Popular sites on the NTP: re-download popular suggestions once per Chrome run
[chromium-blink-merge.git] / chrome / browser / devtools / devtools_network_controller_handle.h
blob7aee0ff56e957ba61324788474a2bf9efd21cca2
1 // Copyright 2015 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 CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_CONTROLLER_HANDLE_H_
6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_CONTROLLER_HANDLE_H_
8 #include <string>
10 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
13 class DevToolsNetworkConditions;
14 class DevToolsNetworkController;
16 // A handle to manage an IO-thread DevToolsNetworkController on the IO thread
17 // while allowing SetNetworkState to be called from the UI thread. Must be
18 // created on the UI thread and destroyed on the IO thread.
19 class DevToolsNetworkControllerHandle {
20 public:
21 DevToolsNetworkControllerHandle();
22 ~DevToolsNetworkControllerHandle();
24 // Called on the UI thread.
25 void SetNetworkState(const std::string& client_id,
26 scoped_ptr<DevToolsNetworkConditions> conditions);
28 // Called on the IO thread.
29 DevToolsNetworkController* GetController();
31 private:
32 void LazyInitialize();
33 void SetNetworkStateOnIO(const std::string& client_id,
34 scoped_ptr<DevToolsNetworkConditions> conditions);
36 scoped_ptr<DevToolsNetworkController> controller_;
38 DISALLOW_COPY_AND_ASSIGN(DevToolsNetworkControllerHandle);
41 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_CONTROLLER_HANDLE_H_