| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/policy/device_management_service.h" | 5 #include "chrome/browser/policy/device_management_service.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 os_version.c_str()); | 179 os_version.c_str()); |
| 180 return platform; | 180 return platform; |
| 181 } | 181 } |
| 182 | 182 |
| 183 // Custom request context implementation that allows to override the user agent, | 183 // Custom request context implementation that allows to override the user agent, |
| 184 // amongst others. Wraps a baseline request context from which we reuse the | 184 // amongst others. Wraps a baseline request context from which we reuse the |
| 185 // networking components. | 185 // networking components. |
| 186 class DeviceManagementRequestContext : public net::URLRequestContext { | 186 class DeviceManagementRequestContext : public net::URLRequestContext { |
| 187 public: | 187 public: |
| 188 explicit DeviceManagementRequestContext(net::URLRequestContext* base_context); | 188 explicit DeviceManagementRequestContext(net::URLRequestContext* base_context); |
| 189 virtual ~DeviceManagementRequestContext(); |
| 189 | 190 |
| 190 private: | 191 private: |
| 191 virtual ~DeviceManagementRequestContext(); | |
| 192 | |
| 193 // Overridden from net::URLRequestContext: | 192 // Overridden from net::URLRequestContext: |
| 194 virtual const std::string& GetUserAgent(const GURL& url) const OVERRIDE; | 193 virtual const std::string& GetUserAgent(const GURL& url) const OVERRIDE; |
| 195 }; | 194 }; |
| 196 | 195 |
| 197 DeviceManagementRequestContext::DeviceManagementRequestContext( | 196 DeviceManagementRequestContext::DeviceManagementRequestContext( |
| 198 net::URLRequestContext* base_context) { | 197 net::URLRequestContext* base_context) { |
| 199 // Share resolver, proxy service and ssl bits with the baseline context. This | 198 // Share resolver, proxy service and ssl bits with the baseline context. This |
| 200 // is important so we don't make redundant requests (e.g. when resolving proxy | 199 // is important so we don't make redundant requests (e.g. when resolving proxy |
| 201 // auto configuration). | 200 // auto configuration). |
| 202 set_net_log(base_context->net_log()); | 201 set_net_log(base_context->net_log()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 | 235 |
| 237 // Overridden from net::URLRequestContextGetter: | 236 // Overridden from net::URLRequestContextGetter: |
| 238 virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE; | 237 virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE; |
| 239 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() | 238 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() |
| 240 const OVERRIDE; | 239 const OVERRIDE; |
| 241 | 240 |
| 242 protected: | 241 protected: |
| 243 virtual ~DeviceManagementRequestContextGetter() {} | 242 virtual ~DeviceManagementRequestContextGetter() {} |
| 244 | 243 |
| 245 private: | 244 private: |
| 246 scoped_refptr<net::URLRequestContext> context_; | 245 scoped_ptr<net::URLRequestContext> context_; |
| 247 scoped_refptr<net::URLRequestContextGetter> base_context_getter_; | 246 scoped_refptr<net::URLRequestContextGetter> base_context_getter_; |
| 248 }; | 247 }; |
| 249 | 248 |
| 250 | 249 |
| 251 net::URLRequestContext* | 250 net::URLRequestContext* |
| 252 DeviceManagementRequestContextGetter::GetURLRequestContext() { | 251 DeviceManagementRequestContextGetter::GetURLRequestContext() { |
| 253 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 252 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 254 if (!context_) { | 253 if (!context_.get()) { |
| 255 context_ = new DeviceManagementRequestContext( | 254 context_.reset(new DeviceManagementRequestContext( |
| 256 base_context_getter_->GetURLRequestContext()); | 255 base_context_getter_->GetURLRequestContext())); |
| 257 } | 256 } |
| 258 | 257 |
| 259 return context_.get(); | 258 return context_.get(); |
| 260 } | 259 } |
| 261 | 260 |
| 262 scoped_refptr<base::MessageLoopProxy> | 261 scoped_refptr<base::MessageLoopProxy> |
| 263 DeviceManagementRequestContextGetter::GetIOMessageLoopProxy() const { | 262 DeviceManagementRequestContextGetter::GetIOMessageLoopProxy() const { |
| 264 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 263 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
| 265 } | 264 } |
| 266 | 265 |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 } | 585 } |
| 587 } | 586 } |
| 588 | 587 |
| 589 const JobQueue::iterator elem = | 588 const JobQueue::iterator elem = |
| 590 std::find(queued_jobs_.begin(), queued_jobs_.end(), job); | 589 std::find(queued_jobs_.begin(), queued_jobs_.end(), job); |
| 591 if (elem != queued_jobs_.end()) | 590 if (elem != queued_jobs_.end()) |
| 592 queued_jobs_.erase(elem); | 591 queued_jobs_.erase(elem); |
| 593 } | 592 } |
| 594 | 593 |
| 595 } // namespace policy | 594 } // namespace policy |
| OLD | NEW |