OLD | NEW |
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 10 matching lines...) Expand all Loading... |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "config.h" | 26 #include "config.h" |
27 #include "modules/webdatabase/DatabaseServer.h" | 27 #include "modules/webdatabase/DatabaseServer.h" |
28 | 28 |
29 #include "modules/webdatabase/Database.h" | 29 #include "modules/webdatabase/Database.h" |
30 #include "modules/webdatabase/DatabaseBackend.h" | 30 #include "modules/webdatabase/DatabaseBackend.h" |
31 #include "modules/webdatabase/DatabaseBackendSync.h" | |
32 #include "modules/webdatabase/DatabaseContext.h" | 31 #include "modules/webdatabase/DatabaseContext.h" |
33 #include "modules/webdatabase/DatabaseSync.h" | |
34 #include "modules/webdatabase/DatabaseTracker.h" | 32 #include "modules/webdatabase/DatabaseTracker.h" |
35 | 33 |
36 namespace blink { | 34 namespace blink { |
37 | 35 |
38 String DatabaseServer::fullPathForDatabase(SecurityOrigin* origin, const String&
name, bool createIfDoesNotExist) | 36 String DatabaseServer::fullPathForDatabase(SecurityOrigin* origin, const String&
name, bool createIfDoesNotExist) |
39 { | 37 { |
40 return DatabaseTracker::tracker().fullPathForDatabase(origin, name, createIf
DoesNotExist); | 38 return DatabaseTracker::tracker().fullPathForDatabase(origin, name, createIf
DoesNotExist); |
41 } | 39 } |
42 | 40 |
43 void DatabaseServer::closeDatabasesImmediately(const String& originIdentifier, c
onst String& name) | 41 void DatabaseServer::closeDatabasesImmediately(const String& originIdentifier, c
onst String& name) |
44 { | 42 { |
45 DatabaseTracker::tracker().closeDatabasesImmediately(originIdentifier, name)
; | 43 DatabaseTracker::tracker().closeDatabasesImmediately(originIdentifier, name)
; |
46 } | 44 } |
47 | 45 |
48 void DatabaseServer::interruptAllDatabasesForContext(const DatabaseContext* cont
ext) | |
49 { | |
50 DatabaseTracker::tracker().interruptAllDatabasesForContext(context); | |
51 } | |
52 | |
53 PassRefPtrWillBeRawPtr<DatabaseBackendBase> DatabaseServer::openDatabase(Databas
eContext* backendContext, | 46 PassRefPtrWillBeRawPtr<DatabaseBackendBase> DatabaseServer::openDatabase(Databas
eContext* backendContext, |
54 DatabaseType type, const String& name, const String& expectedVersion, const
String& displayName, | 47 const String& name, const String& expectedVersion, const String& displayName
, |
55 unsigned long estimatedSize, bool setVersionInNewDatabase, DatabaseError &er
ror, String& errorMessage) | 48 unsigned long estimatedSize, bool setVersionInNewDatabase, DatabaseError &er
ror, String& errorMessage) |
56 { | 49 { |
57 RefPtrWillBeRawPtr<DatabaseBackendBase> database = nullptr; | 50 RefPtrWillBeRawPtr<DatabaseBackendBase> database = nullptr; |
58 if (DatabaseTracker::tracker().canEstablishDatabase(backendContext, name, di
splayName, estimatedSize, error)) | 51 if (DatabaseTracker::tracker().canEstablishDatabase(backendContext, name, di
splayName, estimatedSize, error)) |
59 database = createDatabase(backendContext, type, name, expectedVersion, d
isplayName, estimatedSize, setVersionInNewDatabase, error, errorMessage); | 52 database = createDatabase(backendContext, name, expectedVersion, display
Name, estimatedSize, setVersionInNewDatabase, error, errorMessage); |
60 return database.release(); | 53 return database.release(); |
61 } | 54 } |
62 | 55 |
63 PassRefPtrWillBeRawPtr<DatabaseBackendBase> DatabaseServer::createDatabase(Datab
aseContext* backendContext, | 56 PassRefPtrWillBeRawPtr<DatabaseBackendBase> DatabaseServer::createDatabase(Datab
aseContext* backendContext, |
64 DatabaseType type, const String& name, const String& expectedVersion, const
String& displayName, | 57 const String& name, const String& expectedVersion, const String& displayName
, |
65 unsigned long estimatedSize, bool setVersionInNewDatabase, DatabaseError& er
ror, String& errorMessage) | 58 unsigned long estimatedSize, bool setVersionInNewDatabase, DatabaseError& er
ror, String& errorMessage) |
66 { | 59 { |
67 RefPtrWillBeRawPtr<DatabaseBackendBase> database = nullptr; | 60 RefPtrWillBeRawPtr<DatabaseBackendBase> database = adoptRefWillBeNoop(new Da
tabase(backendContext, name, expectedVersion, displayName, estimatedSize)); |
68 switch (type) { | |
69 case DatabaseType::Async: | |
70 database = adoptRefWillBeNoop(new Database(backendContext, name, expecte
dVersion, displayName, estimatedSize)); | |
71 break; | |
72 case DatabaseType::Sync: | |
73 database = adoptRefWillBeNoop(new DatabaseSync(backendContext, name, exp
ectedVersion, displayName, estimatedSize)); | |
74 } | |
75 | |
76 if (!database->openAndVerifyVersion(setVersionInNewDatabase, error, errorMes
sage)) | 61 if (!database->openAndVerifyVersion(setVersionInNewDatabase, error, errorMes
sage)) |
77 return nullptr; | 62 return nullptr; |
78 return database.release(); | 63 return database.release(); |
79 } | 64 } |
80 | 65 |
81 } // namespace blink | 66 } // namespace blink |
OLD | NEW |