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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_SYSTEM_INFO_HANDLER_H_
6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_SYSTEM_INFO_HANDLER_H_
10 #include "content/browser/devtools/protocol/devtools_protocol_dispatcher.h"
11 #include "content/public/browser/browser_thread.h"
12 #include "content/public/browser/gpu_data_manager_observer.h"
16 namespace system_info
{
18 class SystemInfoHandler
{
20 using Response
= DevToolsProtocolClient::Response
;
25 void SetClient(scoped_ptr
<Client
> client
);
27 Response
GetInfo(DevToolsCommandId command_id
);
30 friend class SystemInfoHandlerGpuObserver
;
32 void SendGetInfoResponse(DevToolsCommandId command_id
);
34 // Bookkeeping for the active GpuObservers.
35 void AddActiveObserverId(int observer_id
);
36 bool RemoveActiveObserverId(int observer_id
);
37 void ObserverWatchdogCallback(int observer_id
, DevToolsCommandId command_id
);
39 // For robustness, we have to guarantee a response to getInfo requests.
40 // It's very unlikely that the requests will time out. The
41 // 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
43 // 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
45 // callback from the GpuDataManager in time.
46 mutable base::Lock lock_
;
47 std::set
<int> active_observers_
;
49 scoped_ptr
<Client
> client_
;
50 base::WeakPtrFactory
<SystemInfoHandler
> weak_factory_
;
52 DISALLOW_COPY_AND_ASSIGN(SystemInfoHandler
);
55 } // namespace system_info
56 } // namespace devtools
57 } // namespace content
59 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_SYSTEM_INFO_HANDLER_H_