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

Side by Side Diff: chrome/browser/in_process_webkit/webkit_context.cc

Issue 545054: Introduce all the plumbing for Session Storage. This mostly consists of crea... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 11 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include "chrome/browser/in_process_webkit/webkit_context.h" 5 #include "chrome/browser/in_process_webkit/webkit_context.h"
6 6
7 #include "chrome/browser/chrome_thread.h" 7 #include "chrome/browser/chrome_thread.h"
8 8
9 WebKitContext::WebKitContext(const FilePath& data_path, bool is_incognito) 9 WebKitContext::WebKitContext(const FilePath& data_path, bool is_incognito)
10 : data_path_(data_path), 10 : data_path_(data_path),
11 is_incognito_(is_incognito), 11 is_incognito_(is_incognito),
12 ALLOW_THIS_IN_INITIALIZER_LIST( 12 ALLOW_THIS_IN_INITIALIZER_LIST(
13 dom_storage_context_(new DOMStorageContext(this))) { 13 dom_storage_context_(new DOMStorageContext(this))) {
14 } 14 }
15 15
16 WebKitContext::~WebKitContext() { 16 WebKitContext::~WebKitContext() {
17 // If the WebKit thread was ever spun up, delete the object there. The task 17 ChromeThread::DeleteSoon(ChromeThread::WEBKIT, FROM_HERE,
18 // will just get deleted if the WebKit thread isn't created. 18 dom_storage_context_.release());
19 DOMStorageContext* dom_storage_context = dom_storage_context_.release();
20 if (!ChromeThread::DeleteSoon(
21 ChromeThread::WEBKIT, FROM_HERE, dom_storage_context)) {
22 // The WebKit thread wasn't created, and the task got deleted without
23 // freeing the DOMStorageContext, so delete it manually.
24 delete dom_storage_context;
25 }
26 } 19 }
27 20
28 void WebKitContext::PurgeMemory() { 21 void WebKitContext::PurgeMemory() {
29 // DOMStorageContext::PurgeMemory() should only be called on the WebKit 22 if (!ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)) {
30 // thread.
31 //
32 // Note that if there is no WebKit thread, then there's nothing in
33 // LocalStorage and it's OK to no-op here.
34 if (ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)) {
35 dom_storage_context_->PurgeMemory();
36 } else {
37 // Since we're not on the WebKit thread, proxy the call over to it. We
38 // can't post a task to call DOMStorageContext::PurgeMemory() directly
39 // because that class is not refcounted.
40 ChromeThread::PostTask( 23 ChromeThread::PostTask(
41 ChromeThread::WEBKIT, FROM_HERE, 24 ChromeThread::WEBKIT, FROM_HERE,
42 NewRunnableMethod(this, &WebKitContext::PurgeMemory)); 25 NewRunnableMethod(this, &WebKitContext::PurgeMemory));
26 return;
43 } 27 }
28
29 dom_storage_context_->PurgeMemory();
44 } 30 }
45 31
46 void WebKitContext::DeleteDataModifiedSince(const base::Time& cutoff) { 32 void WebKitContext::DeleteDataModifiedSince(const base::Time& cutoff) {
47 // DOMStorageContext::DeleteDataModifiedSince() should only be called on the 33 if (!ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)) {
48 // WebKit thread. 34 ChromeThread::PostTask(
49 if (ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)) {
50 dom_storage_context_->DeleteDataModifiedSince(cutoff);
51 } else {
52 bool result = ChromeThread::PostTask(
53 ChromeThread::WEBKIT, FROM_HERE, 35 ChromeThread::WEBKIT, FROM_HERE,
54 NewRunnableMethod(this, &WebKitContext::DeleteDataModifiedSince, 36 NewRunnableMethod(this, &WebKitContext::DeleteDataModifiedSince,
55 cutoff)); 37 cutoff));
56 DCHECK(result); 38 return;
57 } 39 }
40
41 dom_storage_context_->DeleteDataModifiedSince(cutoff);
58 } 42 }
43
44 void WebKitContext::DeleteSessionStorageNamespace(
45 int64 session_storage_namespace_id) {
46 if (!ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)) {
47 ChromeThread::PostTask(
48 ChromeThread::WEBKIT, FROM_HERE,
49 NewRunnableMethod(this, &WebKitContext::DeleteSessionStorageNamespace,
50 session_storage_namespace_id));
51 return;
52 }
53
54 dom_storage_context_->DeleteSessionStorageNamespace(
55 session_storage_namespace_id);
56 }
OLDNEW
« no previous file with comments | « chrome/browser/in_process_webkit/webkit_context.h ('k') | chrome/browser/renderer_host/render_view_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698