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

Side by Side Diff: Source/modules/webdatabase/DatabaseManager.cpp

Issue 212133002: Remove manual ref()-deref() in DatabaseContext. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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
« no previous file with comments | « Source/modules/webdatabase/DatabaseManager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 DatabaseManager::DatabaseManager() 61 DatabaseManager::DatabaseManager()
62 #if !ASSERT_DISABLED 62 #if !ASSERT_DISABLED
63 : m_databaseContextRegisteredCount(0) 63 : m_databaseContextRegisteredCount(0)
64 , m_databaseContextInstanceCount(0) 64 , m_databaseContextInstanceCount(0)
65 #endif 65 #endif
66 { 66 {
67 m_server = new DatabaseServer; 67 m_server = new DatabaseServer;
68 ASSERT(m_server); // We should always have a server to work with. 68 ASSERT(m_server); // We should always have a server to work with.
69 } 69 }
70 70
71 DatabaseManager::~DatabaseManager()
72 {
73 }
74
71 class DatabaseCreationCallbackTask FINAL : public ExecutionContextTask { 75 class DatabaseCreationCallbackTask FINAL : public ExecutionContextTask {
72 public: 76 public:
73 static PassOwnPtr<DatabaseCreationCallbackTask> create(PassRefPtrWillBeRawPt r<Database> database, PassOwnPtr<DatabaseCallback> creationCallback) 77 static PassOwnPtr<DatabaseCreationCallbackTask> create(PassRefPtrWillBeRawPt r<Database> database, PassOwnPtr<DatabaseCallback> creationCallback)
74 { 78 {
75 return adoptPtr(new DatabaseCreationCallbackTask(database, creationCallb ack)); 79 return adoptPtr(new DatabaseCreationCallbackTask(database, creationCallb ack));
76 } 80 }
77 81
78 virtual void performTask(ExecutionContext*) OVERRIDE 82 virtual void performTask(ExecutionContext*) OVERRIDE
79 { 83 {
80 m_creationCallback->handleEvent(m_database.get()); 84 m_creationCallback->handleEvent(m_database.get());
(...skipping 19 matching lines...) Expand all
100 ASSERT(m_databaseContextRegisteredCount <= m_databaseContextInstanceCount); 104 ASSERT(m_databaseContextRegisteredCount <= m_databaseContextInstanceCount);
101 105
102 return m_contextMap.get(context); 106 return m_contextMap.get(context);
103 } 107 }
104 108
105 DatabaseContext* DatabaseManager::databaseContextFor(ExecutionContext* context) 109 DatabaseContext* DatabaseManager::databaseContextFor(ExecutionContext* context)
106 { 110 {
107 if (DatabaseContext* databaseContext = existingDatabaseContextFor(context)) 111 if (DatabaseContext* databaseContext = existingDatabaseContextFor(context))
108 return databaseContext; 112 return databaseContext;
109 // We don't need to hold a reference returned by DatabaseContext::create 113 // We don't need to hold a reference returned by DatabaseContext::create
110 // because a DatabaseContext refers to itself internally. See 114 // because DatabaseContext::create calls registerDatabaseContext, and the
111 // DataabseContext::create. 115 // DatabaseManager holds a reference.
112 return DatabaseContext::create(context).get(); 116 return DatabaseContext::create(context).get();
113 } 117 }
114 118
115 void DatabaseManager::registerDatabaseContext(DatabaseContext* databaseContext) 119 void DatabaseManager::registerDatabaseContext(DatabaseContext* databaseContext)
116 { 120 {
117 MutexLocker locker(m_contextMapLock); 121 MutexLocker locker(m_contextMapLock);
118 ExecutionContext* context = databaseContext->executionContext(); 122 ExecutionContext* context = databaseContext->executionContext();
119 m_contextMap.set(context, databaseContext); 123 m_contextMap.set(context, databaseContext);
120 #if !ASSERT_DISABLED 124 #if !ASSERT_DISABLED
121 m_databaseContextRegisteredCount++; 125 m_databaseContextRegisteredCount++;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 { 270 {
267 m_server->interruptAllDatabasesForContext(databaseContext->backend()); 271 m_server->interruptAllDatabasesForContext(databaseContext->backend());
268 } 272 }
269 273
270 void DatabaseManager::logErrorMessage(ExecutionContext* context, const String& m essage) 274 void DatabaseManager::logErrorMessage(ExecutionContext* context, const String& m essage)
271 { 275 {
272 context->addConsoleMessage(StorageMessageSource, ErrorMessageLevel, message) ; 276 context->addConsoleMessage(StorageMessageSource, ErrorMessageLevel, message) ;
273 } 277 }
274 278
275 } // namespace WebCore 279 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/webdatabase/DatabaseManager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698