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