Revert "Fix broken channel icon in chrome://help on CrOS" and try again
[chromium-blink-merge.git] / components / html_viewer / stats_collection_controller.h
blobac9e307afc1ba014f1198c5da8f8c31ccd8d2891
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_HTML_VIEWER_STATS_COLLECTION_CONTROLLER_H_
6 #define COMPONENTS_HTML_VIEWER_STATS_COLLECTION_CONTROLLER_H_
8 #include "base/basictypes.h"
9 #include "gin/wrappable.h"
10 #include "mojo/services/tracing/public/interfaces/tracing.mojom.h"
12 namespace blink {
13 class WebFrame;
16 namespace mojo {
17 class ApplicationImpl;
20 namespace html_viewer {
22 // This class is exposed in JS as window.statsCollectionController and provides
23 // functionality to read out statistics from the browser.
24 // Its use must be enabled specifically via the
25 // --enable-stats-collection-bindings command line flag.
26 class StatsCollectionController
27 : public gin::Wrappable<StatsCollectionController> {
28 public:
29 static gin::WrapperInfo kWrapperInfo;
31 // Install the JS and return a mojo:tracing InterfacePtr for stats reporting.
32 // This bails and returns a null pointer without the command line flag.
33 static tracing::StartupPerformanceDataCollectorPtr Install(
34 blink::WebFrame* frame,
35 mojo::ApplicationImpl* app);
37 private:
38 explicit StatsCollectionController(
39 tracing::StartupPerformanceDataCollectorPtr collector);
40 ~StatsCollectionController() override;
42 // gin::WrappableBase
43 gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
44 v8::Isolate* isolate) override;
46 // Retrieves a histogram and returns a JSON representation of it.
47 std::string GetHistogram(const std::string& histogram_name);
49 // Retrieves a browser histogram and returns a JSON representation of it.
50 std::string GetBrowserHistogram(const std::string& histogram_name);
52 tracing::StartupPerformanceDataCollectorPtr
53 startup_performance_data_collector_;
55 DISALLOW_COPY_AND_ASSIGN(StatsCollectionController);
58 } // namespace html_viewer
60 #endif // COMPONENTS_HTML_VIEWER_STATS_COLLECTION_CONTROLLER_H_