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

Side by Side Diff: content/common/indexed_db/indexed_db_dispatcher.cc

Issue 10052005: Add DCHECK to ensure IndexedDBDispatcher doesn't get re-created. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: improved comment Created 8 years, 8 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) 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 "content/common/indexed_db/indexed_db_dispatcher.h" 5 #include "content/common/indexed_db/indexed_db_dispatcher.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/threading/thread_local.h" 8 #include "base/threading/thread_local.h"
9 #include "content/common/child_thread.h" 9 #include "content/common/child_thread.h"
10 #include "content/common/indexed_db/indexed_db_messages.h" 10 #include "content/common/indexed_db/indexed_db_messages.h"
(...skipping 20 matching lines...) Expand all
31 using WebKit::WebIDBDatabaseError; 31 using WebKit::WebIDBDatabaseError;
32 using WebKit::WebIDBTransaction; 32 using WebKit::WebIDBTransaction;
33 using WebKit::WebIDBTransactionCallbacks; 33 using WebKit::WebIDBTransactionCallbacks;
34 using webkit_glue::WorkerTaskRunner; 34 using webkit_glue::WorkerTaskRunner;
35 35
36 static base::LazyInstance<ThreadLocalPointer<IndexedDBDispatcher> >::Leaky 36 static base::LazyInstance<ThreadLocalPointer<IndexedDBDispatcher> >::Leaky
37 g_idb_dispatcher_tls = LAZY_INSTANCE_INITIALIZER; 37 g_idb_dispatcher_tls = LAZY_INSTANCE_INITIALIZER;
38 38
39 namespace { 39 namespace {
40 40
41 IndexedDBDispatcher* const HAS_BEEN_DELETED =
jam 2012/04/11 23:35:01 nit: constants in google style guide are of the fo
dgrogan 2012/04/12 02:27:49 Done.
42 reinterpret_cast<IndexedDBDispatcher*>(0x1);
43
41 int32 CurrentWorkerId() { 44 int32 CurrentWorkerId() {
42 return WorkerTaskRunner::Instance()->CurrentWorkerId(); 45 return WorkerTaskRunner::Instance()->CurrentWorkerId();
43 } 46 }
44 47
45 } // unnamed namespace 48 } // unnamed namespace
46 49
47 const size_t kMaxIDBValueSizeInBytes = 64 * 1024 * 1024; 50 const size_t kMaxIDBValueSizeInBytes = 64 * 1024 * 1024;
48 51
49 IndexedDBDispatcher::IndexedDBDispatcher() { 52 IndexedDBDispatcher::IndexedDBDispatcher() {
50 g_idb_dispatcher_tls.Pointer()->Set(this); 53 g_idb_dispatcher_tls.Pointer()->Set(this);
51 } 54 }
52 55
53 IndexedDBDispatcher::~IndexedDBDispatcher() { 56 IndexedDBDispatcher::~IndexedDBDispatcher() {
54 g_idb_dispatcher_tls.Pointer()->Set(NULL); 57 g_idb_dispatcher_tls.Pointer()->Set(HAS_BEEN_DELETED);
55 } 58 }
56 59
57 IndexedDBDispatcher* IndexedDBDispatcher::ThreadSpecificInstance() { 60 IndexedDBDispatcher* IndexedDBDispatcher::ThreadSpecificInstance() {
61 if (g_idb_dispatcher_tls.Pointer()->Get() == HAS_BEEN_DELETED) {
62 NOTREACHED() << "Re-instantiating TLS IndexedDBDispatcher.";
63 g_idb_dispatcher_tls.Pointer()->Set(NULL);
64 }
58 if (g_idb_dispatcher_tls.Pointer()->Get()) 65 if (g_idb_dispatcher_tls.Pointer()->Get())
59 return g_idb_dispatcher_tls.Pointer()->Get(); 66 return g_idb_dispatcher_tls.Pointer()->Get();
60 67
61 IndexedDBDispatcher* dispatcher = new IndexedDBDispatcher; 68 IndexedDBDispatcher* dispatcher = new IndexedDBDispatcher;
62 if (WorkerTaskRunner::Instance()->CurrentWorkerId()) 69 if (WorkerTaskRunner::Instance()->CurrentWorkerId())
63 webkit_glue::WorkerTaskRunner::Instance()->AddStopObserver(dispatcher); 70 webkit_glue::WorkerTaskRunner::Instance()->AddStopObserver(dispatcher);
64 return dispatcher; 71 return dispatcher;
65 } 72 }
66 73
67 void IndexedDBDispatcher::OnWorkerRunLoopStopped() { 74 void IndexedDBDispatcher::OnWorkerRunLoopStopped() {
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 } 713 }
707 714
708 void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) { 715 void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) {
709 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; 716 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator;
710 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { 717 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) {
711 if (i->first == exception_cursor_id) 718 if (i->first == exception_cursor_id)
712 continue; 719 continue;
713 i->second->ResetPrefetchCache(); 720 i->second->ResetPrefetchCache();
714 } 721 }
715 } 722 }
OLDNEW
« no previous file with comments | « content/common/indexed_db/indexed_db_dispatcher.h ('k') | content/renderer/render_thread_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698