[email protected] | b05596b | 2013-12-10 18:43:23 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "android_webview/browser/aw_resource_context.h" |
| 6 | |
| 7 | #include "content/public/browser/browser_thread.h" |
| 8 | #include "net/url_request/url_request_context.h" |
| 9 | #include "net/url_request/url_request_context_getter.h" |
| 10 | |
mostynb | f498ecf | 2015-03-18 14:17:24 | [diff] [blame] | 11 | using content::BrowserThread; |
| 12 | |
[email protected] | b05596b | 2013-12-10 18:43:23 | [diff] [blame] | 13 | namespace android_webview { |
| 14 | |
John Abd-El-Malek | 8104d67 | 2018-11-28 20:27:03 | [diff] [blame] | 15 | AwResourceContext::AwResourceContext() { |
[email protected] | b05596b | 2013-12-10 18:43:23 | [diff] [blame] | 16 | } |
| 17 | |
| 18 | AwResourceContext::~AwResourceContext() { |
| 19 | } |
| 20 | |
| 21 | void AwResourceContext::SetExtraHeaders( |
| 22 | const GURL& url, const std::string& headers) { |
mostynb | f498ecf | 2015-03-18 14:17:24 | [diff] [blame] | 23 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
[email protected] | b05596b | 2013-12-10 18:43:23 | [diff] [blame] | 24 | if (!url.is_valid()) return; |
| 25 | base::AutoLock scoped_lock(extra_headers_lock_); |
| 26 | if (!headers.empty()) |
| 27 | extra_headers_[url.spec()] = headers; |
| 28 | else |
| 29 | extra_headers_.erase(url.spec()); |
| 30 | } |
| 31 | |
| 32 | std::string AwResourceContext::GetExtraHeaders(const GURL& url) { |
[email protected] | b05596b | 2013-12-10 18:43:23 | [diff] [blame] | 33 | if (!url.is_valid()) return std::string(); |
| 34 | base::AutoLock scoped_lock(extra_headers_lock_); |
| 35 | std::map<std::string, std::string>::iterator iter = |
| 36 | extra_headers_.find(url.spec()); |
| 37 | return iter != extra_headers_.end() ? iter->second : std::string(); |
| 38 | } |
| 39 | |
[email protected] | b05596b | 2013-12-10 18:43:23 | [diff] [blame] | 40 | } // namespace android_webview |