| 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 #include "webkit/tools/test_shell/test_shell_webblobregistry_impl.h" | 5 #include "webkit/tools/test_shell/test_shell_webblobregistry_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "googleurl/src/gurl.h" | 9 #include "googleurl/src/gurl.h" |
| 10 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebBlobData.
h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebBlobData.
h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 g_io_thread = MessageLoop::current(); | 29 g_io_thread = MessageLoop::current(); |
| 30 g_blob_storage_controller = blob_storage_controller; | 30 g_blob_storage_controller = blob_storage_controller; |
| 31 } | 31 } |
| 32 | 32 |
| 33 /* static */ | 33 /* static */ |
| 34 void TestShellWebBlobRegistryImpl::Cleanup() { | 34 void TestShellWebBlobRegistryImpl::Cleanup() { |
| 35 g_io_thread = NULL; | 35 g_io_thread = NULL; |
| 36 g_blob_storage_controller = NULL; | 36 g_blob_storage_controller = NULL; |
| 37 } | 37 } |
| 38 | 38 |
| 39 TestShellWebBlobRegistryImpl::TestShellWebBlobRegistryImpl() { | |
| 40 } | |
| 41 | |
| 42 void TestShellWebBlobRegistryImpl::registerBlobURL( | 39 void TestShellWebBlobRegistryImpl::registerBlobURL( |
| 43 const WebURL& url, WebBlobData& data) { | 40 const WebURL& url, WebBlobData& data) { |
| 44 DCHECK(g_io_thread); | 41 DCHECK(g_io_thread); |
| 45 GURL thread_safe_url = url; // WebURL uses refcounted strings. | 42 GURL thread_safe_url = url; // WebURL uses refcounted strings. |
| 46 g_io_thread->PostTask(FROM_HERE, base::Bind( | 43 g_io_thread->PostTask(FROM_HERE, base::Bind( |
| 47 &TestShellWebBlobRegistryImpl::AddFinishedBlob, this, | 44 &TestShellWebBlobRegistryImpl::AddFinishedBlob, this, |
| 48 thread_safe_url, make_scoped_refptr(new BlobData(data)))); | 45 thread_safe_url, make_scoped_refptr(new BlobData(data)))); |
| 49 } | 46 } |
| 50 | 47 |
| 51 void TestShellWebBlobRegistryImpl::registerBlobURL( | 48 void TestShellWebBlobRegistryImpl::registerBlobURL( |
| 52 const WebURL& url, const WebURL& src_url) { | 49 const WebURL& url, const WebURL& src_url) { |
| 53 DCHECK(g_io_thread); | 50 DCHECK(g_io_thread); |
| 54 GURL thread_safe_url = url; | 51 GURL thread_safe_url = url; |
| 55 GURL thread_safe_src_url = src_url; | 52 GURL thread_safe_src_url = src_url; |
| 56 g_io_thread->PostTask(FROM_HERE, base::Bind( | 53 g_io_thread->PostTask(FROM_HERE, base::Bind( |
| 57 &TestShellWebBlobRegistryImpl::CloneBlob, this, | 54 &TestShellWebBlobRegistryImpl::CloneBlob, this, |
| 58 thread_safe_url, thread_safe_src_url)); | 55 thread_safe_url, thread_safe_src_url)); |
| 59 } | 56 } |
| 60 | 57 |
| 61 void TestShellWebBlobRegistryImpl::unregisterBlobURL(const WebURL& url) { | 58 void TestShellWebBlobRegistryImpl::unregisterBlobURL(const WebURL& url) { |
| 62 DCHECK(g_io_thread); | 59 DCHECK(g_io_thread); |
| 63 GURL thread_safe_url = url; | 60 GURL thread_safe_url = url; |
| 64 g_io_thread->PostTask(FROM_HERE, base::Bind( | 61 g_io_thread->PostTask(FROM_HERE, base::Bind( |
| 65 &TestShellWebBlobRegistryImpl::RemoveBlob, this, | 62 &TestShellWebBlobRegistryImpl::RemoveBlob, this, |
| 66 thread_safe_url)); | 63 thread_safe_url)); |
| 67 } | 64 } |
| 68 | 65 |
| 66 TestShellWebBlobRegistryImpl::TestShellWebBlobRegistryImpl() {} |
| 67 |
| 69 void TestShellWebBlobRegistryImpl::AddFinishedBlob( | 68 void TestShellWebBlobRegistryImpl::AddFinishedBlob( |
| 70 const GURL& url, BlobData* blob_data) { | 69 const GURL& url, BlobData* blob_data) { |
| 71 DCHECK(g_blob_storage_controller); | 70 DCHECK(g_blob_storage_controller); |
| 72 g_blob_storage_controller->AddFinishedBlob(url, blob_data); | 71 g_blob_storage_controller->AddFinishedBlob(url, blob_data); |
| 73 } | 72 } |
| 74 | 73 |
| 75 void TestShellWebBlobRegistryImpl::CloneBlob( | 74 void TestShellWebBlobRegistryImpl::CloneBlob( |
| 76 const GURL& url, const GURL& src_url) { | 75 const GURL& url, const GURL& src_url) { |
| 77 DCHECK(g_blob_storage_controller); | 76 DCHECK(g_blob_storage_controller); |
| 78 g_blob_storage_controller->CloneBlob(url, src_url); | 77 g_blob_storage_controller->CloneBlob(url, src_url); |
| 79 } | 78 } |
| 80 | 79 |
| 81 void TestShellWebBlobRegistryImpl::RemoveBlob(const GURL& url) { | 80 void TestShellWebBlobRegistryImpl::RemoveBlob(const GURL& url) { |
| 82 DCHECK(g_blob_storage_controller); | 81 DCHECK(g_blob_storage_controller); |
| 83 g_blob_storage_controller->RemoveBlob(url); | 82 g_blob_storage_controller->RemoveBlob(url); |
| 84 } | 83 } |
| OLD | NEW |