| OLD | NEW | 
|---|
|  | (Empty) | 
| 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 |  | 
| 3 // found in the LICENSE file. |  | 
| 4 |  | 
| 5 #ifndef CHROME_BROWSER_RENDERER_HOST_DATABASE_DISPATCHER_HOST_H_ |  | 
| 6 #define CHROME_BROWSER_RENDERER_HOST_DATABASE_DISPATCHER_HOST_H_ |  | 
| 7 #pragma once |  | 
| 8 |  | 
| 9 #include "base/hash_tables.h" |  | 
| 10 #include "base/process.h" |  | 
| 11 #include "base/ref_counted.h" |  | 
| 12 #include "base/string16.h" |  | 
| 13 #include "chrome/common/content_settings.h" |  | 
| 14 #include "ipc/ipc_message.h" |  | 
| 15 #include "webkit/database/database_connections.h" |  | 
| 16 #include "webkit/database/database_tracker.h" |  | 
| 17 |  | 
| 18 class GURL; |  | 
| 19 class HostContentSettingsMap; |  | 
| 20 class Receiver; |  | 
| 21 class ResourceMessageFilter; |  | 
| 22 |  | 
| 23 class DatabaseDispatcherHost |  | 
| 24     : public base::RefCountedThreadSafe<DatabaseDispatcherHost>, |  | 
| 25       public webkit_database::DatabaseTracker::Observer { |  | 
| 26  public: |  | 
| 27   DatabaseDispatcherHost(webkit_database::DatabaseTracker* db_tracker, |  | 
| 28                          IPC::Message::Sender* sender, |  | 
| 29                          HostContentSettingsMap *host_content_settings_map); |  | 
| 30   void Init(base::ProcessHandle process_handle); |  | 
| 31   void Shutdown(); |  | 
| 32 |  | 
| 33   bool OnMessageReceived(const IPC::Message& message, bool* message_was_ok); |  | 
| 34 |  | 
| 35   // VFS message handlers (IO thread) |  | 
| 36   void OnDatabaseOpenFile(const string16& vfs_file_name, |  | 
| 37                           int desired_flags, |  | 
| 38                           IPC::Message* reply_msg); |  | 
| 39   void OnDatabaseDeleteFile(const string16& vfs_file_name, |  | 
| 40                             const bool& sync_dir, |  | 
| 41                             IPC::Message* reply_msg); |  | 
| 42   void OnDatabaseGetFileAttributes(const string16& vfs_file_name, |  | 
| 43                                    IPC::Message* reply_msg); |  | 
| 44   void OnDatabaseGetFileSize(const string16& vfs_file_name, |  | 
| 45                              IPC::Message* reply_msg); |  | 
| 46 |  | 
| 47   // Database tracker message handlers (IO thread) |  | 
| 48   void OnDatabaseOpened(const string16& origin_identifier, |  | 
| 49                         const string16& database_name, |  | 
| 50                         const string16& description, |  | 
| 51                         int64 estimated_size); |  | 
| 52   void OnDatabaseModified(const string16& origin_identifier, |  | 
| 53                           const string16& database_name); |  | 
| 54   void OnDatabaseClosed(const string16& origin_identifier, |  | 
| 55                         const string16& database_name); |  | 
| 56   void OnAllowDatabase(const std::string& origin_url, |  | 
| 57                        const string16& name, |  | 
| 58                        const string16& display_name, |  | 
| 59                        unsigned long estimated_size, |  | 
| 60                        IPC::Message* reply_msg); |  | 
| 61 |  | 
| 62   // DatabaseTracker::Observer callbacks (file thread) |  | 
| 63   virtual void OnDatabaseSizeChanged(const string16& origin_identifier, |  | 
| 64                                      const string16& database_name, |  | 
| 65                                      int64 database_size, |  | 
| 66                                      int64 space_available); |  | 
| 67   virtual void OnDatabaseScheduledForDeletion(const string16& origin_identifier, |  | 
| 68                                               const string16& database_name); |  | 
| 69 |  | 
| 70   webkit_database::DatabaseTracker* database_tracker() const { |  | 
| 71     return db_tracker_.get(); |  | 
| 72   } |  | 
| 73 |  | 
| 74   void Send(IPC::Message* message); |  | 
| 75 |  | 
| 76  private: |  | 
| 77   friend class base::RefCountedThreadSafe<DatabaseDispatcherHost>; |  | 
| 78   virtual ~DatabaseDispatcherHost(); |  | 
| 79 |  | 
| 80   class PromptDelegate; |  | 
| 81 |  | 
| 82   void AddObserver(); |  | 
| 83   void RemoveObserver(); |  | 
| 84 |  | 
| 85   void ReceivedBadMessage(uint32 msg_type); |  | 
| 86 |  | 
| 87   // VFS message handlers (file thread) |  | 
| 88   void DatabaseOpenFile(const string16& vfs_file_name, |  | 
| 89                         int desired_flags, |  | 
| 90                         IPC::Message* reply_msg); |  | 
| 91   void DatabaseDeleteFile(const string16& vfs_file_name, |  | 
| 92                           bool sync_dir, |  | 
| 93                           IPC::Message* reply_msg, |  | 
| 94                           int reschedule_count); |  | 
| 95   void DatabaseGetFileAttributes(const string16& vfs_file_name, |  | 
| 96                                  IPC::Message* reply_msg); |  | 
| 97   void DatabaseGetFileSize(const string16& vfs_file_name, |  | 
| 98                            IPC::Message* reply_msg); |  | 
| 99 |  | 
| 100   // Database tracker message handlers (file thread) |  | 
| 101   void DatabaseOpened(const string16& origin_identifier, |  | 
| 102                       const string16& database_name, |  | 
| 103                       const string16& description, |  | 
| 104                       int64 estimated_size); |  | 
| 105   void DatabaseModified(const string16& origin_identifier, |  | 
| 106                         const string16& database_name); |  | 
| 107   void DatabaseClosed(const string16& origin_identifier, |  | 
| 108                       const string16& database_name); |  | 
| 109 |  | 
| 110   // CookiePromptModalDialog response handler (io thread) |  | 
| 111   void AllowDatabaseResponse(IPC::Message* reply_msg, |  | 
| 112                              ContentSetting content_setting); |  | 
| 113 |  | 
| 114   // The database tracker for the current profile. |  | 
| 115   scoped_refptr<webkit_database::DatabaseTracker> db_tracker_; |  | 
| 116 |  | 
| 117   // The sender to be used for sending out IPC messages. |  | 
| 118   IPC::Message::Sender* message_sender_; |  | 
| 119 |  | 
| 120   // The handle of this process. |  | 
| 121   base::ProcessHandle process_handle_; |  | 
| 122 |  | 
| 123   // True if and only if this instance was added as an observer |  | 
| 124   // to DatabaseTracker. |  | 
| 125   bool observer_added_; |  | 
| 126 |  | 
| 127   // If true, all messages that are normally processed by this class |  | 
| 128   // will be silently discarded. This field should be set to true |  | 
| 129   // only when the corresponding renderer process is about to go away. |  | 
| 130   bool shutdown_; |  | 
| 131 |  | 
| 132   // Keeps track of all DB connections opened by this renderer |  | 
| 133   webkit_database::DatabaseConnections database_connections_; |  | 
| 134 |  | 
| 135   // Used to look up permissions at database creation time. |  | 
| 136   scoped_refptr<HostContentSettingsMap> host_content_settings_map_; |  | 
| 137 }; |  | 
| 138 |  | 
| 139 #endif  // CHROME_BROWSER_RENDERER_HOST_DATABASE_DISPATCHER_HOST_H_ |  | 
| OLD | NEW | 
|---|