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 CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_CONTROLLER_H_
6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_CONTROLLER_H_
10 #include "base/containers/scoped_ptr_hash_map.h"
11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
14 #include "base/threading/thread_checker.h"
16 class DevToolsNetworkConditions
;
17 class DevToolsNetworkInterceptor
;
18 class DevToolsNetworkTransaction
;
21 class DevToolsNetworkControllerHelper
;
24 // DevToolsNetworkController tracks DevToolsNetworkTransactions.
25 class DevToolsNetworkController
{
28 DevToolsNetworkController();
29 virtual ~DevToolsNetworkController();
31 // Applies network emulation configuration.
33 const std::string
& client_id
,
34 scoped_ptr
<DevToolsNetworkConditions
> conditions
);
36 base::WeakPtr
<DevToolsNetworkInterceptor
> GetInterceptor(
37 DevToolsNetworkTransaction
* transaction
);
40 friend class test::DevToolsNetworkControllerHelper
;
43 // Controller must be constructed on IO thread.
44 base::ThreadChecker thread_checker_
;
46 void SetNetworkStateOnIO(
47 const std::string
& client_id
,
48 scoped_ptr
<DevToolsNetworkConditions
> conditions
);
50 typedef scoped_ptr
<DevToolsNetworkInterceptor
> Interceptor
;
51 Interceptor default_interceptor_
;
52 Interceptor appcache_interceptor_
;
53 typedef base::ScopedPtrHashMap
<std::string
,
54 scoped_ptr
<DevToolsNetworkInterceptor
>>
56 Interceptors interceptors_
;
58 base::WeakPtrFactory
<DevToolsNetworkController
> weak_ptr_factory_
;
60 DISALLOW_COPY_AND_ASSIGN(DevToolsNetworkController
);
63 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_CONTROLLER_H_