diff options
author | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-17 23:00:51 +0000 |
---|---|---|
committer | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-17 23:00:51 +0000 |
commit | a3c71e8edf494687af2e67bc8fe8b013577bcbb6 (patch) | |
tree | ee46aaaf7a90f4b57065f6af59c2b6a647d92c00 /webkit/tools/test_shell/test_shell_webblobregistry_impl.cc | |
parent | 378429dc295cf26b11d20f9e52bc568e4dbf3b4e (diff) | |
download | chromium_src-a3c71e8edf494687af2e67bc8fe8b013577bcbb6.zip chromium_src-a3c71e8edf494687af2e67bc8fe8b013577bcbb6.tar.gz chromium_src-a3c71e8edf494687af2e67bc8fe8b013577bcbb6.tar.bz2 |
A few improvements to Blob handling.
* Break large blobs into multiple ipcs during creation.
* Use shared memory blocks for the xfer.
* Rename some methods and IPCs for readability.
* Cap memory usage in the browser process at 1G.
BUG=97221
Review URL: http://codereview.chromium.org/7974011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105950 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools/test_shell/test_shell_webblobregistry_impl.cc')
-rw-r--r-- | webkit/tools/test_shell/test_shell_webblobregistry_impl.cc | 76 |
1 files changed, 21 insertions, 55 deletions
diff --git a/webkit/tools/test_shell/test_shell_webblobregistry_impl.cc b/webkit/tools/test_shell/test_shell_webblobregistry_impl.cc index 6ecdc4f..c376055 100644 --- a/webkit/tools/test_shell/test_shell_webblobregistry_impl.cc +++ b/webkit/tools/test_shell/test_shell_webblobregistry_impl.cc @@ -6,35 +6,21 @@ #include "base/bind.h" #include "base/message_loop.h" -#include "base/task.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" #include "webkit/blob/blob_storage_controller.h" using WebKit::WebBlobData; -using WebKit::WebString; using WebKit::WebURL; +using webkit_blob::BlobData; namespace { MessageLoop* g_io_thread; webkit_blob::BlobStorageController* g_blob_storage_controller; -// WebURL contains a WebCString object that is ref-counted, -// but not thread-safe ref-counted. -// "Normal" copying of WebURL results in a copy that is not thread-safe. -// This method creates a deep copy of WebURL. -WebURL GetWebURLThreadsafeCopy(const WebURL& source) { - const WebKit::WebCString spec(source.spec().data(), source.spec().length()); - const url_parse::Parsed& parsed(source.parsed()); - const bool is_valid = source.isValid(); - return WebURL(spec, parsed, is_valid); -} - } // namespace /* static */ @@ -56,63 +42,43 @@ TestShellWebBlobRegistryImpl::TestShellWebBlobRegistryImpl() { void TestShellWebBlobRegistryImpl::registerBlobURL( const WebURL& url, WebBlobData& data) { DCHECK(g_io_thread); - base::Closure task; - { - scoped_refptr<webkit_blob::BlobData> blob_data( - new webkit_blob::BlobData(data)); - WebURL url_copy = GetWebURLThreadsafeCopy(url); - task = base::Bind(&TestShellWebBlobRegistryImpl::DoRegisterBlobUrl, this, - url_copy, blob_data); - // After this block exits, url_copy is disposed, and - // the underlying WebCString will have a refcount=1 and will - // only be accessible from the task object. - } - g_io_thread->PostTask(FROM_HERE, task); + GURL thread_safe_url = url; // WebURL uses refcounted strings. + g_io_thread->PostTask(FROM_HERE, base::Bind( + &TestShellWebBlobRegistryImpl::AddFinishedBlob, this, + thread_safe_url, make_scoped_refptr(new BlobData(data)))); } void TestShellWebBlobRegistryImpl::registerBlobURL( const WebURL& url, const WebURL& src_url) { DCHECK(g_io_thread); - base::Closure task; - { - WebURL url_copy = GetWebURLThreadsafeCopy(url); - WebURL src_url_copy = GetWebURLThreadsafeCopy(src_url); - task = base::Bind(&TestShellWebBlobRegistryImpl::DoRegisterBlobUrlFrom, - this, url_copy, src_url_copy); - // After this block exits, url_copy and src_url_copy are disposed, and - // the underlying WebCStrings will have a refcount=1 and will - // only be accessible from the task object. - } - g_io_thread->PostTask(FROM_HERE, task); + GURL thread_safe_url = url; + GURL thread_safe_src_url = src_url; + g_io_thread->PostTask(FROM_HERE, base::Bind( + &TestShellWebBlobRegistryImpl::CloneBlob, this, + thread_safe_url, thread_safe_src_url)); } void TestShellWebBlobRegistryImpl::unregisterBlobURL(const WebURL& url) { DCHECK(g_io_thread); - base::Closure task; - { - WebURL url_copy = GetWebURLThreadsafeCopy(url); - task = base::Bind(&TestShellWebBlobRegistryImpl::DoUnregisterBlobUrl, this, - url_copy); - // After this block exits, url_copy is disposed, and - // the underlying WebCString will have a refcount=1 and will - // only be accessible from the task object. - } - g_io_thread->PostTask(FROM_HERE, task); + GURL thread_safe_url = url; + g_io_thread->PostTask(FROM_HERE, base::Bind( + &TestShellWebBlobRegistryImpl::RemoveBlob, this, + thread_safe_url)); } -void TestShellWebBlobRegistryImpl::DoRegisterBlobUrl( - const GURL& url, webkit_blob::BlobData* blob_data) { +void TestShellWebBlobRegistryImpl::AddFinishedBlob( + const GURL& url, BlobData* blob_data) { DCHECK(g_blob_storage_controller); - g_blob_storage_controller->RegisterBlobUrl(url, blob_data); + g_blob_storage_controller->AddFinishedBlob(url, blob_data); } -void TestShellWebBlobRegistryImpl::DoRegisterBlobUrlFrom( +void TestShellWebBlobRegistryImpl::CloneBlob( const GURL& url, const GURL& src_url) { DCHECK(g_blob_storage_controller); - g_blob_storage_controller->RegisterBlobUrlFrom(url, src_url); + g_blob_storage_controller->CloneBlob(url, src_url); } -void TestShellWebBlobRegistryImpl::DoUnregisterBlobUrl(const GURL& url) { +void TestShellWebBlobRegistryImpl::RemoveBlob(const GURL& url) { DCHECK(g_blob_storage_controller); - g_blob_storage_controller->UnregisterBlobUrl(url); + g_blob_storage_controller->RemoveBlob(url); } |