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

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

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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 27 matching lines...) Expand all
38 #include "modules/indexeddb/IDBKey.h" 38 #include "modules/indexeddb/IDBKey.h"
39 #include "modules/indexeddb/IDBTracing.h" 39 #include "modules/indexeddb/IDBTracing.h"
40 #include "modules/indexeddb/IndexedDBClient.h" 40 #include "modules/indexeddb/IndexedDBClient.h"
41 #include "modules/indexeddb/WebIDBCallbacksImpl.h" 41 #include "modules/indexeddb/WebIDBCallbacksImpl.h"
42 #include "modules/indexeddb/WebIDBDatabaseCallbacksImpl.h" 42 #include "modules/indexeddb/WebIDBDatabaseCallbacksImpl.h"
43 #include "platform/Histogram.h" 43 #include "platform/Histogram.h"
44 #include "platform/weborigin/SecurityOrigin.h" 44 #include "platform/weborigin/SecurityOrigin.h"
45 #include "public/platform/Platform.h" 45 #include "public/platform/Platform.h"
46 #include "public/platform/WebSecurityOrigin.h" 46 #include "public/platform/WebSecurityOrigin.h"
47 #include "public/platform/modules/indexeddb/WebIDBFactory.h" 47 #include "public/platform/modules/indexeddb/WebIDBFactory.h"
48 #include <memory>
49 48
50 namespace blink { 49 namespace blink {
51 50
52 static const char permissionDeniedErrorMessage[] = "The user denied permission t o access the database."; 51 static const char permissionDeniedErrorMessage[] = "The user denied permission t o access the database.";
53 52
54 IDBFactory::IDBFactory() 53 IDBFactory::IDBFactory()
55 { 54 {
56 } 55 }
57 56
58 static bool isContextValid(ExecutionContext* context) 57 static bool isContextValid(ExecutionContext* context)
(...skipping 16 matching lines...) Expand all
75 return nullptr; 74 return nullptr;
76 } 75 }
77 76
78 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::createNull(), nullptr); 77 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::createNull(), nullptr);
79 78
80 if (!IndexedDBClient::from(scriptState->getExecutionContext())->allowIndexed DB(scriptState->getExecutionContext(), "Database Listing")) { 79 if (!IndexedDBClient::from(scriptState->getExecutionContext())->allowIndexed DB(scriptState->getExecutionContext(), "Database Listing")) {
81 request->onError(DOMException::create(UnknownError, permissionDeniedErro rMessage)); 80 request->onError(DOMException::create(UnknownError, permissionDeniedErro rMessage));
82 return request; 81 return request;
83 } 82 }
84 83
85 Platform::current()->idbFactory()->getDatabaseNames(WebIDBCallbacksImpl::cre ate(request).release(), WebSecurityOrigin(scriptState->getExecutionContext()->ge tSecurityOrigin())); 84 Platform::current()->idbFactory()->getDatabaseNames(WebIDBCallbacksImpl::cre ate(request).leakPtr(), WebSecurityOrigin(scriptState->getExecutionContext()->ge tSecurityOrigin()));
86 return request; 85 return request;
87 } 86 }
88 87
89 IDBOpenDBRequest* IDBFactory::open(ScriptState* scriptState, const String& name, unsigned long long version, ExceptionState& exceptionState) 88 IDBOpenDBRequest* IDBFactory::open(ScriptState* scriptState, const String& name, unsigned long long version, ExceptionState& exceptionState)
90 { 89 {
91 IDB_TRACE("IDBFactory::open"); 90 IDB_TRACE("IDBFactory::open");
92 if (!version) { 91 if (!version) {
93 exceptionState.throwTypeError("The version provided must not be 0."); 92 exceptionState.throwTypeError("The version provided must not be 0.");
94 return nullptr; 93 return nullptr;
95 } 94 }
(...skipping 13 matching lines...) Expand all
109 108
110 IDBDatabaseCallbacks* databaseCallbacks = IDBDatabaseCallbacks::create(); 109 IDBDatabaseCallbacks* databaseCallbacks = IDBDatabaseCallbacks::create();
111 int64_t transactionId = IDBDatabase::nextTransactionId(); 110 int64_t transactionId = IDBDatabase::nextTransactionId();
112 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState, databaseCa llbacks, transactionId, version); 111 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState, databaseCa llbacks, transactionId, version);
113 112
114 if (!IndexedDBClient::from(scriptState->getExecutionContext())->allowIndexed DB(scriptState->getExecutionContext(), name)) { 113 if (!IndexedDBClient::from(scriptState->getExecutionContext())->allowIndexed DB(scriptState->getExecutionContext(), name)) {
115 request->onError(DOMException::create(UnknownError, permissionDeniedErro rMessage)); 114 request->onError(DOMException::create(UnknownError, permissionDeniedErro rMessage));
116 return request; 115 return request;
117 } 116 }
118 117
119 Platform::current()->idbFactory()->open(name, version, transactionId, WebIDB CallbacksImpl::create(request).release(), WebIDBDatabaseCallbacksImpl::create(da tabaseCallbacks).release(), WebSecurityOrigin(scriptState->getExecutionContext() ->getSecurityOrigin())); 118 Platform::current()->idbFactory()->open(name, version, transactionId, WebIDB CallbacksImpl::create(request).leakPtr(), WebIDBDatabaseCallbacksImpl::create(da tabaseCallbacks).leakPtr(), WebSecurityOrigin(scriptState->getExecutionContext() ->getSecurityOrigin()));
120 return request; 119 return request;
121 } 120 }
122 121
123 IDBOpenDBRequest* IDBFactory::open(ScriptState* scriptState, const String& name, ExceptionState& exceptionState) 122 IDBOpenDBRequest* IDBFactory::open(ScriptState* scriptState, const String& name, ExceptionState& exceptionState)
124 { 123 {
125 IDB_TRACE("IDBFactory::open"); 124 IDB_TRACE("IDBFactory::open");
126 return openInternal(scriptState, name, IDBDatabaseMetadata::NoVersion, excep tionState); 125 return openInternal(scriptState, name, IDBDatabaseMetadata::NoVersion, excep tionState);
127 } 126 }
128 127
129 IDBOpenDBRequest* IDBFactory::deleteDatabase(ScriptState* scriptState, const Str ing& name, ExceptionState& exceptionState) 128 IDBOpenDBRequest* IDBFactory::deleteDatabase(ScriptState* scriptState, const Str ing& name, ExceptionState& exceptionState)
130 { 129 {
131 IDB_TRACE("IDBFactory::deleteDatabase"); 130 IDB_TRACE("IDBFactory::deleteDatabase");
132 IDBDatabase::recordApiCallsHistogram(IDBDeleteDatabaseCall); 131 IDBDatabase::recordApiCallsHistogram(IDBDeleteDatabaseCall);
133 if (!isContextValid(scriptState->getExecutionContext())) 132 if (!isContextValid(scriptState->getExecutionContext()))
134 return nullptr; 133 return nullptr;
135 if (!scriptState->getExecutionContext()->getSecurityOrigin()->canAccessDatab ase()) { 134 if (!scriptState->getExecutionContext()->getSecurityOrigin()->canAccessDatab ase()) {
136 exceptionState.throwSecurityError("access to the Indexed Database API is denied in this context."); 135 exceptionState.throwSecurityError("access to the Indexed Database API is denied in this context.");
137 return nullptr; 136 return nullptr;
138 } 137 }
139 138
140 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState, nullptr, 0 , IDBDatabaseMetadata::DefaultVersion); 139 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState, nullptr, 0 , IDBDatabaseMetadata::DefaultVersion);
141 140
142 if (!IndexedDBClient::from(scriptState->getExecutionContext())->allowIndexed DB(scriptState->getExecutionContext(), name)) { 141 if (!IndexedDBClient::from(scriptState->getExecutionContext())->allowIndexed DB(scriptState->getExecutionContext(), name)) {
143 request->onError(DOMException::create(UnknownError, permissionDeniedErro rMessage)); 142 request->onError(DOMException::create(UnknownError, permissionDeniedErro rMessage));
144 return request; 143 return request;
145 } 144 }
146 145
147 Platform::current()->idbFactory()->deleteDatabase(name, WebIDBCallbacksImpl: :create(request).release(), WebSecurityOrigin(scriptState->getExecutionContext() ->getSecurityOrigin())); 146 Platform::current()->idbFactory()->deleteDatabase(name, WebIDBCallbacksImpl: :create(request).leakPtr(), WebSecurityOrigin(scriptState->getExecutionContext() ->getSecurityOrigin()));
148 return request; 147 return request;
149 } 148 }
150 149
151 short IDBFactory::cmp(ScriptState* scriptState, const ScriptValue& firstValue, c onst ScriptValue& secondValue, ExceptionState& exceptionState) 150 short IDBFactory::cmp(ScriptState* scriptState, const ScriptValue& firstValue, c onst ScriptValue& secondValue, ExceptionState& exceptionState)
152 { 151 {
153 IDBKey* first = ScriptValue::to<IDBKey*>(scriptState->isolate(), firstValue, exceptionState); 152 IDBKey* first = ScriptValue::to<IDBKey*>(scriptState->isolate(), firstValue, exceptionState);
154 if (exceptionState.hadException()) 153 if (exceptionState.hadException())
155 return 0; 154 return 0;
156 ASSERT(first); 155 ASSERT(first);
157 if (!first->isValid()) { 156 if (!first->isValid()) {
158 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro rMessage); 157 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro rMessage);
159 return 0; 158 return 0;
160 } 159 }
161 160
162 IDBKey* second = ScriptValue::to<IDBKey*>(scriptState->isolate(), secondValu e, exceptionState); 161 IDBKey* second = ScriptValue::to<IDBKey*>(scriptState->isolate(), secondValu e, exceptionState);
163 if (exceptionState.hadException()) 162 if (exceptionState.hadException())
164 return 0; 163 return 0;
165 ASSERT(second); 164 ASSERT(second);
166 if (!second->isValid()) { 165 if (!second->isValid()) {
167 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro rMessage); 166 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro rMessage);
168 return 0; 167 return 0;
169 } 168 }
170 169
171 return static_cast<short>(first->compare(second)); 170 return static_cast<short>(first->compare(second));
172 } 171 }
173 172
174 } // namespace blink 173 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/indexeddb/IDBDatabase.cpp ('k') | third_party/WebKit/Source/modules/indexeddb/IDBIndex.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698