OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/common/web_database_observer_impl.h" | 5 #include "chrome/common/web_database_observer_impl.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/string16.h" | 9 #include "base/string16.h" |
10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/database_messages.h" |
11 #include "third_party/WebKit/WebKit/chromium/public/WebDatabase.h" | 11 #include "third_party/WebKit/WebKit/chromium/public/WebDatabase.h" |
| 12 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" |
12 | 13 |
13 WebDatabaseObserverImpl::WebDatabaseObserverImpl( | 14 WebDatabaseObserverImpl::WebDatabaseObserverImpl( |
14 IPC::Message::Sender* sender) | 15 IPC::Message::Sender* sender) |
15 : sender_(sender), | 16 : sender_(sender), |
16 waiting_for_dbs_to_close_(false) { | 17 waiting_for_dbs_to_close_(false) { |
17 } | 18 } |
18 | 19 |
19 void WebDatabaseObserverImpl::databaseOpened( | 20 void WebDatabaseObserverImpl::databaseOpened( |
20 const WebKit::WebDatabase& database) { | 21 const WebKit::WebDatabase& database) { |
21 string16 origin_identifier = database.securityOrigin().databaseIdentifier(); | 22 string16 origin_identifier = database.securityOrigin().databaseIdentifier(); |
22 string16 database_name = database.name(); | 23 string16 database_name = database.name(); |
23 sender_->Send(new ViewHostMsg_DatabaseOpened( | 24 sender_->Send(new DatabaseHostMsg_Opened( |
24 origin_identifier, database_name, | 25 origin_identifier, database_name, |
25 database.displayName(), database.estimatedSize())); | 26 database.displayName(), database.estimatedSize())); |
26 database_connections_.AddConnection(origin_identifier, database_name); | 27 database_connections_.AddConnection(origin_identifier, database_name); |
27 } | 28 } |
28 | 29 |
29 void WebDatabaseObserverImpl::databaseModified( | 30 void WebDatabaseObserverImpl::databaseModified( |
30 const WebKit::WebDatabase& database) { | 31 const WebKit::WebDatabase& database) { |
31 sender_->Send(new ViewHostMsg_DatabaseModified( | 32 sender_->Send(new DatabaseHostMsg_Modified( |
32 database.securityOrigin().databaseIdentifier(), database.name())); | 33 database.securityOrigin().databaseIdentifier(), database.name())); |
33 } | 34 } |
34 | 35 |
35 void WebDatabaseObserverImpl::databaseClosed( | 36 void WebDatabaseObserverImpl::databaseClosed( |
36 const WebKit::WebDatabase& database) { | 37 const WebKit::WebDatabase& database) { |
37 string16 origin_identifier = database.securityOrigin().databaseIdentifier(); | 38 string16 origin_identifier = database.securityOrigin().databaseIdentifier(); |
38 string16 database_name = database.name(); | 39 string16 database_name = database.name(); |
39 sender_->Send(new ViewHostMsg_DatabaseClosed( | 40 sender_->Send(new DatabaseHostMsg_Closed( |
40 origin_identifier, database_name)); | 41 origin_identifier, database_name)); |
41 database_connections_.RemoveConnection(origin_identifier, database_name); | 42 database_connections_.RemoveConnection(origin_identifier, database_name); |
42 if (waiting_for_dbs_to_close_ && database_connections_.IsEmpty()) | 43 if (waiting_for_dbs_to_close_ && database_connections_.IsEmpty()) |
43 MessageLoop::current()->Quit(); | 44 MessageLoop::current()->Quit(); |
44 } | 45 } |
45 | 46 |
46 void WebDatabaseObserverImpl::WaitForAllDatabasesToClose() { | 47 void WebDatabaseObserverImpl::WaitForAllDatabasesToClose() { |
47 if (!database_connections_.IsEmpty()) { | 48 if (!database_connections_.IsEmpty()) { |
48 AutoReset<bool> waiting_for_dbs_auto_reset(&waiting_for_dbs_to_close_, true)
; | 49 AutoReset<bool> waiting_for_dbs_auto_reset(&waiting_for_dbs_to_close_, true)
; |
49 MessageLoop::ScopedNestableTaskAllower nestable(MessageLoop::current()); | 50 MessageLoop::ScopedNestableTaskAllower nestable(MessageLoop::current()); |
50 MessageLoop::current()->Run(); | 51 MessageLoop::current()->Run(); |
51 } | 52 } |
52 } | 53 } |
OLD | NEW |