Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/dom_storage/dom_storage_context.h" | 5 #include "webkit/dom_storage/dom_storage_context.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/guid.h" | 10 #include "base/guid.h" |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 39 // AtomicSequenceNum starts at 0 but we want to start session | 39 // AtomicSequenceNum starts at 0 but we want to start session |
| 40 // namespace ids at one since zero is reserved for the | 40 // namespace ids at one since zero is reserved for the |
| 41 // kLocalStorageNamespaceId. | 41 // kLocalStorageNamespaceId. |
| 42 session_id_sequence_.GetNext(); | 42 session_id_sequence_.GetNext(); |
| 43 } | 43 } |
| 44 | 44 |
| 45 DomStorageContext::~DomStorageContext() { | 45 DomStorageContext::~DomStorageContext() { |
| 46 if (session_storage_database_.get()) { | 46 if (session_storage_database_.get()) { |
| 47 // SessionStorageDatabase shouldn't be deleted right away: deleting it will | 47 // SessionStorageDatabase shouldn't be deleted right away: deleting it will |
| 48 // potentially involve waiting in leveldb::DBImpl::~DBImpl, and waiting | 48 // potentially involve waiting in leveldb::DBImpl::~DBImpl, and waiting |
| 49 // shouldn't happen on this thread. This will unassign the ref counted | 49 // shouldn't happen on this thread. |
| 50 // pointer without decreasing the ref count, and is balanced by the Release | 50 session_storage_database_->AddRef(); |
|
michaeln
2012/12/06 00:26:12
Same raciness here as mentioned before.
piman
2012/12/06 04:56:27
Done.
| |
| 51 // that happens later. | |
| 52 task_runner_->PostShutdownBlockingTask( | 51 task_runner_->PostShutdownBlockingTask( |
| 53 FROM_HERE, | 52 FROM_HERE, |
| 54 DomStorageTaskRunner::COMMIT_SEQUENCE, | 53 DomStorageTaskRunner::COMMIT_SEQUENCE, |
| 55 base::Bind(&SessionStorageDatabase::Release, | 54 base::Bind(&SessionStorageDatabase::Release, |
| 56 base::Unretained(session_storage_database_.release()))); | 55 base::Unretained(session_storage_database_.get()))); |
| 57 } | 56 } |
| 58 } | 57 } |
| 59 | 58 |
| 60 DomStorageNamespace* DomStorageContext::GetStorageNamespace( | 59 DomStorageNamespace* DomStorageContext::GetStorageNamespace( |
| 61 int64 namespace_id) { | 60 int64 namespace_id) { |
| 62 if (is_shutdown_) | 61 if (is_shutdown_) |
| 63 return NULL; | 62 return NULL; |
| 64 StorageNamespaceMap::iterator found = namespaces_.find(namespace_id); | 63 StorageNamespaceMap::iterator found = namespaces_.find(namespace_id); |
| 65 if (found == namespaces_.end()) { | 64 if (found == namespaces_.end()) { |
| 66 if (namespace_id == kLocalStorageNamespaceId) { | 65 if (namespace_id == kLocalStorageNamespaceId) { |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 414 if (!deletable_persistent_namespace_ids_.empty()) { | 413 if (!deletable_persistent_namespace_ids_.empty()) { |
| 415 task_runner_->PostDelayedTask( | 414 task_runner_->PostDelayedTask( |
| 416 FROM_HERE, base::Bind( | 415 FROM_HERE, base::Bind( |
| 417 &DomStorageContext::DeleteNextUnusedNamespace, | 416 &DomStorageContext::DeleteNextUnusedNamespace, |
| 418 this), | 417 this), |
| 419 base::TimeDelta::FromSeconds(kSessionStoraceScavengingSeconds)); | 418 base::TimeDelta::FromSeconds(kSessionStoraceScavengingSeconds)); |
| 420 } | 419 } |
| 421 } | 420 } |
| 422 | 421 |
| 423 } // namespace dom_storage | 422 } // namespace dom_storage |
| OLD | NEW |