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

Side by Side Diff: webkit/tools/test_shell/test_shell_webblobregistry_impl.cc

Issue 3582002: Add deletable file refs to Blobs (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/blob/blob_storage_controller.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 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/message_loop.h" 7 #include "base/message_loop.h"
8 #include "googleurl/src/gurl.h" 8 #include "googleurl/src/gurl.h"
9 #include "third_party/WebKit/WebKit/chromium/public/WebBlobData.h" 9 #include "third_party/WebKit/WebKit/chromium/public/WebBlobData.h"
10 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" 10 #include "third_party/WebKit/WebKit/chromium/public/WebString.h"
11 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" 11 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h"
12 #include "webkit/blob/blob_data.h" 12 #include "webkit/blob/blob_data.h"
13 #include "webkit/blob/blob_storage_controller.h" 13 #include "webkit/blob/blob_storage_controller.h"
14 14
15 using WebKit::WebBlobData; 15 using WebKit::WebBlobData;
16 using WebKit::WebBlobStorageData; 16 using WebKit::WebBlobStorageData;
17 using WebKit::WebString; 17 using WebKit::WebString;
18 using WebKit::WebURL; 18 using WebKit::WebURL;
19 19
20 namespace {
21
20 MessageLoop* g_io_thread; 22 MessageLoop* g_io_thread;
21 webkit_blob::BlobStorageController* g_blob_storage_controller; 23 webkit_blob::BlobStorageController* g_blob_storage_controller;
22 24
25 } // namespace
26
23 /* static */ 27 /* static */
24 void TestShellWebBlobRegistryImpl::InitializeOnIOThread( 28 void TestShellWebBlobRegistryImpl::InitializeOnIOThread(
25 webkit_blob::BlobStorageController* blob_storage_controller) { 29 webkit_blob::BlobStorageController* blob_storage_controller) {
26 g_io_thread = MessageLoop::current(); 30 g_io_thread = MessageLoop::current();
27 g_blob_storage_controller = blob_storage_controller; 31 g_blob_storage_controller = blob_storage_controller;
28 } 32 }
29 33
30 /* static */ 34 /* static */
31 void TestShellWebBlobRegistryImpl::Cleanup() { 35 void TestShellWebBlobRegistryImpl::Cleanup() {
32 g_io_thread = NULL; 36 g_io_thread = NULL;
33 g_blob_storage_controller = NULL; 37 g_blob_storage_controller = NULL;
34 } 38 }
35 39
36 TestShellWebBlobRegistryImpl::TestShellWebBlobRegistryImpl() { 40 TestShellWebBlobRegistryImpl::TestShellWebBlobRegistryImpl() {
37 } 41 }
38 42
39 void TestShellWebBlobRegistryImpl::registerBlobURL( 43 void TestShellWebBlobRegistryImpl::registerBlobURL(
40 const WebURL& url, WebBlobData& data) { 44 const WebURL& url, WebBlobData& data) {
41 DCHECK(g_io_thread); 45 DCHECK(g_io_thread);
46 // Note: BlobData is not refcounted thread safe.
42 scoped_refptr<webkit_blob::BlobData> blob_data( 47 scoped_refptr<webkit_blob::BlobData> blob_data(
43 new webkit_blob::BlobData(data)); 48 new webkit_blob::BlobData(data));
44 blob_data->AddRef(); // Release on DoRegisterBlobURL.
45 g_io_thread->PostTask( 49 g_io_thread->PostTask(
46 FROM_HERE, 50 FROM_HERE,
47 NewRunnableMethod(this, 51 NewRunnableMethod(
48 &TestShellWebBlobRegistryImpl::DoRegisterBlobUrl, 52 this, &TestShellWebBlobRegistryImpl::DoRegisterBlobUrl, url,
49 url, 53 blob_data.release())); // Released in DoRegisterBlobUrl.
50 blob_data.get()));
51 } 54 }
52 55
53 void TestShellWebBlobRegistryImpl::registerBlobURL( 56 void TestShellWebBlobRegistryImpl::registerBlobURL(
54 const WebURL& url, const WebURL& src_url) { 57 const WebURL& url, const WebURL& src_url) {
55 DCHECK(g_io_thread); 58 DCHECK(g_io_thread);
56 g_io_thread->PostTask( 59 g_io_thread->PostTask(
57 FROM_HERE, 60 FROM_HERE,
58 NewRunnableMethod(this, 61 NewRunnableMethod(this,
59 &TestShellWebBlobRegistryImpl::DoRegisterBlobUrlFrom, 62 &TestShellWebBlobRegistryImpl::DoRegisterBlobUrlFrom,
60 url, 63 url,
(...skipping 19 matching lines...) Expand all
80 void TestShellWebBlobRegistryImpl::DoRegisterBlobUrlFrom( 83 void TestShellWebBlobRegistryImpl::DoRegisterBlobUrlFrom(
81 const GURL& url, const GURL& src_url) { 84 const GURL& url, const GURL& src_url) {
82 DCHECK(g_blob_storage_controller); 85 DCHECK(g_blob_storage_controller);
83 g_blob_storage_controller->RegisterBlobUrlFrom(url, src_url); 86 g_blob_storage_controller->RegisterBlobUrlFrom(url, src_url);
84 } 87 }
85 88
86 void TestShellWebBlobRegistryImpl::DoUnregisterBlobUrl(const GURL& url) { 89 void TestShellWebBlobRegistryImpl::DoUnregisterBlobUrl(const GURL& url) {
87 DCHECK(g_blob_storage_controller); 90 DCHECK(g_blob_storage_controller);
88 g_blob_storage_controller->UnregisterBlobUrl(url); 91 g_blob_storage_controller->UnregisterBlobUrl(url);
89 } 92 }
OLDNEW
« no previous file with comments | « webkit/blob/blob_storage_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698