Chromium Code Reviews| 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/system_info.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 protocol { |
| 17 namespace system_info { | |
| 18 | 17 |
| 19 class SystemInfoHandler { | 18 class SystemInfoHandler : public SystemInfo::Backend { |
| 20 public: | 19 public: |
| 21 using Response = DevToolsProtocolClient::Response; | |
| 22 | 20 |
| 23 SystemInfoHandler(); | 21 SystemInfoHandler(); |
| 24 ~SystemInfoHandler(); | 22 ~SystemInfoHandler() override; |
| 25 | 23 |
| 26 void SetClient(std::unique_ptr<Client> client); | 24 void Wire(UberDispatcher*); |
| 25 Response Disable() override; | |
| 27 | 26 |
| 28 Response GetInfo(DevToolsCommandId command_id); | 27 void GetInfo(std::unique_ptr<GetInfoCallback> callback) override; |
| 29 | 28 |
| 30 private: | 29 private: |
| 31 friend class SystemInfoHandlerGpuObserver; | 30 friend class SystemInfoHandlerGpuObserver; |
| 32 | 31 |
| 33 void SendGetInfoResponse(DevToolsCommandId command_id); | 32 std::unique_ptr<SystemInfo::Frontend> frontend_; |
|
caseq
2016/11/21 23:32:33
also unused?
dgozman
2016/11/22 00:53:39
Done.
| |
| 34 | |
| 35 // Bookkeeping for the active GpuObservers. | |
| 36 void AddActiveObserverId(int observer_id); | |
| 37 bool RemoveActiveObserverId(int observer_id); | |
| 38 void ObserverWatchdogCallback(int observer_id, DevToolsCommandId command_id); | |
| 39 | |
| 40 // For robustness, we have to guarantee a response to getInfo requests. | |
| 41 // It's very unlikely that the requests will time out. The | |
| 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 | |
| 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 | |
| 46 // callback from the GpuDataManager in time. | |
| 47 mutable base::Lock lock_; | |
| 48 std::set<int> active_observers_; | |
| 49 | |
| 50 std::unique_ptr<Client> client_; | |
| 51 base::WeakPtrFactory<SystemInfoHandler> weak_factory_; | |
| 52 | 33 |
| 53 DISALLOW_COPY_AND_ASSIGN(SystemInfoHandler); | 34 DISALLOW_COPY_AND_ASSIGN(SystemInfoHandler); |
| 54 }; | 35 }; |
| 55 | 36 |
| 56 } // namespace system_info | 37 } // namespace protocol |
| 57 } // namespace devtools | |
| 58 } // namespace content | 38 } // namespace content |
| 59 | 39 |
| 60 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_SYSTEM_INFO_HANDLER_H_ | 40 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_SYSTEM_INFO_HANDLER_H_ |
| OLD | NEW |