OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 URLRequest, meaning it is a "simple" version | 6 // The class is implemented using URLRequest, meaning it is a "simple" version |
7 // that directly issues requests. The more complicated one used in the | 7 // that directly issues requests. The more complicated one used in the |
8 // browser uses IPC. | 8 // browser uses IPC. |
9 // | 9 // |
10 // Because URLRequest only provides an asynchronous resource loading API, this | 10 // Because URLRequest only provides an asynchronous resource loading API, this |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 #include "net/base/static_cookie_policy.h" | 51 #include "net/base/static_cookie_policy.h" |
52 #include "net/base/upload_data.h" | 52 #include "net/base/upload_data.h" |
53 #include "net/http/http_cache.h" | 53 #include "net/http/http_cache.h" |
54 #include "net/http/http_request_headers.h" | 54 #include "net/http/http_request_headers.h" |
55 #include "net/http/http_response_headers.h" | 55 #include "net/http/http_response_headers.h" |
56 #include "net/proxy/proxy_service.h" | 56 #include "net/proxy/proxy_service.h" |
57 #if defined(OS_WIN) | 57 #if defined(OS_WIN) |
58 #include "net/socket/ssl_client_socket_nss_factory.h" | 58 #include "net/socket/ssl_client_socket_nss_factory.h" |
59 #endif | 59 #endif |
60 #include "net/url_request/url_request.h" | 60 #include "net/url_request/url_request.h" |
| 61 #include "net/url_request/url_request_job.h" |
61 #include "webkit/appcache/appcache_interfaces.h" | 62 #include "webkit/appcache/appcache_interfaces.h" |
62 #include "webkit/blob/blob_storage_controller.h" | 63 #include "webkit/blob/blob_storage_controller.h" |
| 64 #include "webkit/blob/blob_url_request_job.h" |
63 #include "webkit/glue/resource_loader_bridge.h" | 65 #include "webkit/glue/resource_loader_bridge.h" |
64 #include "webkit/tools/test_shell/simple_appcache_system.h" | 66 #include "webkit/tools/test_shell/simple_appcache_system.h" |
65 #include "webkit/tools/test_shell/simple_socket_stream_bridge.h" | 67 #include "webkit/tools/test_shell/simple_socket_stream_bridge.h" |
66 #include "webkit/tools/test_shell/test_shell_request_context.h" | 68 #include "webkit/tools/test_shell/test_shell_request_context.h" |
67 #include "webkit/tools/test_shell/test_shell_webblobregistry_impl.h" | 69 #include "webkit/tools/test_shell/test_shell_webblobregistry_impl.h" |
68 | 70 |
69 using webkit_glue::ResourceLoaderBridge; | 71 using webkit_glue::ResourceLoaderBridge; |
70 using net::StaticCookiePolicy; | 72 using net::StaticCookiePolicy; |
71 using net::HttpResponseHeaders; | 73 using net::HttpResponseHeaders; |
72 | 74 |
73 namespace { | 75 namespace { |
74 | 76 |
75 struct TestShellRequestContextParams { | 77 struct TestShellRequestContextParams { |
76 TestShellRequestContextParams( | 78 TestShellRequestContextParams( |
77 const FilePath& in_cache_path, | 79 const FilePath& in_cache_path, |
78 net::HttpCache::Mode in_cache_mode, | 80 net::HttpCache::Mode in_cache_mode, |
79 bool in_no_proxy) | 81 bool in_no_proxy) |
80 : cache_path(in_cache_path), | 82 : cache_path(in_cache_path), |
81 cache_mode(in_cache_mode), | 83 cache_mode(in_cache_mode), |
82 no_proxy(in_no_proxy), | 84 no_proxy(in_no_proxy), |
83 accept_all_cookies(false) {} | 85 accept_all_cookies(false) {} |
84 | 86 |
85 FilePath cache_path; | 87 FilePath cache_path; |
86 net::HttpCache::Mode cache_mode; | 88 net::HttpCache::Mode cache_mode; |
87 bool no_proxy; | 89 bool no_proxy; |
88 bool accept_all_cookies; | 90 bool accept_all_cookies; |
89 }; | 91 }; |
90 | 92 |
| 93 static URLRequestJob* BlobURLRequestJobFactory(URLRequest* request, |
| 94 const std::string& scheme) { |
| 95 webkit_blob::BlobStorageController* blob_storage_controller = |
| 96 static_cast<TestShellRequestContext*>(request->context())-> |
| 97 blob_storage_controller(); |
| 98 return new webkit_blob::BlobURLRequestJob( |
| 99 request, |
| 100 blob_storage_controller->GetBlobDataFromUrl(request->url()), |
| 101 NULL); |
| 102 } |
| 103 |
91 TestShellRequestContextParams* g_request_context_params = NULL; | 104 TestShellRequestContextParams* g_request_context_params = NULL; |
92 URLRequestContext* g_request_context = NULL; | 105 URLRequestContext* g_request_context = NULL; |
93 base::Thread* g_cache_thread = NULL; | 106 base::Thread* g_cache_thread = NULL; |
94 | 107 |
95 //----------------------------------------------------------------------------- | 108 //----------------------------------------------------------------------------- |
96 | 109 |
97 class IOThread : public base::Thread { | 110 class IOThread : public base::Thread { |
98 public: | 111 public: |
99 IOThread() : base::Thread("IOThread") { | 112 IOThread() : base::Thread("IOThread") { |
100 } | 113 } |
(...skipping 15 matching lines...) Expand all Loading... |
116 g_request_context_params = NULL; | 129 g_request_context_params = NULL; |
117 } else { | 130 } else { |
118 g_request_context = new TestShellRequestContext(); | 131 g_request_context = new TestShellRequestContext(); |
119 SetAcceptAllCookies(false); | 132 SetAcceptAllCookies(false); |
120 } | 133 } |
121 | 134 |
122 g_request_context->AddRef(); | 135 g_request_context->AddRef(); |
123 | 136 |
124 SimpleAppCacheSystem::InitializeOnIOThread(g_request_context); | 137 SimpleAppCacheSystem::InitializeOnIOThread(g_request_context); |
125 SimpleSocketStreamBridge::InitializeOnIOThread(g_request_context); | 138 SimpleSocketStreamBridge::InitializeOnIOThread(g_request_context); |
| 139 |
126 TestShellWebBlobRegistryImpl::InitializeOnIOThread( | 140 TestShellWebBlobRegistryImpl::InitializeOnIOThread( |
127 static_cast<TestShellRequestContext*>(g_request_context)-> | 141 static_cast<TestShellRequestContext*>(g_request_context)-> |
128 blob_storage_controller()); | 142 blob_storage_controller()); |
| 143 URLRequest::RegisterProtocolFactory("blob", &BlobURLRequestJobFactory); |
129 } | 144 } |
130 | 145 |
131 virtual void CleanUp() { | 146 virtual void CleanUp() { |
132 SimpleSocketStreamBridge::Cleanup(); | 147 SimpleSocketStreamBridge::Cleanup(); |
133 TestShellWebBlobRegistryImpl::Cleanup(); | 148 TestShellWebBlobRegistryImpl::Cleanup(); |
134 if (g_request_context) { | 149 if (g_request_context) { |
135 g_request_context->Release(); | 150 g_request_context->Release(); |
136 g_request_context = NULL; | 151 g_request_context = NULL; |
137 } | 152 } |
138 } | 153 } |
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 | 865 |
851 // static | 866 // static |
852 scoped_refptr<base::MessageLoopProxy> | 867 scoped_refptr<base::MessageLoopProxy> |
853 SimpleResourceLoaderBridge::GetIoThread() { | 868 SimpleResourceLoaderBridge::GetIoThread() { |
854 if (!EnsureIOThread()) { | 869 if (!EnsureIOThread()) { |
855 LOG(DFATAL) << "Failed to create IO thread."; | 870 LOG(DFATAL) << "Failed to create IO thread."; |
856 return NULL; | 871 return NULL; |
857 } | 872 } |
858 return g_io_thread->message_loop_proxy(); | 873 return g_io_thread->message_loop_proxy(); |
859 } | 874 } |
OLD | NEW |