Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Side by Side Diff: webkit/tools/test_shell/simple_resource_loader_bridge.cc

Issue 7036004: Remove more URLRequest::RegisterProtocolFactory calls. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes. Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 bool in_no_proxy) 89 bool in_no_proxy)
90 : cache_path(in_cache_path), 90 : cache_path(in_cache_path),
91 cache_mode(in_cache_mode), 91 cache_mode(in_cache_mode),
92 no_proxy(in_no_proxy) {} 92 no_proxy(in_no_proxy) {}
93 93
94 FilePath cache_path; 94 FilePath cache_path;
95 net::HttpCache::Mode cache_mode; 95 net::HttpCache::Mode cache_mode;
96 bool no_proxy; 96 bool no_proxy;
97 }; 97 };
98 98
99 net::URLRequestJob* BlobURLRequestJobFactory(net::URLRequest* request,
100 const std::string& scheme) {
101 webkit_blob::BlobStorageController* blob_storage_controller =
102 static_cast<TestShellRequestContext*>(request->context())->
103 blob_storage_controller();
104 return new webkit_blob::BlobURLRequestJob(
105 request,
106 blob_storage_controller->GetBlobDataFromUrl(request->url()),
107 SimpleResourceLoaderBridge::GetIoThread());
108 }
109
110
111 net::URLRequestJob* FileSystemURLRequestJobFactory(net::URLRequest* request,
112 const std::string& scheme) {
113 fileapi::FileSystemContext* fs_context =
114 static_cast<TestShellRequestContext*>(request->context())
115 ->file_system_context();
116 if (!fs_context) {
117 LOG(WARNING) << "No FileSystemContext found, ignoring filesystem: URL";
118 return NULL;
119 }
120
121 // If the path ends with a /, we know it's a directory. If the path refers
122 // to a directory and gets dispatched to FileSystemURLRequestJob, that class
123 // redirects back here, by adding a / to the URL.
124 const std::string path = request->url().path();
125 if (!path.empty() && path[path.size() - 1] == '/') {
126 return new fileapi::FileSystemDirURLRequestJob(
127 request,
128 fs_context,
129 SimpleResourceLoaderBridge::GetIoThread());
130 }
131 return new fileapi::FileSystemURLRequestJob(
132 request,
133 fs_context,
134 SimpleResourceLoaderBridge::GetIoThread());
135 }
136
137 TestShellRequestContextParams* g_request_context_params = NULL; 99 TestShellRequestContextParams* g_request_context_params = NULL;
138 TestShellRequestContext* g_request_context = NULL; 100 TestShellRequestContext* g_request_context = NULL;
139 base::Thread* g_cache_thread = NULL; 101 base::Thread* g_cache_thread = NULL;
140 bool g_accept_all_cookies = false; 102 bool g_accept_all_cookies = false;
141 103
142 //----------------------------------------------------------------------------- 104 //-----------------------------------------------------------------------------
143 105
144 class IOThread : public base::Thread { 106 class IOThread : public base::Thread {
145 public: 107 public:
146 IOThread() : base::Thread("IOThread") { 108 IOThread() : base::Thread("IOThread") {
(...skipping 17 matching lines...) Expand all
164 g_request_context = new TestShellRequestContext(); 126 g_request_context = new TestShellRequestContext();
165 } 127 }
166 128
167 g_request_context->AddRef(); 129 g_request_context->AddRef();
168 130
169 SimpleAppCacheSystem::InitializeOnIOThread(g_request_context); 131 SimpleAppCacheSystem::InitializeOnIOThread(g_request_context);
170 SimpleSocketStreamBridge::InitializeOnIOThread(g_request_context); 132 SimpleSocketStreamBridge::InitializeOnIOThread(g_request_context);
171 SimpleFileWriter::InitializeOnIOThread(g_request_context); 133 SimpleFileWriter::InitializeOnIOThread(g_request_context);
172 TestShellWebBlobRegistryImpl::InitializeOnIOThread( 134 TestShellWebBlobRegistryImpl::InitializeOnIOThread(
173 g_request_context->blob_storage_controller()); 135 g_request_context->blob_storage_controller());
174
175 net::URLRequest::RegisterProtocolFactory("blob", &BlobURLRequestJobFactory);
176 net::URLRequest::RegisterProtocolFactory("filesystem",
177 &FileSystemURLRequestJobFactory);
178 } 136 }
179 137
180 virtual void CleanUp() { 138 virtual void CleanUp() {
181 // In reverse order of initialization. 139 // In reverse order of initialization.
182 TestShellWebBlobRegistryImpl::Cleanup(); 140 TestShellWebBlobRegistryImpl::Cleanup();
183 SimpleFileWriter::CleanupOnIOThread(); 141 SimpleFileWriter::CleanupOnIOThread();
184 SimpleSocketStreamBridge::Cleanup(); 142 SimpleSocketStreamBridge::Cleanup();
185 SimpleAppCacheSystem::CleanupOnIOThread(); 143 SimpleAppCacheSystem::CleanupOnIOThread();
186 144
187 if (g_request_context) { 145 if (g_request_context) {
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 913
956 // static 914 // static
957 scoped_refptr<base::MessageLoopProxy> 915 scoped_refptr<base::MessageLoopProxy>
958 SimpleResourceLoaderBridge::GetIoThread() { 916 SimpleResourceLoaderBridge::GetIoThread() {
959 if (!EnsureIOThread()) { 917 if (!EnsureIOThread()) {
960 LOG(DFATAL) << "Failed to create IO thread."; 918 LOG(DFATAL) << "Failed to create IO thread.";
961 return NULL; 919 return NULL;
962 } 920 }
963 return g_io_thread->message_loop_proxy(); 921 return g_io_thread->message_loop_proxy();
964 } 922 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698