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 91 matching lines...) Loading... |
102 webkit_blob::BlobStorageController* blob_storage_controller = | 102 webkit_blob::BlobStorageController* blob_storage_controller = |
103 static_cast<TestShellRequestContext*>(request->context())-> | 103 static_cast<TestShellRequestContext*>(request->context())-> |
104 blob_storage_controller(); | 104 blob_storage_controller(); |
105 return new webkit_blob::BlobURLRequestJob( | 105 return new webkit_blob::BlobURLRequestJob( |
106 request, | 106 request, |
107 blob_storage_controller->GetBlobDataFromUrl(request->url()), | 107 blob_storage_controller->GetBlobDataFromUrl(request->url()), |
108 NULL); | 108 NULL); |
109 } | 109 } |
110 | 110 |
111 TestShellRequestContextParams* g_request_context_params = NULL; | 111 TestShellRequestContextParams* g_request_context_params = NULL; |
112 URLRequestContext* g_request_context = NULL; | 112 TestShellRequestContext* g_request_context = NULL; |
113 base::Thread* g_cache_thread = NULL; | 113 base::Thread* g_cache_thread = NULL; |
114 | 114 |
115 //----------------------------------------------------------------------------- | 115 //----------------------------------------------------------------------------- |
116 | 116 |
117 class IOThread : public base::Thread { | 117 class IOThread : public base::Thread { |
118 public: | 118 public: |
119 IOThread() : base::Thread("IOThread") { | 119 IOThread() : base::Thread("IOThread") { |
120 } | 120 } |
121 | 121 |
122 ~IOThread() { | 122 ~IOThread() { |
(...skipping 14 matching lines...) Loading... |
137 } else { | 137 } else { |
138 g_request_context = new TestShellRequestContext(); | 138 g_request_context = new TestShellRequestContext(); |
139 SetAcceptAllCookies(false); | 139 SetAcceptAllCookies(false); |
140 } | 140 } |
141 | 141 |
142 g_request_context->AddRef(); | 142 g_request_context->AddRef(); |
143 | 143 |
144 SimpleAppCacheSystem::InitializeOnIOThread(g_request_context); | 144 SimpleAppCacheSystem::InitializeOnIOThread(g_request_context); |
145 SimpleSocketStreamBridge::InitializeOnIOThread(g_request_context); | 145 SimpleSocketStreamBridge::InitializeOnIOThread(g_request_context); |
146 SimpleFileWriter::InitializeOnIOThread(g_request_context); | 146 SimpleFileWriter::InitializeOnIOThread(g_request_context); |
| 147 TestShellWebBlobRegistryImpl::InitializeOnIOThread( |
| 148 g_request_context->blob_storage_controller()); |
147 | 149 |
148 TestShellWebBlobRegistryImpl::InitializeOnIOThread( | |
149 static_cast<TestShellRequestContext*>(g_request_context)-> | |
150 blob_storage_controller()); | |
151 URLRequest::RegisterProtocolFactory("blob", &BlobURLRequestJobFactory); | 150 URLRequest::RegisterProtocolFactory("blob", &BlobURLRequestJobFactory); |
152 } | 151 } |
153 | 152 |
154 virtual void CleanUp() { | 153 virtual void CleanUp() { |
155 SimpleSocketStreamBridge::Cleanup(); | 154 // In reverse order of initialization. |
156 TestShellWebBlobRegistryImpl::Cleanup(); | 155 TestShellWebBlobRegistryImpl::Cleanup(); |
157 SimpleFileWriter::CleanupOnIOThread(); | 156 SimpleFileWriter::CleanupOnIOThread(); |
| 157 SimpleSocketStreamBridge::Cleanup(); |
| 158 SimpleAppCacheSystem::CleanupOnIOThread(); |
| 159 |
158 if (g_request_context) { | 160 if (g_request_context) { |
159 g_request_context->Release(); | 161 g_request_context->Release(); |
160 g_request_context = NULL; | 162 g_request_context = NULL; |
161 } | 163 } |
162 } | 164 } |
163 | 165 |
164 void SetAcceptAllCookies(bool accept_all_cookies) { | 166 void SetAcceptAllCookies(bool accept_all_cookies) { |
165 StaticCookiePolicy::Type policy_type = accept_all_cookies ? | 167 StaticCookiePolicy::Type policy_type = accept_all_cookies ? |
166 StaticCookiePolicy::ALLOW_ALL_COOKIES : | 168 StaticCookiePolicy::ALLOW_ALL_COOKIES : |
167 StaticCookiePolicy::BLOCK_THIRD_PARTY_COOKIES; | 169 StaticCookiePolicy::BLOCK_THIRD_PARTY_COOKIES; |
(...skipping 758 matching lines...) Loading... |
926 | 928 |
927 // static | 929 // static |
928 scoped_refptr<base::MessageLoopProxy> | 930 scoped_refptr<base::MessageLoopProxy> |
929 SimpleResourceLoaderBridge::GetIoThread() { | 931 SimpleResourceLoaderBridge::GetIoThread() { |
930 if (!EnsureIOThread()) { | 932 if (!EnsureIOThread()) { |
931 LOG(DFATAL) << "Failed to create IO thread."; | 933 LOG(DFATAL) << "Failed to create IO thread."; |
932 return NULL; | 934 return NULL; |
933 } | 935 } |
934 return g_io_thread->message_loop_proxy(); | 936 return g_io_thread->message_loop_proxy(); |
935 } | 937 } |
OLD | NEW |