2016-04-14 01:29:14 +00:00
|
|
|
// Copyright (c) 2015 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE-CHROMIUM file.
|
|
|
|
|
|
|
|
#ifndef BROWSER_DEVTOOLS_NETWORK_CONTROLLER_HANDLE_H_
|
|
|
|
#define BROWSER_DEVTOOLS_NETWORK_CONTROLLER_HANDLE_H_
|
|
|
|
|
2016-05-23 06:08:20 +00:00
|
|
|
#include <memory>
|
2016-04-14 01:29:14 +00:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "base/macros.h"
|
|
|
|
|
|
|
|
namespace brightray {
|
|
|
|
|
|
|
|
class DevToolsNetworkConditions;
|
|
|
|
class DevToolsNetworkController;
|
|
|
|
|
|
|
|
// A handle to manage an IO-thread DevToolsNetworkController on the IO thread
|
|
|
|
// while allowing SetNetworkState to be called from the UI thread.
|
|
|
|
class DevToolsNetworkControllerHandle {
|
|
|
|
public:
|
|
|
|
DevToolsNetworkControllerHandle();
|
|
|
|
~DevToolsNetworkControllerHandle();
|
|
|
|
|
|
|
|
// Called on the UI thread.
|
|
|
|
void SetNetworkState(const std::string& client_id,
|
2016-05-23 01:59:07 +00:00
|
|
|
std::unique_ptr<DevToolsNetworkConditions> conditions);
|
2016-04-14 01:29:14 +00:00
|
|
|
|
|
|
|
// Called on the IO thread.
|
|
|
|
DevToolsNetworkController* GetController();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void LazyInitialize();
|
2017-03-23 22:47:30 +00:00
|
|
|
void SetNetworkStateOnIO(
|
|
|
|
const std::string& client_id,
|
|
|
|
std::unique_ptr<DevToolsNetworkConditions> conditions);
|
2016-04-14 01:29:14 +00:00
|
|
|
|
2016-05-23 01:59:07 +00:00
|
|
|
std::unique_ptr<DevToolsNetworkController> controller_;
|
2016-04-14 01:29:14 +00:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(DevToolsNetworkControllerHandle);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace brightray
|
|
|
|
|
|
|
|
#endif // BROWSER_DEVTOOLS_NETWORK_CONTROLLER_HANDLE_H_
|