blob: dddcac987b3c54ef79e3bc60917e98c48b8d24aa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
// Copyright 2014 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 file.
#ifndef CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_CONTROLLER_H_
#define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_CONTROLLER_H_
#include <string>
#include "base/containers/scoped_ptr_hash_map.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/threading/thread_checker.h"
class DevToolsNetworkConditions;
class DevToolsNetworkInterceptor;
class DevToolsNetworkTransaction;
namespace test {
class DevToolsNetworkControllerHelper;
}
// DevToolsNetworkController tracks DevToolsNetworkTransactions.
class DevToolsNetworkController {
public:
DevToolsNetworkController();
virtual ~DevToolsNetworkController();
// Applies network emulation configuration.
void SetNetworkState(
const std::string& client_id,
scoped_ptr<DevToolsNetworkConditions> conditions);
base::WeakPtr<DevToolsNetworkInterceptor> GetInterceptor(
DevToolsNetworkTransaction* transaction);
protected:
friend class test::DevToolsNetworkControllerHelper;
private:
// Controller must be constructed on IO thread.
base::ThreadChecker thread_checker_;
void SetNetworkStateOnIO(
const std::string& client_id,
scoped_ptr<DevToolsNetworkConditions> conditions);
typedef scoped_ptr<DevToolsNetworkInterceptor> Interceptor;
Interceptor default_interceptor_;
Interceptor appcache_interceptor_;
typedef base::ScopedPtrHashMap<std::string,
scoped_ptr<DevToolsNetworkInterceptor>>
Interceptors;
Interceptors interceptors_;
base::WeakPtrFactory<DevToolsNetworkController> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(DevToolsNetworkController);
};
#endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_CONTROLLER_H_
|