OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/child/db_message_filter.h" | 5 #include "content/child/db_message_filter.h" |
6 | 6 |
7 #include "content/common/database_messages.h" | 7 #include "content/common/database_messages.h" |
8 #include "storage/common/database/database_identifier.h" | 8 #include "storage/common/database/database_identifier.h" |
9 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 9 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
10 #include "third_party/WebKit/public/platform/WebString.h" | 10 #include "third_party/WebKit/public/platform/WebString.h" |
11 #include "third_party/WebKit/public/platform/WebURL.h" | 11 #include "third_party/WebKit/public/platform/WebURL.h" |
12 #include "third_party/WebKit/public/web/WebDatabase.h" | 12 #include "third_party/WebKit/public/web/WebDatabase.h" |
| 13 #include "url/origin.h" |
13 | 14 |
14 using blink::WebSecurityOrigin; | 15 using blink::WebSecurityOrigin; |
15 using blink::WebString; | 16 using blink::WebString; |
16 | 17 |
17 namespace content { | 18 namespace content { |
18 | 19 |
19 namespace { | |
20 | |
21 // TODO(jsbell): Pass url::Origin over IPC instead of database identifier/GURL. | |
22 // https://crbug.com/591482 | |
23 WebSecurityOrigin OriginFromIdentifier(const std::string& identifier) { | |
24 return WebSecurityOrigin::create( | |
25 storage::GetOriginFromIdentifier(identifier)); | |
26 } | |
27 | |
28 } // namespace | |
29 | |
30 DBMessageFilter::DBMessageFilter() { | 20 DBMessageFilter::DBMessageFilter() { |
31 } | 21 } |
32 | 22 |
33 bool DBMessageFilter::OnMessageReceived(const IPC::Message& message) { | 23 bool DBMessageFilter::OnMessageReceived(const IPC::Message& message) { |
34 bool handled = true; | 24 bool handled = true; |
35 IPC_BEGIN_MESSAGE_MAP(DBMessageFilter, message) | 25 IPC_BEGIN_MESSAGE_MAP(DBMessageFilter, message) |
36 IPC_MESSAGE_HANDLER(DatabaseMsg_UpdateSize, OnDatabaseUpdateSize) | 26 IPC_MESSAGE_HANDLER(DatabaseMsg_UpdateSize, OnDatabaseUpdateSize) |
37 IPC_MESSAGE_HANDLER(DatabaseMsg_UpdateSpaceAvailable, | 27 IPC_MESSAGE_HANDLER(DatabaseMsg_UpdateSpaceAvailable, |
38 OnDatabaseUpdateSpaceAvailable) | 28 OnDatabaseUpdateSpaceAvailable) |
39 IPC_MESSAGE_HANDLER(DatabaseMsg_ResetSpaceAvailable, | 29 IPC_MESSAGE_HANDLER(DatabaseMsg_ResetSpaceAvailable, |
40 OnDatabaseResetSpaceAvailable) | 30 OnDatabaseResetSpaceAvailable) |
41 IPC_MESSAGE_HANDLER(DatabaseMsg_CloseImmediately, | 31 IPC_MESSAGE_HANDLER(DatabaseMsg_CloseImmediately, |
42 OnDatabaseCloseImmediately) | 32 OnDatabaseCloseImmediately) |
43 IPC_MESSAGE_UNHANDLED(handled = false) | 33 IPC_MESSAGE_UNHANDLED(handled = false) |
44 IPC_END_MESSAGE_MAP() | 34 IPC_END_MESSAGE_MAP() |
45 return handled; | 35 return handled; |
46 } | 36 } |
47 | 37 |
48 void DBMessageFilter::OnDatabaseUpdateSize(const std::string& origin_identifier, | 38 void DBMessageFilter::OnDatabaseUpdateSize(const url::Origin& origin, |
49 const base::string16& database_name, | 39 const base::string16& database_name, |
50 int64_t database_size) { | 40 int64_t database_size) { |
51 blink::WebDatabase::updateDatabaseSize( | 41 DCHECK(!origin.unique()); |
52 OriginFromIdentifier(origin_identifier), database_name, database_size); | 42 blink::WebDatabase::updateDatabaseSize(origin, database_name, database_size); |
53 } | 43 } |
54 | 44 |
55 void DBMessageFilter::OnDatabaseUpdateSpaceAvailable( | 45 void DBMessageFilter::OnDatabaseUpdateSpaceAvailable(const url::Origin& origin, |
56 const std::string& origin_identifier, | 46 int64_t space_available) { |
57 int64_t space_available) { | 47 DCHECK(!origin.unique()); |
58 blink::WebDatabase::updateSpaceAvailable( | 48 blink::WebDatabase::updateSpaceAvailable(origin, space_available); |
59 OriginFromIdentifier(origin_identifier), space_available); | |
60 } | 49 } |
61 | 50 |
62 void DBMessageFilter::OnDatabaseResetSpaceAvailable( | 51 void DBMessageFilter::OnDatabaseResetSpaceAvailable(const url::Origin& origin) { |
63 const std::string& origin_identifier) { | 52 DCHECK(!origin.unique()); |
64 blink::WebDatabase::resetSpaceAvailable( | 53 blink::WebDatabase::resetSpaceAvailable(origin); |
65 OriginFromIdentifier(origin_identifier)); | |
66 } | 54 } |
67 | 55 |
68 void DBMessageFilter::OnDatabaseCloseImmediately( | 56 void DBMessageFilter::OnDatabaseCloseImmediately( |
69 const std::string& origin_identifier, | 57 const url::Origin& origin, |
70 const base::string16& database_name) { | 58 const base::string16& database_name) { |
71 blink::WebDatabase::closeDatabaseImmediately( | 59 DCHECK(!origin.unique()); |
72 OriginFromIdentifier(origin_identifier), database_name); | 60 blink::WebDatabase::closeDatabaseImmediately(origin, database_name); |
73 } | 61 } |
74 | 62 |
75 } // namespace content | 63 } // namespace content |
OLD | NEW |