| 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 #ifndef CHROME_BROWSER_RENDERER_HOST_DATABASE_DISPATCHER_HOST_H_ | 5 #ifndef CHROME_BROWSER_RENDERER_HOST_DATABASE_DISPATCHER_HOST_H_ |
| 6 #define CHROME_BROWSER_RENDERER_HOST_DATABASE_DISPATCHER_HOST_H_ | 6 #define CHROME_BROWSER_RENDERER_HOST_DATABASE_DISPATCHER_HOST_H_ |
| 7 | 7 |
| 8 #include "base/hash_tables.h" | 8 #include "base/hash_tables.h" |
| 9 #include "base/process.h" | 9 #include "base/process.h" |
| 10 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
| 11 #include "base/string16.h" | 11 #include "base/string16.h" |
| 12 #include "chrome/common/content_settings.h" | 12 #include "chrome/common/content_settings.h" |
| 13 #include "ipc/ipc_message.h" | 13 #include "ipc/ipc_message.h" |
| 14 #include "webkit/database/database_connections.h" | 14 #include "webkit/database/database_connections.h" |
| 15 #include "webkit/database/database_tracker.h" | 15 #include "webkit/database/database_tracker.h" |
| 16 | 16 |
| 17 class GURL; |
| 18 class HostContentSettingsMap; |
| 19 class Receiver; |
| 17 class ResourceMessageFilter; | 20 class ResourceMessageFilter; |
| 18 | 21 |
| 19 class DatabaseDispatcherHost | 22 class DatabaseDispatcherHost |
| 20 : public base::RefCountedThreadSafe<DatabaseDispatcherHost>, | 23 : public base::RefCountedThreadSafe<DatabaseDispatcherHost>, |
| 21 public webkit_database::DatabaseTracker::Observer { | 24 public webkit_database::DatabaseTracker::Observer { |
| 22 public: | 25 public: |
| 23 DatabaseDispatcherHost(webkit_database::DatabaseTracker* db_tracker, | 26 DatabaseDispatcherHost(webkit_database::DatabaseTracker* db_tracker, |
| 24 ResourceMessageFilter* resource_message_filter); | 27 ResourceMessageFilter* resource_message_filter); |
| 25 void Init(base::ProcessHandle process_handle); | 28 void Init(base::ProcessHandle process_handle); |
| 26 void Shutdown(); | 29 void Shutdown(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 41 | 44 |
| 42 // Database tracker message handlers (IO thread) | 45 // Database tracker message handlers (IO thread) |
| 43 void OnDatabaseOpened(const string16& origin_identifier, | 46 void OnDatabaseOpened(const string16& origin_identifier, |
| 44 const string16& database_name, | 47 const string16& database_name, |
| 45 const string16& description, | 48 const string16& description, |
| 46 int64 estimated_size); | 49 int64 estimated_size); |
| 47 void OnDatabaseModified(const string16& origin_identifier, | 50 void OnDatabaseModified(const string16& origin_identifier, |
| 48 const string16& database_name); | 51 const string16& database_name); |
| 49 void OnDatabaseClosed(const string16& origin_identifier, | 52 void OnDatabaseClosed(const string16& origin_identifier, |
| 50 const string16& database_name); | 53 const string16& database_name); |
| 54 void OnAllowDatabase(const std::string& origin, |
| 55 const string16& name, |
| 56 const string16& display_name, |
| 57 unsigned long estimated_size, |
| 58 IPC::Message* reply_msg); |
| 51 | 59 |
| 52 // DatabaseTracker::Observer callbacks (file thread) | 60 // DatabaseTracker::Observer callbacks (file thread) |
| 53 virtual void OnDatabaseSizeChanged(const string16& origin_identifier, | 61 virtual void OnDatabaseSizeChanged(const string16& origin_identifier, |
| 54 const string16& database_name, | 62 const string16& database_name, |
| 55 int64 database_size, | 63 int64 database_size, |
| 56 int64 space_available); | 64 int64 space_available); |
| 57 virtual void OnDatabaseScheduledForDeletion(const string16& origin_identifier, | 65 virtual void OnDatabaseScheduledForDeletion(const string16& origin_identifier, |
| 58 const string16& database_name); | 66 const string16& database_name); |
| 59 | 67 |
| 68 void Send(IPC::Message* message); |
| 69 |
| 60 private: | 70 private: |
| 71 class PromptDelegate; |
| 72 |
| 61 void AddObserver(); | 73 void AddObserver(); |
| 62 void RemoveObserver(); | 74 void RemoveObserver(); |
| 63 | 75 |
| 64 void ReceivedBadMessage(uint32 msg_type); | 76 void ReceivedBadMessage(uint32 msg_type); |
| 65 void SendMessage(IPC::Message* message); | |
| 66 | 77 |
| 67 // VFS message handlers (file thread) | 78 // VFS message handlers (file thread) |
| 68 void DatabaseOpenFile(const string16& vfs_file_name, | 79 void DatabaseOpenFile(const string16& vfs_file_name, |
| 69 int desired_flags, | 80 int desired_flags, |
| 70 int32 message_id); | 81 int32 message_id); |
| 71 void DatabaseDeleteFile(const string16& vfs_file_name, | 82 void DatabaseDeleteFile(const string16& vfs_file_name, |
| 72 bool sync_dir, | 83 bool sync_dir, |
| 73 int32 message_id, | 84 int32 message_id, |
| 74 int reschedule_count); | 85 int reschedule_count); |
| 75 void DatabaseGetFileAttributes(const string16& vfs_file_name, | 86 void DatabaseGetFileAttributes(const string16& vfs_file_name, |
| 76 int32 message_id); | 87 int32 message_id); |
| 77 void DatabaseGetFileSize(const string16& vfs_file_name, | 88 void DatabaseGetFileSize(const string16& vfs_file_name, |
| 78 int32 message_id); | 89 int32 message_id); |
| 79 | 90 |
| 80 // Database tracker message handlers (file thread) | 91 // Database tracker message handlers (file thread) |
| 81 void DatabaseOpened(const string16& origin_identifier, | 92 void DatabaseOpened(const string16& origin_identifier, |
| 82 const string16& database_name, | 93 const string16& database_name, |
| 83 const string16& description, | 94 const string16& description, |
| 84 int64 estimated_size); | 95 int64 estimated_size); |
| 85 void DatabaseModified(const string16& origin_identifier, | 96 void DatabaseModified(const string16& origin_identifier, |
| 86 const string16& database_name); | 97 const string16& database_name); |
| 87 void DatabaseClosed(const string16& origin_identifier, | 98 void DatabaseClosed(const string16& origin_identifier, |
| 88 const string16& database_name); | 99 const string16& database_name); |
| 89 | 100 |
| 90 // Called once we decide whether to allow or block an open file request. | 101 // CookiePromptModalDialog response handler (io thread) |
| 91 void OnDatabaseOpenFileAllowed(const string16& vfs_file_name, | 102 void AllowDatabaseResponse(IPC::Message* reply_msg, |
| 92 int desired_flags, | 103 ContentSetting content_setting); |
| 93 int32 message_id); | |
| 94 void OnDatabaseOpenFileBlocked(int32 message_id); | |
| 95 | 104 |
| 96 // The database tracker for the current profile. | 105 // The database tracker for the current profile. |
| 97 scoped_refptr<webkit_database::DatabaseTracker> db_tracker_; | 106 scoped_refptr<webkit_database::DatabaseTracker> db_tracker_; |
| 98 | 107 |
| 99 // The resource message filter that owns us. | 108 // The resource message filter that owns us. |
| 100 ResourceMessageFilter* resource_message_filter_; | 109 ResourceMessageFilter* resource_message_filter_; |
| 101 | 110 |
| 102 // The handle of this process. | 111 // The handle of this process. |
| 103 base::ProcessHandle process_handle_; | 112 base::ProcessHandle process_handle_; |
| 104 | 113 |
| 105 // True if and only if this instance was added as an observer | 114 // True if and only if this instance was added as an observer |
| 106 // to DatabaseTracker. | 115 // to DatabaseTracker. |
| 107 bool observer_added_; | 116 bool observer_added_; |
| 108 | 117 |
| 109 // If true, all messages that are normally processed by this class | 118 // If true, all messages that are normally processed by this class |
| 110 // will be silently discarded. This field should be set to true | 119 // will be silently discarded. This field should be set to true |
| 111 // only when the corresponding renderer process is about to go away. | 120 // only when the corresponding renderer process is about to go away. |
| 112 bool shutdown_; | 121 bool shutdown_; |
| 113 | 122 |
| 114 // Keeps track of all DB connections opened by this renderer | 123 // Keeps track of all DB connections opened by this renderer |
| 115 webkit_database::DatabaseConnections database_connections_; | 124 webkit_database::DatabaseConnections database_connections_; |
| 116 }; | 125 }; |
| 117 | 126 |
| 118 #endif // CHROME_BROWSER_RENDERER_HOST_DATABASE_DISPATCHER_HOST_H_ | 127 #endif // CHROME_BROWSER_RENDERER_HOST_DATABASE_DISPATCHER_HOST_H_ |
| OLD | NEW |