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

Side by Side Diff: Source/modules/indexeddb/IDBFactory.cpp

Issue 1166553004: IndexedDB: Replace 0 with nullptr where appropriate (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: MOAR Created 5 years, 6 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/indexeddb/IDBDatabase.cpp ('k') | Source/modules/indexeddb/IDBIndex.cpp » ('j') | 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) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google 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 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 return true; 70 return true;
71 } 71 }
72 72
73 IDBRequest* IDBFactory::getDatabaseNames(ScriptState* scriptState, ExceptionStat e& exceptionState) 73 IDBRequest* IDBFactory::getDatabaseNames(ScriptState* scriptState, ExceptionStat e& exceptionState)
74 { 74 {
75 IDB_TRACE("IDBFactory::getDatabaseNames"); 75 IDB_TRACE("IDBFactory::getDatabaseNames");
76 if (!isContextValid(scriptState->executionContext())) 76 if (!isContextValid(scriptState->executionContext()))
77 return nullptr; 77 return nullptr;
78 if (!scriptState->executionContext()->securityOrigin()->canAccessDatabase()) { 78 if (!scriptState->executionContext()->securityOrigin()->canAccessDatabase()) {
79 exceptionState.throwSecurityError("access to the Indexed Database API is denied in this context."); 79 exceptionState.throwSecurityError("access to the Indexed Database API is denied in this context.");
80 return 0; 80 return nullptr;
81 } 81 }
82 82
83 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::createNull(), 0); 83 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::createNull(), nullptr);
84 84
85 if (!m_permissionClient->allowIndexedDB(scriptState->executionContext(), "Da tabase Listing")) { 85 if (!m_permissionClient->allowIndexedDB(scriptState->executionContext(), "Da tabase Listing")) {
86 request->onError(DOMError::create(UnknownError, permissionDeniedErrorMes sage)); 86 request->onError(DOMError::create(UnknownError, permissionDeniedErrorMes sage));
87 return request; 87 return request;
88 } 88 }
89 89
90 Platform::current()->idbFactory()->getDatabaseNames(WebIDBCallbacksImpl::cre ate(request).leakPtr(), createDatabaseIdentifierFromSecurityOrigin(scriptState-> executionContext()->securityOrigin())); 90 Platform::current()->idbFactory()->getDatabaseNames(WebIDBCallbacksImpl::cre ate(request).leakPtr(), createDatabaseIdentifierFromSecurityOrigin(scriptState-> executionContext()->securityOrigin()));
91 return request; 91 return request;
92 } 92 }
93 93
94 IDBOpenDBRequest* IDBFactory::open(ScriptState* scriptState, const String& name, unsigned long long version, ExceptionState& exceptionState) 94 IDBOpenDBRequest* IDBFactory::open(ScriptState* scriptState, const String& name, unsigned long long version, ExceptionState& exceptionState)
95 { 95 {
96 IDB_TRACE("IDBFactory::open"); 96 IDB_TRACE("IDBFactory::open");
97 if (!version) { 97 if (!version) {
98 exceptionState.throwTypeError("The version provided must not be 0."); 98 exceptionState.throwTypeError("The version provided must not be 0.");
99 return 0; 99 return nullptr;
100 } 100 }
101 return openInternal(scriptState, name, version, exceptionState); 101 return openInternal(scriptState, name, version, exceptionState);
102 } 102 }
103 103
104 IDBOpenDBRequest* IDBFactory::openInternal(ScriptState* scriptState, const Strin g& name, int64_t version, ExceptionState& exceptionState) 104 IDBOpenDBRequest* IDBFactory::openInternal(ScriptState* scriptState, const Strin g& name, int64_t version, ExceptionState& exceptionState)
105 { 105 {
106 Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEndAPICall s", IDBOpenCall, IDBMethodsMax); 106 Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEndAPICall s", IDBOpenCall, IDBMethodsMax);
107 ASSERT(version >= 1 || version == IDBDatabaseMetadata::NoIntVersion); 107 ASSERT(version >= 1 || version == IDBDatabaseMetadata::NoIntVersion);
108 if (!isContextValid(scriptState->executionContext())) 108 if (!isContextValid(scriptState->executionContext()))
109 return nullptr; 109 return nullptr;
110 if (!scriptState->executionContext()->securityOrigin()->canAccessDatabase()) { 110 if (!scriptState->executionContext()->securityOrigin()->canAccessDatabase()) {
111 exceptionState.throwSecurityError("access to the Indexed Database API is denied in this context."); 111 exceptionState.throwSecurityError("access to the Indexed Database API is denied in this context.");
112 return 0; 112 return nullptr;
113 } 113 }
114 114
115 IDBDatabaseCallbacks* databaseCallbacks = IDBDatabaseCallbacks::create(); 115 IDBDatabaseCallbacks* databaseCallbacks = IDBDatabaseCallbacks::create();
116 int64_t transactionId = IDBDatabase::nextTransactionId(); 116 int64_t transactionId = IDBDatabase::nextTransactionId();
117 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState, databaseCa llbacks, transactionId, version); 117 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState, databaseCa llbacks, transactionId, version);
118 118
119 if (!m_permissionClient->allowIndexedDB(scriptState->executionContext(), nam e)) { 119 if (!m_permissionClient->allowIndexedDB(scriptState->executionContext(), nam e)) {
120 request->onError(DOMError::create(UnknownError, permissionDeniedErrorMes sage)); 120 request->onError(DOMError::create(UnknownError, permissionDeniedErrorMes sage));
121 return request; 121 return request;
122 } 122 }
123 123
124 Platform::current()->idbFactory()->open(name, version, transactionId, WebIDB CallbacksImpl::create(request).leakPtr(), WebIDBDatabaseCallbacksImpl::create(da tabaseCallbacks).leakPtr(), createDatabaseIdentifierFromSecurityOrigin(scriptSta te->executionContext()->securityOrigin())); 124 Platform::current()->idbFactory()->open(name, version, transactionId, WebIDB CallbacksImpl::create(request).leakPtr(), WebIDBDatabaseCallbacksImpl::create(da tabaseCallbacks).leakPtr(), createDatabaseIdentifierFromSecurityOrigin(scriptSta te->executionContext()->securityOrigin()));
125 return request; 125 return request;
126 } 126 }
127 127
128 IDBOpenDBRequest* IDBFactory::open(ScriptState* scriptState, const String& name, ExceptionState& exceptionState) 128 IDBOpenDBRequest* IDBFactory::open(ScriptState* scriptState, const String& name, ExceptionState& exceptionState)
129 { 129 {
130 IDB_TRACE("IDBFactory::open"); 130 IDB_TRACE("IDBFactory::open");
131 return openInternal(scriptState, name, IDBDatabaseMetadata::NoIntVersion, ex ceptionState); 131 return openInternal(scriptState, name, IDBDatabaseMetadata::NoIntVersion, ex ceptionState);
132 } 132 }
133 133
134 IDBOpenDBRequest* IDBFactory::deleteDatabase(ScriptState* scriptState, const Str ing& name, ExceptionState& exceptionState) 134 IDBOpenDBRequest* IDBFactory::deleteDatabase(ScriptState* scriptState, const Str ing& name, ExceptionState& exceptionState)
135 { 135 {
136 IDB_TRACE("IDBFactory::deleteDatabase"); 136 IDB_TRACE("IDBFactory::deleteDatabase");
137 Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEndAPICall s", IDBDeleteDatabaseCall, IDBMethodsMax); 137 Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEndAPICall s", IDBDeleteDatabaseCall, IDBMethodsMax);
138 if (!isContextValid(scriptState->executionContext())) 138 if (!isContextValid(scriptState->executionContext()))
139 return nullptr; 139 return nullptr;
140 if (!scriptState->executionContext()->securityOrigin()->canAccessDatabase()) { 140 if (!scriptState->executionContext()->securityOrigin()->canAccessDatabase()) {
141 exceptionState.throwSecurityError("access to the Indexed Database API is denied in this context."); 141 exceptionState.throwSecurityError("access to the Indexed Database API is denied in this context.");
142 return 0; 142 return nullptr;
143 } 143 }
144 144
145 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState, nullptr, 0 , IDBDatabaseMetadata::DefaultIntVersion); 145 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState, nullptr, 0 , IDBDatabaseMetadata::DefaultIntVersion);
146 146
147 if (!m_permissionClient->allowIndexedDB(scriptState->executionContext(), nam e)) { 147 if (!m_permissionClient->allowIndexedDB(scriptState->executionContext(), nam e)) {
148 request->onError(DOMError::create(UnknownError, permissionDeniedErrorMes sage)); 148 request->onError(DOMError::create(UnknownError, permissionDeniedErrorMes sage));
149 return request; 149 return request;
150 } 150 }
151 151
152 Platform::current()->idbFactory()->deleteDatabase(name, WebIDBCallbacksImpl: :create(request).leakPtr(), createDatabaseIdentifierFromSecurityOrigin(scriptSta te->executionContext()->securityOrigin())); 152 Platform::current()->idbFactory()->deleteDatabase(name, WebIDBCallbacksImpl: :create(request).leakPtr(), createDatabaseIdentifierFromSecurityOrigin(scriptSta te->executionContext()->securityOrigin()));
(...skipping 17 matching lines...) Expand all
170 ASSERT(second); 170 ASSERT(second);
171 if (!second->isValid()) { 171 if (!second->isValid()) {
172 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro rMessage); 172 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro rMessage);
173 return 0; 173 return 0;
174 } 174 }
175 175
176 return static_cast<short>(first->compare(second)); 176 return static_cast<short>(first->compare(second));
177 } 177 }
178 178
179 } // namespace blink 179 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/indexeddb/IDBDatabase.cpp ('k') | Source/modules/indexeddb/IDBIndex.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698