| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // This file contains an implementation of the ResourceLoaderBridge class. | 5 // This file contains an implementation of the ResourceLoaderBridge class. |
| 6 // The class is implemented using net::URLRequest, meaning it is a "simple" | 6 // The class is implemented using net::URLRequest, meaning it is a "simple" |
| 7 // version that directly issues requests. The more complicated one used in the | 7 // version that directly issues requests. The more complicated one used in the |
| 8 // browser uses IPC. | 8 // browser uses IPC. |
| 9 // | 9 // |
| 10 // Because net::URLRequest only provides an asynchronous resource loading API, | 10 // Because net::URLRequest only provides an asynchronous resource loading API, |
| (...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 | 681 |
| 682 //----------------------------------------------------------------------------- | 682 //----------------------------------------------------------------------------- |
| 683 | 683 |
| 684 class SyncRequestProxy : public RequestProxy { | 684 class SyncRequestProxy : public RequestProxy { |
| 685 public: | 685 public: |
| 686 explicit SyncRequestProxy(ResourceLoaderBridge::SyncLoadResponse* result) | 686 explicit SyncRequestProxy(ResourceLoaderBridge::SyncLoadResponse* result) |
| 687 : result_(result), event_(true, false) { | 687 : result_(result), event_(true, false) { |
| 688 } | 688 } |
| 689 | 689 |
| 690 void WaitForCompletion() { | 690 void WaitForCompletion() { |
| 691 if (!event_.Wait()) | 691 event_.Wait(); |
| 692 NOTREACHED(); | |
| 693 } | 692 } |
| 694 | 693 |
| 695 // -------------------------------------------------------------------------- | 694 // -------------------------------------------------------------------------- |
| 696 // Event hooks that run on the IO thread: | 695 // Event hooks that run on the IO thread: |
| 697 | 696 |
| 698 virtual void OnReceivedRedirect( | 697 virtual void OnReceivedRedirect( |
| 699 const GURL& new_url, | 698 const GURL& new_url, |
| 700 const ResourceResponseInfo& info, | 699 const ResourceResponseInfo& info, |
| 701 bool* defer_redirect) { | 700 bool* defer_redirect) { |
| 702 // TODO(darin): It would be much better if this could live in WebCore, but | 701 // TODO(darin): It would be much better if this could live in WebCore, but |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 872 CookieGetter() : event_(false, false) { | 871 CookieGetter() : event_(false, false) { |
| 873 } | 872 } |
| 874 | 873 |
| 875 void Get(const GURL& url) { | 874 void Get(const GURL& url) { |
| 876 g_request_context->cookie_store()->GetCookiesWithOptionsAsync( | 875 g_request_context->cookie_store()->GetCookiesWithOptionsAsync( |
| 877 url, net::CookieOptions(), | 876 url, net::CookieOptions(), |
| 878 base::Bind(&CookieGetter::OnGetCookies, this)); | 877 base::Bind(&CookieGetter::OnGetCookies, this)); |
| 879 } | 878 } |
| 880 | 879 |
| 881 std::string GetResult() { | 880 std::string GetResult() { |
| 882 if (!event_.Wait()) | 881 event_.Wait(); |
| 883 NOTREACHED(); | |
| 884 return result_; | 882 return result_; |
| 885 } | 883 } |
| 886 | 884 |
| 887 private: | 885 private: |
| 888 void OnGetCookies(const std::string& cookie_line) { | 886 void OnGetCookies(const std::string& cookie_line) { |
| 889 result_ = cookie_line; | 887 result_ = cookie_line; |
| 890 event_.Signal(); | 888 event_.Signal(); |
| 891 } | 889 } |
| 892 friend class base::RefCountedThreadSafe<CookieGetter>; | 890 friend class base::RefCountedThreadSafe<CookieGetter>; |
| 893 | 891 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 | 1030 |
| 1033 // static | 1031 // static |
| 1034 void SimpleResourceLoaderBridge::AllowFileOverHTTP( | 1032 void SimpleResourceLoaderBridge::AllowFileOverHTTP( |
| 1035 const std::string& file_path_template, const GURL& http_prefix) { | 1033 const std::string& file_path_template, const GURL& http_prefix) { |
| 1036 DCHECK(!file_path_template.empty()); | 1034 DCHECK(!file_path_template.empty()); |
| 1037 DCHECK(http_prefix.is_valid() && | 1035 DCHECK(http_prefix.is_valid() && |
| 1038 (http_prefix.SchemeIs("http") || http_prefix.SchemeIs("https"))); | 1036 (http_prefix.SchemeIs("http") || http_prefix.SchemeIs("https"))); |
| 1039 g_file_over_http_params = new FileOverHTTPParams(file_path_template, | 1037 g_file_over_http_params = new FileOverHTTPParams(file_path_template, |
| 1040 http_prefix); | 1038 http_prefix); |
| 1041 } | 1039 } |
| OLD | NEW |