| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_HTML_VIEWER_STATS_COLLECTION_CONTROLLER_H_ | 5 #ifndef COMPONENTS_HTML_VIEWER_STATS_COLLECTION_CONTROLLER_H_ |
| 6 #define COMPONENTS_HTML_VIEWER_STATS_COLLECTION_CONTROLLER_H_ | 6 #define COMPONENTS_HTML_VIEWER_STATS_COLLECTION_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "gin/wrappable.h" | 9 #include "gin/wrappable.h" |
| 10 #include "mojo/services/tracing/public/interfaces/tracing.mojom.h" | 10 #include "mojo/services/tracing/public/interfaces/tracing.mojom.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 class WebFrame; | 13 class WebFrame; |
| 14 } | 14 } |
| 15 | 15 |
| 16 namespace mojo { | 16 namespace mojo { |
| 17 class ApplicationImpl; | 17 class Shell; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace html_viewer { | 20 namespace html_viewer { |
| 21 | 21 |
| 22 // This class is exposed in JS as window.statsCollectionController and provides | 22 // This class is exposed in JS as window.statsCollectionController and provides |
| 23 // functionality to read out statistics from the browser. | 23 // functionality to read out statistics from the browser. |
| 24 // Its use must be enabled specifically via the | 24 // Its use must be enabled specifically via the |
| 25 // --enable-stats-collection-bindings command line flag. | 25 // --enable-stats-collection-bindings command line flag. |
| 26 class StatsCollectionController | 26 class StatsCollectionController |
| 27 : public gin::Wrappable<StatsCollectionController> { | 27 : public gin::Wrappable<StatsCollectionController> { |
| 28 public: | 28 public: |
| 29 static gin::WrapperInfo kWrapperInfo; | 29 static gin::WrapperInfo kWrapperInfo; |
| 30 | 30 |
| 31 // Install the JS and return a mojo:tracing InterfacePtr for stats reporting. | 31 // Install the JS and return a mojo:tracing InterfacePtr for stats reporting. |
| 32 // This bails and returns a null pointer without the stats command line flag. | 32 // This bails and returns a null pointer without the stats command line flag. |
| 33 static tracing::StartupPerformanceDataCollectorPtr Install( | 33 static tracing::StartupPerformanceDataCollectorPtr Install( |
| 34 blink::WebFrame* frame, | 34 blink::WebFrame* frame, |
| 35 mojo::ApplicationImpl* app); | 35 mojo::Shell* shell); |
| 36 | 36 |
| 37 // Return a mojo:metrics InterfacePtr for stats reporting. | 37 // Return a mojo:metrics InterfacePtr for stats reporting. |
| 38 // This bails and returns a null pointer without the stats command line flag. | 38 // This bails and returns a null pointer without the stats command line flag. |
| 39 static tracing::StartupPerformanceDataCollectorPtr ConnectToDataCollector( | 39 static tracing::StartupPerformanceDataCollectorPtr ConnectToDataCollector( |
| 40 mojo::ApplicationImpl* app); | 40 mojo::Shell* shell); |
| 41 | 41 |
| 42 private: | 42 private: |
| 43 explicit StatsCollectionController( | 43 explicit StatsCollectionController( |
| 44 tracing::StartupPerformanceDataCollectorPtr collector); | 44 tracing::StartupPerformanceDataCollectorPtr collector); |
| 45 ~StatsCollectionController() override; | 45 ~StatsCollectionController() override; |
| 46 | 46 |
| 47 // gin::WrappableBase | 47 // gin::WrappableBase |
| 48 gin::ObjectTemplateBuilder GetObjectTemplateBuilder( | 48 gin::ObjectTemplateBuilder GetObjectTemplateBuilder( |
| 49 v8::Isolate* isolate) override; | 49 v8::Isolate* isolate) override; |
| 50 | 50 |
| 51 // Retrieves a histogram and returns a JSON representation of it. | 51 // Retrieves a histogram and returns a JSON representation of it. |
| 52 std::string GetHistogram(const std::string& histogram_name); | 52 std::string GetHistogram(const std::string& histogram_name); |
| 53 | 53 |
| 54 // Retrieves a browser histogram and returns a JSON representation of it. | 54 // Retrieves a browser histogram and returns a JSON representation of it. |
| 55 std::string GetBrowserHistogram(const std::string& histogram_name); | 55 std::string GetBrowserHistogram(const std::string& histogram_name); |
| 56 | 56 |
| 57 tracing::StartupPerformanceDataCollectorPtr | 57 tracing::StartupPerformanceDataCollectorPtr |
| 58 startup_performance_data_collector_; | 58 startup_performance_data_collector_; |
| 59 | 59 |
| 60 DISALLOW_COPY_AND_ASSIGN(StatsCollectionController); | 60 DISALLOW_COPY_AND_ASSIGN(StatsCollectionController); |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 } // namespace html_viewer | 63 } // namespace html_viewer |
| 64 | 64 |
| 65 #endif // COMPONENTS_HTML_VIEWER_STATS_COLLECTION_CONTROLLER_H_ | 65 #endif // COMPONENTS_HTML_VIEWER_STATS_COLLECTION_CONTROLLER_H_ |
| OLD | NEW |