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

Side by Side Diff: webkit/dom_storage/dom_storage_context.cc

Issue 11458003: Remove scoped_refptr::release which is confusing and causes leaks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: duh Created 8 years 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) 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
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 SessionStorageDatabase* to_release = session_storage_database_.get();
51 // that happens later. 51 to_release->AddRef();
52 session_storage_database_ = NULL;
52 task_runner_->PostShutdownBlockingTask( 53 task_runner_->PostShutdownBlockingTask(
53 FROM_HERE, 54 FROM_HERE,
54 DomStorageTaskRunner::COMMIT_SEQUENCE, 55 DomStorageTaskRunner::COMMIT_SEQUENCE,
55 base::Bind(&SessionStorageDatabase::Release, 56 base::Bind(&SessionStorageDatabase::Release,
56 base::Unretained(session_storage_database_.release()))); 57 base::Unretained(to_release)));
57 } 58 }
58 } 59 }
59 60
60 DomStorageNamespace* DomStorageContext::GetStorageNamespace( 61 DomStorageNamespace* DomStorageContext::GetStorageNamespace(
61 int64 namespace_id) { 62 int64 namespace_id) {
62 if (is_shutdown_) 63 if (is_shutdown_)
63 return NULL; 64 return NULL;
64 StorageNamespaceMap::iterator found = namespaces_.find(namespace_id); 65 StorageNamespaceMap::iterator found = namespaces_.find(namespace_id);
65 if (found == namespaces_.end()) { 66 if (found == namespaces_.end()) {
66 if (namespace_id == kLocalStorageNamespaceId) { 67 if (namespace_id == kLocalStorageNamespaceId) {
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 if (!deletable_persistent_namespace_ids_.empty()) { 415 if (!deletable_persistent_namespace_ids_.empty()) {
415 task_runner_->PostDelayedTask( 416 task_runner_->PostDelayedTask(
416 FROM_HERE, base::Bind( 417 FROM_HERE, base::Bind(
417 &DomStorageContext::DeleteNextUnusedNamespace, 418 &DomStorageContext::DeleteNextUnusedNamespace,
418 this), 419 this),
419 base::TimeDelta::FromSeconds(kSessionStoraceScavengingSeconds)); 420 base::TimeDelta::FromSeconds(kSessionStoraceScavengingSeconds));
420 } 421 }
421 } 422 }
422 423
423 } // namespace dom_storage 424 } // namespace dom_storage
OLDNEW
« cc/occlusion_tracker_unittest.cc ('K') | « net/disk_cache/backend_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698