| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/net/spdyproxy/proxy_advisor.h" | 5 #include "chrome/browser/net/spdyproxy/proxy_advisor.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 net::URLRequestContextGetter* context_getter) | 78 net::URLRequestContextGetter* context_getter) |
| 79 : context_getter_(context_getter) { | 79 : context_getter_(context_getter) { |
| 80 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 80 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 81 | 81 |
| 82 // pref_service may be null in mock test subclasses. | 82 // pref_service may be null in mock test subclasses. |
| 83 if (pref_service) { | 83 if (pref_service) { |
| 84 proxy_pref_member_.Init( | 84 proxy_pref_member_.Init( |
| 85 data_reduction_proxy::prefs::kDataReductionProxyEnabled, | 85 data_reduction_proxy::prefs::kDataReductionProxyEnabled, |
| 86 pref_service, | 86 pref_service, |
| 87 base::Bind(&ProxyAdvisor::UpdateProxyState, base::Unretained(this))); | 87 base::Bind(&ProxyAdvisor::UpdateProxyState, base::Unretained(this))); |
| 88 proxy_pref_member_.MoveToThread( | 88 proxy_pref_member_.MoveToTaskRunner( |
| 89 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 89 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 | 92 |
| 93 ProxyAdvisor::~ProxyAdvisor() { | 93 ProxyAdvisor::~ProxyAdvisor() { |
| 94 STLDeleteElements(&inflight_requests_); | 94 STLDeleteElements(&inflight_requests_); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void ProxyAdvisor::OnResponseStarted(net::URLRequest* request) { | 97 void ProxyAdvisor::OnResponseStarted(net::URLRequest* request) { |
| 98 const net::URLRequestStatus& status(request->status()); | 98 const net::URLRequestStatus& status(request->status()); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 scoped_ptr<net::URLRequest> scoped_request_for_deletion(request); | 160 scoped_ptr<net::URLRequest> scoped_request_for_deletion(request); |
| 161 inflight_requests_.erase(request); | 161 inflight_requests_.erase(request); |
| 162 // |scoped_request_for_deletion| will delete |request| | 162 // |scoped_request_for_deletion| will delete |request| |
| 163 } | 163 } |
| 164 | 164 |
| 165 void ProxyAdvisor::UpdateProxyState() { | 165 void ProxyAdvisor::UpdateProxyState() { |
| 166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 167 // Delete all inflight requests. Each request's destructor will call Cancel(). | 167 // Delete all inflight requests. Each request's destructor will call Cancel(). |
| 168 STLDeleteElements(&inflight_requests_); | 168 STLDeleteElements(&inflight_requests_); |
| 169 } | 169 } |
| OLD | NEW |