| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_CONTROLLER_H_ | 6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/containers/scoped_ptr_hash_map.h" | 10 #include "base/containers/scoped_ptr_hash_map.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
| 15 | 15 |
| 16 class DevToolsNetworkConditions; | 16 class DevToolsNetworkConditions; |
| 17 class DevToolsNetworkInterceptor; | 17 class DevToolsNetworkInterceptor; |
| 18 class DevToolsNetworkTransaction; | |
| 19 | 18 |
| 20 // DevToolsNetworkController tracks DevToolsNetworkTransactions. | 19 // DevToolsNetworkController manages interceptors identified by client id |
| 20 // and their throttling conditions. |
| 21 class DevToolsNetworkController { | 21 class DevToolsNetworkController { |
| 22 public: | 22 public: |
| 23 DevToolsNetworkController(); | 23 DevToolsNetworkController(); |
| 24 virtual ~DevToolsNetworkController(); | 24 virtual ~DevToolsNetworkController(); |
| 25 | 25 |
| 26 // Applies network emulation configuration. | 26 // Applies network emulation configuration. |
| 27 void SetNetworkState( | 27 void SetNetworkState( |
| 28 const std::string& client_id, | 28 const std::string& client_id, |
| 29 scoped_ptr<DevToolsNetworkConditions> conditions); | 29 scoped_ptr<DevToolsNetworkConditions> conditions); |
| 30 | 30 |
| 31 base::WeakPtr<DevToolsNetworkInterceptor> GetInterceptor( | 31 base::WeakPtr<DevToolsNetworkInterceptor> GetInterceptor( |
| 32 DevToolsNetworkTransaction* transaction); | 32 const std::string& client_id); |
| 33 | 33 |
| 34 private: | 34 private: |
| 35 using InterceptorMap = | 35 using InterceptorMap = |
| 36 base::ScopedPtrHashMap<std::string, | 36 base::ScopedPtrHashMap<std::string, |
| 37 scoped_ptr<DevToolsNetworkInterceptor>>; | 37 scoped_ptr<DevToolsNetworkInterceptor>>; |
| 38 | 38 |
| 39 scoped_ptr<DevToolsNetworkInterceptor> default_interceptor_; | 39 scoped_ptr<DevToolsNetworkInterceptor> default_interceptor_; |
| 40 scoped_ptr<DevToolsNetworkInterceptor> appcache_interceptor_; | 40 scoped_ptr<DevToolsNetworkInterceptor> appcache_interceptor_; |
| 41 InterceptorMap interceptors_; | 41 InterceptorMap interceptors_; |
| 42 base::ThreadChecker thread_checker_; | 42 base::ThreadChecker thread_checker_; |
| 43 | 43 |
| 44 DISALLOW_COPY_AND_ASSIGN(DevToolsNetworkController); | 44 DISALLOW_COPY_AND_ASSIGN(DevToolsNetworkController); |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_CONTROLLER_H_ | 47 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_CONTROLLER_H_ |
| OLD | NEW |