aw_resource_context.cc 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. #include "android_webview/browser/aw_resource_context.h"
  5. #include "content/public/browser/browser_thread.h"
  6. #include "net/url_request/url_request_context.h"
  7. #include "net/url_request/url_request_context_getter.h"
  8. using content::BrowserThread;
  9. namespace android_webview {
  10. AwResourceContext::AwResourceContext() {
  11. }
  12. AwResourceContext::~AwResourceContext() {
  13. }
  14. void AwResourceContext::SetExtraHeaders(
  15. const GURL& url, const std::string& headers) {
  16. DCHECK_CURRENTLY_ON(BrowserThread::UI);
  17. if (!url.is_valid()) return;
  18. base::AutoLock scoped_lock(extra_headers_lock_);
  19. if (!headers.empty())
  20. extra_headers_[url.spec()] = headers;
  21. else
  22. extra_headers_.erase(url.spec());
  23. }
  24. std::string AwResourceContext::GetExtraHeaders(const GURL& url) {
  25. if (!url.is_valid()) return std::string();
  26. base::AutoLock scoped_lock(extra_headers_lock_);
  27. std::map<std::string, std::string>::iterator iter =
  28. extra_headers_.find(url.spec());
  29. return iter != extra_headers_.end() ? iter->second : std::string();
  30. }
  31. } // namespace android_webview