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

Unified Diff: webkit/tools/test_shell/test_shell_webblobregistry_impl.cc

Issue 6878059: test_shell_webblobregistry_impl.cc posts CString to other threads without (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Naming Created 9 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698