OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CONTENT_BROWSER_DEVTOOLS_PROTOCOL_SYSTEM_INFO_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_SYSTEM_INFO_HANDLER_H_ |
6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_SYSTEM_INFO_HANDLER_H_ | 6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_SYSTEM_INFO_HANDLER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "content/browser/devtools/protocol/devtools_protocol_dispatcher.h" | 10 #include "content/browser/devtools/protocol/devtools_protocol_dispatcher.h" |
11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
12 #include "content/public/browser/gpu_data_manager_observer.h" | 12 #include "content/public/browser/gpu_data_manager_observer.h" |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 namespace devtools { | 15 namespace devtools { |
16 namespace system_info { | 16 namespace system_info { |
17 | 17 |
18 class SystemInfoHandler { | 18 class SystemInfoHandler { |
19 public: | 19 public: |
20 using Response = DevToolsProtocolClient::Response; | 20 using Response = DevToolsProtocolClient::Response; |
21 | 21 |
22 SystemInfoHandler(); | 22 SystemInfoHandler(); |
23 ~SystemInfoHandler(); | 23 ~SystemInfoHandler(); |
24 | 24 |
25 void SetClient(scoped_ptr<Client> client); | 25 void SetClient(scoped_ptr<Client> client); |
26 | 26 |
27 Response GetInfo(DevToolsCommandId command_id); | 27 Response GetInfo(int session_id, DevToolsCommandId command_id); |
28 | 28 |
29 private: | 29 private: |
30 friend class SystemInfoHandlerGpuObserver; | 30 friend class SystemInfoHandlerGpuObserver; |
31 | 31 |
32 void SendGetInfoResponse(DevToolsCommandId command_id); | 32 void SendGetInfoResponse(int session_id, DevToolsCommandId command_id); |
33 | 33 |
34 // Bookkeeping for the active GpuObservers. | 34 // Bookkeeping for the active GpuObservers. |
35 void AddActiveObserverId(int observer_id); | 35 void AddActiveObserverId(int observer_id); |
36 bool RemoveActiveObserverId(int observer_id); | 36 bool RemoveActiveObserverId(int observer_id); |
37 void ObserverWatchdogCallback(int observer_id, DevToolsCommandId command_id); | 37 void ObserverWatchdogCallback(int observer_id, |
| 38 int session_id, |
| 39 DevToolsCommandId command_id); |
38 | 40 |
39 // For robustness, we have to guarantee a response to getInfo requests. | 41 // For robustness, we have to guarantee a response to getInfo requests. |
40 // It's very unlikely that the requests will time out. The | 42 // It's very unlikely that the requests will time out. The |
41 // GpuDataManager's threading model is not well defined (see comments in | 43 // GpuDataManager's threading model is not well defined (see comments in |
42 // gpu_data_manager_impl.h) and it is very difficult to correctly clean | 44 // gpu_data_manager_impl.h) and it is very difficult to correctly clean |
43 // up its observers. For the moment, especially since these classes are | 45 // up its observers. For the moment, especially since these classes are |
44 // only used in tests, we leak a little bit of memory if we don't get a | 46 // only used in tests, we leak a little bit of memory if we don't get a |
45 // callback from the GpuDataManager in time. | 47 // callback from the GpuDataManager in time. |
46 mutable base::Lock lock_; | 48 mutable base::Lock lock_; |
47 std::set<int> active_observers_; | 49 std::set<int> active_observers_; |
48 | 50 |
49 scoped_ptr<Client> client_; | 51 scoped_ptr<Client> client_; |
50 base::WeakPtrFactory<SystemInfoHandler> weak_factory_; | 52 base::WeakPtrFactory<SystemInfoHandler> weak_factory_; |
51 | 53 |
52 DISALLOW_COPY_AND_ASSIGN(SystemInfoHandler); | 54 DISALLOW_COPY_AND_ASSIGN(SystemInfoHandler); |
53 }; | 55 }; |
54 | 56 |
55 } // namespace system_info | 57 } // namespace system_info |
56 } // namespace devtools | 58 } // namespace devtools |
57 } // namespace content | 59 } // namespace content |
58 | 60 |
59 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_SYSTEM_INFO_HANDLER_H_ | 61 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_SYSTEM_INFO_HANDLER_H_ |
OLD | NEW |