| 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> |
| 8 |
| 7 #include "chrome/browser/devtools/devtools_network_conditions.h" | 9 #include "chrome/browser/devtools/devtools_network_conditions.h" |
| 8 #include "chrome/browser/devtools/devtools_network_interceptor.h" | 10 #include "chrome/browser/devtools/devtools_network_interceptor.h" |
| 9 #include "net/http/http_request_info.h" | 11 #include "net/http/http_request_info.h" |
| 10 | 12 |
| 11 DevToolsNetworkController::DevToolsNetworkController() | 13 DevToolsNetworkController::DevToolsNetworkController() |
| 12 : appcache_interceptor_(new DevToolsNetworkInterceptor()) {} | 14 : appcache_interceptor_(new DevToolsNetworkInterceptor()) {} |
| 13 | 15 |
| 14 DevToolsNetworkController::~DevToolsNetworkController() { | 16 DevToolsNetworkController::~DevToolsNetworkController() { |
| 15 DCHECK(thread_checker_.CalledOnValidThread()); | 17 DCHECK(thread_checker_.CalledOnValidThread()); |
| 16 } | 18 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 33 scoped_ptr<DevToolsNetworkConditions> conditions) { | 35 scoped_ptr<DevToolsNetworkConditions> conditions) { |
| 34 DCHECK(thread_checker_.CalledOnValidThread()); | 36 DCHECK(thread_checker_.CalledOnValidThread()); |
| 35 | 37 |
| 36 DevToolsNetworkInterceptor* interceptor = interceptors_.get(client_id); | 38 DevToolsNetworkInterceptor* interceptor = interceptors_.get(client_id); |
| 37 if (!interceptor) { | 39 if (!interceptor) { |
| 38 DCHECK(conditions); | 40 DCHECK(conditions); |
| 39 if (!conditions) | 41 if (!conditions) |
| 40 return; | 42 return; |
| 41 scoped_ptr<DevToolsNetworkInterceptor> new_interceptor( | 43 scoped_ptr<DevToolsNetworkInterceptor> new_interceptor( |
| 42 new DevToolsNetworkInterceptor()); | 44 new DevToolsNetworkInterceptor()); |
| 43 new_interceptor->UpdateConditions(conditions.Pass()); | 45 new_interceptor->UpdateConditions(std::move(conditions)); |
| 44 interceptors_.set(client_id, new_interceptor.Pass()); | 46 interceptors_.set(client_id, std::move(new_interceptor)); |
| 45 } else { | 47 } else { |
| 46 if (!conditions) { | 48 if (!conditions) { |
| 47 scoped_ptr<DevToolsNetworkConditions> online_conditions( | 49 scoped_ptr<DevToolsNetworkConditions> online_conditions( |
| 48 new DevToolsNetworkConditions()); | 50 new DevToolsNetworkConditions()); |
| 49 interceptor->UpdateConditions(online_conditions.Pass()); | 51 interceptor->UpdateConditions(std::move(online_conditions)); |
| 50 interceptors_.erase(client_id); | 52 interceptors_.erase(client_id); |
| 51 } else { | 53 } else { |
| 52 interceptor->UpdateConditions(conditions.Pass()); | 54 interceptor->UpdateConditions(std::move(conditions)); |
| 53 } | 55 } |
| 54 } | 56 } |
| 55 | 57 |
| 56 bool has_offline_interceptors = false; | 58 bool has_offline_interceptors = false; |
| 57 InterceptorMap::iterator it = interceptors_.begin(); | 59 InterceptorMap::iterator it = interceptors_.begin(); |
| 58 for (; it != interceptors_.end(); ++it) { | 60 for (; it != interceptors_.end(); ++it) { |
| 59 if (it->second->IsOffline()) { | 61 if (it->second->IsOffline()) { |
| 60 has_offline_interceptors = true; | 62 has_offline_interceptors = true; |
| 61 break; | 63 break; |
| 62 } | 64 } |
| 63 } | 65 } |
| 64 | 66 |
| 65 bool is_appcache_offline = appcache_interceptor_->IsOffline(); | 67 bool is_appcache_offline = appcache_interceptor_->IsOffline(); |
| 66 if (is_appcache_offline != has_offline_interceptors) { | 68 if (is_appcache_offline != has_offline_interceptors) { |
| 67 scoped_ptr<DevToolsNetworkConditions> appcache_conditions( | 69 scoped_ptr<DevToolsNetworkConditions> appcache_conditions( |
| 68 new DevToolsNetworkConditions(has_offline_interceptors)); | 70 new DevToolsNetworkConditions(has_offline_interceptors)); |
| 69 appcache_interceptor_->UpdateConditions(appcache_conditions.Pass()); | 71 appcache_interceptor_->UpdateConditions(std::move(appcache_conditions)); |
| 70 } | 72 } |
| 71 } | 73 } |
| OLD | NEW |