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 #include "chrome/browser/devtools/devtools_network_controller.h" | 5 #include "chrome/browser/devtools/devtools_network_controller.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "chrome/browser/devtools/devtools_network_conditions.h" | 9 #include "chrome/browser/devtools/devtools_network_conditions.h" |
10 #include "chrome/browser/devtools/devtools_network_interceptor.h" | 10 #include "chrome/browser/devtools/devtools_network_interceptor.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 return interceptor; | 30 return interceptor; |
31 } | 31 } |
32 | 32 |
33 void DevToolsNetworkController::SetNetworkState( | 33 void DevToolsNetworkController::SetNetworkState( |
34 const std::string& client_id, | 34 const std::string& client_id, |
35 std::unique_ptr<DevToolsNetworkConditions> conditions) { | 35 std::unique_ptr<DevToolsNetworkConditions> conditions) { |
36 DCHECK(thread_checker_.CalledOnValidThread()); | 36 DCHECK(thread_checker_.CalledOnValidThread()); |
37 | 37 |
38 DevToolsNetworkInterceptor* interceptor = interceptors_.get(client_id); | 38 DevToolsNetworkInterceptor* interceptor = interceptors_.get(client_id); |
39 if (!interceptor) { | 39 if (!interceptor) { |
40 DCHECK(conditions); | |
41 if (!conditions) | 40 if (!conditions) |
42 return; | 41 return; |
43 std::unique_ptr<DevToolsNetworkInterceptor> new_interceptor( | 42 std::unique_ptr<DevToolsNetworkInterceptor> new_interceptor( |
44 new DevToolsNetworkInterceptor()); | 43 new DevToolsNetworkInterceptor()); |
45 new_interceptor->UpdateConditions(std::move(conditions)); | 44 new_interceptor->UpdateConditions(std::move(conditions)); |
46 interceptors_.set(client_id, std::move(new_interceptor)); | 45 interceptors_.set(client_id, std::move(new_interceptor)); |
47 } else { | 46 } else { |
48 if (!conditions) { | 47 if (!conditions) { |
49 std::unique_ptr<DevToolsNetworkConditions> online_conditions( | 48 std::unique_ptr<DevToolsNetworkConditions> online_conditions( |
50 new DevToolsNetworkConditions()); | 49 new DevToolsNetworkConditions()); |
(...skipping 13 matching lines...) Expand all Loading... |
64 } | 63 } |
65 } | 64 } |
66 | 65 |
67 bool is_appcache_offline = appcache_interceptor_->IsOffline(); | 66 bool is_appcache_offline = appcache_interceptor_->IsOffline(); |
68 if (is_appcache_offline != has_offline_interceptors) { | 67 if (is_appcache_offline != has_offline_interceptors) { |
69 std::unique_ptr<DevToolsNetworkConditions> appcache_conditions( | 68 std::unique_ptr<DevToolsNetworkConditions> appcache_conditions( |
70 new DevToolsNetworkConditions(has_offline_interceptors)); | 69 new DevToolsNetworkConditions(has_offline_interceptors)); |
71 appcache_interceptor_->UpdateConditions(std::move(appcache_conditions)); | 70 appcache_interceptor_->UpdateConditions(std::move(appcache_conditions)); |
72 } | 71 } |
73 } | 72 } |
OLD | NEW |