OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 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 |
| 5 #include "webkit/tools/test_shell/test_shell_webblobregistry_impl.h" |
| 6 |
| 7 #include "base/message_loop.h" |
| 8 #include "googleurl/src/gurl.h" |
| 9 #include "third_party/WebKit/WebKit/chromium/public/WebBlobData.h" |
| 10 #include "third_party/WebKit/WebKit/chromium/public/WebBlobStorageData.h" |
| 11 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" |
| 12 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" |
| 13 #include "webkit/blob/blob_data.h" |
| 14 #include "webkit/blob/blob_storage_controller.h" |
| 15 |
| 16 using WebKit::WebBlobData; |
| 17 using WebKit::WebBlobStorageData; |
| 18 using WebKit::WebString; |
| 19 using WebKit::WebURL; |
| 20 |
| 21 MessageLoop* g_io_thread; |
| 22 webkit_blob::BlobStorageController* g_blob_storage_controller; |
| 23 |
| 24 /* static */ |
| 25 void TestShellWebBlobRegistryImpl::InitializeOnIOThread( |
| 26 webkit_blob::BlobStorageController* blob_storage_controller) { |
| 27 g_io_thread = MessageLoop::current(); |
| 28 g_blob_storage_controller = blob_storage_controller; |
| 29 } |
| 30 |
| 31 /* static */ |
| 32 void TestShellWebBlobRegistryImpl::Cleanup() { |
| 33 g_io_thread = NULL; |
| 34 g_blob_storage_controller = NULL; |
| 35 } |
| 36 |
| 37 TestShellWebBlobRegistryImpl::TestShellWebBlobRegistryImpl() { |
| 38 } |
| 39 |
| 40 void TestShellWebBlobRegistryImpl::registerBlobURL( |
| 41 const WebURL& url, WebBlobData& data) { |
| 42 DCHECK(g_io_thread); |
| 43 scoped_refptr<webkit_blob::BlobData> blob_data( |
| 44 new webkit_blob::BlobData(data)); |
| 45 blob_data->AddRef(); // Release on DoRegisterBlobURL. |
| 46 g_io_thread->PostTask( |
| 47 FROM_HERE, |
| 48 NewRunnableMethod(this, |
| 49 &TestShellWebBlobRegistryImpl::DoRegisterBlobUrl, |
| 50 url, |
| 51 blob_data.get())); |
| 52 } |
| 53 |
| 54 void TestShellWebBlobRegistryImpl::registerBlobURL( |
| 55 const WebURL& url, const WebURL& src_url) { |
| 56 DCHECK(g_io_thread); |
| 57 g_io_thread->PostTask( |
| 58 FROM_HERE, |
| 59 NewRunnableMethod(this, |
| 60 &TestShellWebBlobRegistryImpl::DoRegisterBlobUrlFrom, |
| 61 url, |
| 62 src_url)); |
| 63 } |
| 64 |
| 65 void TestShellWebBlobRegistryImpl::unregisterBlobURL(const WebURL& url) { |
| 66 DCHECK(g_io_thread); |
| 67 g_io_thread->PostTask( |
| 68 FROM_HERE, |
| 69 NewRunnableMethod(this, |
| 70 &TestShellWebBlobRegistryImpl::DoUnregisterBlobUrl, |
| 71 url)); |
| 72 } |
| 73 |
| 74 void TestShellWebBlobRegistryImpl::DoRegisterBlobUrl( |
| 75 const GURL& url, webkit_blob::BlobData* blob_data) { |
| 76 DCHECK(g_blob_storage_controller); |
| 77 g_blob_storage_controller->RegisterBlobUrl(url, blob_data); |
| 78 blob_data->Release(); |
| 79 } |
| 80 |
| 81 void TestShellWebBlobRegistryImpl::DoRegisterBlobUrlFrom( |
| 82 const GURL& url, const GURL& src_url) { |
| 83 DCHECK(g_blob_storage_controller); |
| 84 g_blob_storage_controller->RegisterBlobUrlFrom(url, src_url); |
| 85 } |
| 86 |
| 87 void TestShellWebBlobRegistryImpl::DoUnregisterBlobUrl(const GURL& url) { |
| 88 DCHECK(g_blob_storage_controller); |
| 89 g_blob_storage_controller->UnregisterBlobUrl(url); |
| 90 } |
OLD | NEW |