1 // Copyright (c) 2012 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. 4 5 #ifndef CHROME_BROWSER_UI_WEBUI_PERFORMANCE_MONITOR_PERFORMANCE_MONITOR_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_PERFORMANCE_MONITOR_PERFORMANCE_MONITOR_HANDLER_H_ 7 8 #include "base/compiler_specific.h" 9 #include "base/memory/weak_ptr.h" 10 #include "content/public/browser/web_ui_message_handler.h" 11 12 namespace base { 13 class ListValue; 14 class Time; 15 class Value; 16 } // namespace base 17 18 namespace performance_monitor { 19 20 // This class handles messages to and from the performance monitor page. 21 // Incoming calls are handled by the Handle* functions and callbacks are made 22 // from ReturnResults functions. 23 class PerformanceMonitorHandler 24 : public content::WebUIMessageHandler, 25 public base::SupportsWeakPtr<PerformanceMonitorHandler> { 26 public: 27 PerformanceMonitorHandler(); 28 29 private: 30 virtual ~PerformanceMonitorHandler(); 31 32 // WebUIMessageHandler implementation. 33 virtual void RegisterMessages() OVERRIDE; 34 35 // Returns |results| through the given |callback| string. 36 void ReturnResults(const std::string& callback, const base::Value* results); 37 38 // Callback for the "getActiveIntervals" message. 39 // |args| contains a start and an end time. 40 void HandleGetActiveIntervals(const base::ListValue* args); 41 42 // Callback for the "getFlagEnabled" message. 43 // |args| is unused. 44 void HandleGetFlagEnabled(const base::ListValue* args); 45 46 // Callback for the "getAggregationTypes" message. 47 // |args| is unused. 48 void HandleGetAggregationTypes(const base::ListValue* args); 49 50 // Callback for the "getEventTypes" message. 51 // |args| is unused. 52 void HandleGetEventTypes(const base::ListValue* args); 53 54 // Callback for the "getEvents" message. 55 // |args| contains an EventType id to collect and a start and end time. 56 void HandleGetEvents(const base::ListValue* args); 57 58 // Callback for the "getMetricTypes" message. 59 // |args| is unused. 60 void HandleGetMetricTypes(const base::ListValue* args); 61 62 // Callback for the "getMetrics" message. 63 // |args| contains a list of MetricTypes to collect, a start and end time, 64 // a time resolution (defining the spacing of metric samples returned), 65 // and an aggregation method. 66 void HandleGetMetrics(const base::ListValue* args); 67 68 DISALLOW_COPY_AND_ASSIGN(PerformanceMonitorHandler); 69 }; 70 71 } // namespace performance_monitor 72 73 #endif // CHROME_BROWSER_UI_WEBUI_PERFORMANCE_MONITOR_PERFORMANCE_MONITOR_HANDLER_H_ 74