Fix race initialising DevtoolsNetworkController

This commit is contained in:
deepak1556 2016-04-14 06:59:14 +05:30
parent 2f107fcbe1
commit de60acbfde
10 changed files with 130 additions and 35 deletions

View file

@ -0,0 +1,44 @@
// 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_
#include <string>
#include "base/macros.h"
#include "base/memory/scoped_ptr.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,
scoped_ptr<DevToolsNetworkConditions> conditions);
// Called on the IO thread.
DevToolsNetworkController* GetController();
private:
void LazyInitialize();
void SetNetworkStateOnIO(const std::string& client_id,
scoped_ptr<DevToolsNetworkConditions> conditions);
scoped_ptr<DevToolsNetworkController> controller_;
DISALLOW_COPY_AND_ASSIGN(DevToolsNetworkControllerHandle);
};
} // namespace brightray
#endif // BROWSER_DEVTOOLS_NETWORK_CONTROLLER_HANDLE_H_