OLD | NEW |
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 "chrome/browser/in_process_webkit/webkit_context.h" | 5 #include "chrome/browser/in_process_webkit/webkit_context.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "chrome/browser/browser_thread.h" | 8 #include "chrome/browser/browser_thread.h" |
9 #include "chrome/browser/profile.h" | 9 #include "chrome/browser/profile.h" |
10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
11 | 11 |
12 WebKitContext::WebKitContext(Profile* profile) | 12 WebKitContext::WebKitContext(Profile* profile, bool clear_local_state_on_exit) |
13 : data_path_(profile->IsOffTheRecord() ? FilePath() : profile->GetPath()), | 13 : data_path_(profile->IsOffTheRecord() ? FilePath() : profile->GetPath()), |
14 is_incognito_(profile->IsOffTheRecord()), | 14 is_incognito_(profile->IsOffTheRecord()), |
| 15 clear_local_state_on_exit_(clear_local_state_on_exit), |
15 ALLOW_THIS_IN_INITIALIZER_LIST( | 16 ALLOW_THIS_IN_INITIALIZER_LIST( |
16 dom_storage_context_(new DOMStorageContext(this))), | 17 dom_storage_context_(new DOMStorageContext(this))), |
17 ALLOW_THIS_IN_INITIALIZER_LIST( | 18 ALLOW_THIS_IN_INITIALIZER_LIST( |
18 indexed_db_context_(new IndexedDBContext(this))) { | 19 indexed_db_context_(new IndexedDBContext(this))) { |
19 } | 20 } |
20 | 21 |
21 WebKitContext::~WebKitContext() { | 22 WebKitContext::~WebKitContext() { |
22 // If the WebKit thread was ever spun up, delete the object there. The task | 23 // If the WebKit thread was ever spun up, delete the object there. The task |
23 // will just get deleted if the WebKit thread isn't created (which only | 24 // will just get deleted if the WebKit thread isn't created (which only |
24 // happens during testing). | 25 // happens during testing). |
25 DOMStorageContext* dom_storage_context = dom_storage_context_.release(); | 26 DOMStorageContext* dom_storage_context = dom_storage_context_.release(); |
26 if (!BrowserThread::DeleteSoon( | 27 if (!BrowserThread::DeleteSoon( |
27 BrowserThread::WEBKIT, FROM_HERE, dom_storage_context)) { | 28 BrowserThread::WEBKIT, FROM_HERE, dom_storage_context)) { |
28 // The WebKit thread wasn't created, and the task got deleted without | 29 // The WebKit thread wasn't created, and the task got deleted without |
29 // freeing the DOMStorageContext, so delete it manually. | 30 // freeing the DOMStorageContext, so delete it manually. |
30 delete dom_storage_context; | 31 delete dom_storage_context; |
31 } | 32 } |
32 | 33 |
| 34 indexed_db_context_->set_clear_local_state_on_exit( |
| 35 clear_local_state_on_exit_); |
33 IndexedDBContext* indexed_db_context = indexed_db_context_.release(); | 36 IndexedDBContext* indexed_db_context = indexed_db_context_.release(); |
34 if (!BrowserThread::DeleteSoon( | 37 if (!BrowserThread::DeleteSoon( |
35 BrowserThread::WEBKIT, FROM_HERE, indexed_db_context)) { | 38 BrowserThread::WEBKIT, FROM_HERE, indexed_db_context)) { |
36 delete indexed_db_context; | 39 delete indexed_db_context; |
37 } | 40 } |
38 } | 41 } |
39 | 42 |
40 void WebKitContext::PurgeMemory() { | 43 void WebKitContext::PurgeMemory() { |
41 if (!BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)) { | 44 if (!BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)) { |
42 BrowserThread::PostTask( | 45 BrowserThread::PostTask( |
(...skipping 28 matching lines...) Expand all Loading... |
71 BrowserThread::PostTask( | 74 BrowserThread::PostTask( |
72 BrowserThread::WEBKIT, FROM_HERE, | 75 BrowserThread::WEBKIT, FROM_HERE, |
73 NewRunnableMethod(this, &WebKitContext::DeleteSessionStorageNamespace, | 76 NewRunnableMethod(this, &WebKitContext::DeleteSessionStorageNamespace, |
74 session_storage_namespace_id)); | 77 session_storage_namespace_id)); |
75 return; | 78 return; |
76 } | 79 } |
77 | 80 |
78 dom_storage_context_->DeleteSessionStorageNamespace( | 81 dom_storage_context_->DeleteSessionStorageNamespace( |
79 session_storage_namespace_id); | 82 session_storage_namespace_id); |
80 } | 83 } |
OLD | NEW |