Chromium Code Reviews| Index: webkit/tools/test_shell/test_shell_webblobregistry_impl.cc |
| diff --git a/webkit/tools/test_shell/test_shell_webblobregistry_impl.cc b/webkit/tools/test_shell/test_shell_webblobregistry_impl.cc |
| index 9c451cc3ff767b083a88b7d7e212461bf2e0b51b..f71fbcc7a6b637c1c214a8c58da46c26063c5952 100644 |
| --- a/webkit/tools/test_shell/test_shell_webblobregistry_impl.cc |
| +++ b/webkit/tools/test_shell/test_shell_webblobregistry_impl.cc |
| @@ -7,6 +7,7 @@ |
| #include "base/message_loop.h" |
| #include "googleurl/src/gurl.h" |
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebBlobData.h" |
| +#include "third_party/WebKit/Source/WebKit/chromium/public/WebCString.h" |
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" |
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" |
| #include "webkit/blob/blob_data.h" |
| @@ -36,6 +37,15 @@ void TestShellWebBlobRegistryImpl::Cleanup() { |
| g_blob_storage_controller = NULL; |
| } |
| +// Copy WebURL object to safely pass it to a different thread |
| +static void CopyWebURL(const WebURL& source, WebURL* target) { |
|
tony
2011/04/19 22:27:35
I would probably just return a WebURL. There's an
jianli
2011/04/19 22:53:02
I agree with Tony that returning a WebURL will mak
|
| + // Creates a copy of WebCString with refcount 1 |
|
jianli
2011/04/19 22:53:02
Please end with period.
|
| + const WebKit::WebCString spec(source.spec()); |
| + const url_parse::Parsed& parsed(source.parsed()); |
| + const bool is_valid = source.isValid(); |
| + target->assign(spec, parsed, is_valid); |
| +} |
| + |
| TestShellWebBlobRegistryImpl::TestShellWebBlobRegistryImpl() { |
| } |
| @@ -45,26 +55,34 @@ void TestShellWebBlobRegistryImpl::registerBlobURL( |
| // Note: BlobData is not refcounted thread safe. |
| scoped_refptr<webkit_blob::BlobData> blob_data( |
| new webkit_blob::BlobData(data)); |
| + WebURL url_copy; |
| + CopyWebURL(url, &url_copy); |
| g_io_thread->PostTask( |
| FROM_HERE, |
| NewRunnableMethod( |
| - this, &TestShellWebBlobRegistryImpl::DoRegisterBlobUrl, url, |
| + this, &TestShellWebBlobRegistryImpl::DoRegisterBlobUrl, url_copy, |
| blob_data)); |
| } |
| void TestShellWebBlobRegistryImpl::registerBlobURL( |
| const WebURL& url, const WebURL& src_url) { |
| DCHECK(g_io_thread); |
| + WebURL url_copy; |
| + CopyWebURL(url, &url_copy); |
| + WebURL src_url_copy; |
| + CopyWebURL(src_url, &src_url_copy); |
| g_io_thread->PostTask( |
| FROM_HERE, |
| NewRunnableMethod(this, |
| &TestShellWebBlobRegistryImpl::DoRegisterBlobUrlFrom, |
| - url, |
| - src_url)); |
| + url_copy, |
| + src_url_copy)); |
| } |
| void TestShellWebBlobRegistryImpl::unregisterBlobURL(const WebURL& url) { |
| DCHECK(g_io_thread); |
| + WebURL url_copy; |
| + CopyWebURL(url, &url_copy); |
| g_io_thread->PostTask( |
| FROM_HERE, |
| NewRunnableMethod(this, |