OLD | NEW |
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 #include <memory> | 47 #include <memory> |
48 | 48 |
49 namespace blink { | 49 namespace blink { |
50 | 50 |
51 static const char kPermissionDeniedErrorMessage[] = | 51 static const char kPermissionDeniedErrorMessage[] = |
52 "The user denied permission to access the database."; | 52 "The user denied permission to access the database."; |
53 | 53 |
54 IDBFactory::IDBFactory() {} | 54 IDBFactory::IDBFactory() {} |
55 | 55 |
56 static bool IsContextValid(ExecutionContext* context) { | 56 static bool IsContextValid(ExecutionContext* context) { |
57 ASSERT(context->IsDocument() || context->IsWorkerGlobalScope()); | 57 DCHECK(context->IsDocument() || context->IsWorkerGlobalScope()); |
58 if (context->IsDocument()) { | 58 if (context->IsDocument()) { |
59 Document* document = ToDocument(context); | 59 Document* document = ToDocument(context); |
60 return document->GetFrame() && document->GetPage(); | 60 return document->GetFrame() && document->GetPage(); |
61 } | 61 } |
62 return true; | 62 return true; |
63 } | 63 } |
64 | 64 |
65 IDBRequest* IDBFactory::getDatabaseNames(ScriptState* script_state, | 65 IDBRequest* IDBFactory::getDatabaseNames(ScriptState* script_state, |
66 ExceptionState& exception_state) { | 66 ExceptionState& exception_state) { |
67 IDB_TRACE("IDBFactory::getDatabaseNames"); | 67 IDB_TRACE("IDBFactory::getDatabaseNames"); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 return nullptr; | 103 return nullptr; |
104 } | 104 } |
105 return OpenInternal(script_state, name, version, exception_state); | 105 return OpenInternal(script_state, name, version, exception_state); |
106 } | 106 } |
107 | 107 |
108 IDBOpenDBRequest* IDBFactory::OpenInternal(ScriptState* script_state, | 108 IDBOpenDBRequest* IDBFactory::OpenInternal(ScriptState* script_state, |
109 const String& name, | 109 const String& name, |
110 int64_t version, | 110 int64_t version, |
111 ExceptionState& exception_state) { | 111 ExceptionState& exception_state) { |
112 IDBDatabase::RecordApiCallsHistogram(kIDBOpenCall); | 112 IDBDatabase::RecordApiCallsHistogram(kIDBOpenCall); |
113 ASSERT(version >= 1 || version == IDBDatabaseMetadata::kNoVersion); | 113 DCHECK(version >= 1 || version == IDBDatabaseMetadata::kNoVersion); |
114 if (!IsContextValid(script_state->GetExecutionContext())) | 114 if (!IsContextValid(script_state->GetExecutionContext())) |
115 return nullptr; | 115 return nullptr; |
116 if (!script_state->GetExecutionContext() | 116 if (!script_state->GetExecutionContext() |
117 ->GetSecurityOrigin() | 117 ->GetSecurityOrigin() |
118 ->CanAccessDatabase()) { | 118 ->CanAccessDatabase()) { |
119 exception_state.ThrowSecurityError( | 119 exception_state.ThrowSecurityError( |
120 "access to the Indexed Database API is denied in this context."); | 120 "access to the Indexed Database API is denied in this context."); |
121 return nullptr; | 121 return nullptr; |
122 } | 122 } |
123 | 123 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 } | 200 } |
201 | 201 |
202 short IDBFactory::cmp(ScriptState* script_state, | 202 short IDBFactory::cmp(ScriptState* script_state, |
203 const ScriptValue& first_value, | 203 const ScriptValue& first_value, |
204 const ScriptValue& second_value, | 204 const ScriptValue& second_value, |
205 ExceptionState& exception_state) { | 205 ExceptionState& exception_state) { |
206 IDBKey* first = ScriptValue::To<IDBKey*>(script_state->GetIsolate(), | 206 IDBKey* first = ScriptValue::To<IDBKey*>(script_state->GetIsolate(), |
207 first_value, exception_state); | 207 first_value, exception_state); |
208 if (exception_state.HadException()) | 208 if (exception_state.HadException()) |
209 return 0; | 209 return 0; |
210 ASSERT(first); | 210 DCHECK(first); |
211 if (!first->IsValid()) { | 211 if (!first->IsValid()) { |
212 exception_state.ThrowDOMException(kDataError, | 212 exception_state.ThrowDOMException(kDataError, |
213 IDBDatabase::kNotValidKeyErrorMessage); | 213 IDBDatabase::kNotValidKeyErrorMessage); |
214 return 0; | 214 return 0; |
215 } | 215 } |
216 | 216 |
217 IDBKey* second = ScriptValue::To<IDBKey*>(script_state->GetIsolate(), | 217 IDBKey* second = ScriptValue::To<IDBKey*>(script_state->GetIsolate(), |
218 second_value, exception_state); | 218 second_value, exception_state); |
219 if (exception_state.HadException()) | 219 if (exception_state.HadException()) |
220 return 0; | 220 return 0; |
221 ASSERT(second); | 221 DCHECK(second); |
222 if (!second->IsValid()) { | 222 if (!second->IsValid()) { |
223 exception_state.ThrowDOMException(kDataError, | 223 exception_state.ThrowDOMException(kDataError, |
224 IDBDatabase::kNotValidKeyErrorMessage); | 224 IDBDatabase::kNotValidKeyErrorMessage); |
225 return 0; | 225 return 0; |
226 } | 226 } |
227 | 227 |
228 return static_cast<short>(first->Compare(second)); | 228 return static_cast<short>(first->Compare(second)); |
229 } | 229 } |
230 | 230 |
231 } // namespace blink | 231 } // namespace blink |
OLD | NEW |