| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/file_path.h" | 8 #include "base/file_path.h" |
| 9 | 9 |
| 10 class MessageLoop; | |
| 11 class ResourceMessageFilter; | 10 class ResourceMessageFilter; |
| 12 | 11 |
| 13 namespace IPC { | 12 namespace IPC { |
| 14 class Message; | 13 class Message; |
| 15 } | 14 } |
| 16 | 15 |
| 17 class DatabaseDispatcherHost { | 16 class DatabaseDispatcherHost { |
| 18 public: | 17 public: |
| 19 DatabaseDispatcherHost(const FilePath& profile_path, | 18 DatabaseDispatcherHost(const FilePath& profile_path, |
| 20 ResourceMessageFilter* resource_message_filter); | 19 ResourceMessageFilter* resource_message_filter); |
| 21 ~DatabaseDispatcherHost() {} | 20 ~DatabaseDispatcherHost() {} |
| 22 | 21 |
| 23 // Returns true iff the message is HTML5 DB related and was processed. | 22 // Returns true iff the message is HTML5 DB related and was processed. |
| 24 bool OnMessageReceived(const IPC::Message& message, bool* message_was_ok); | 23 bool OnMessageReceived(const IPC::Message& message, bool* message_was_ok); |
| 25 | 24 |
| 25 private: |
| 26 // Message handlers. |
| 26 // Processes the request to return a handle to the given DB file. | 27 // Processes the request to return a handle to the given DB file. |
| 27 void OnDatabaseOpenFile(const FilePath& file_name, | 28 void OnDatabaseOpenFile(const FilePath& file_name, |
| 28 int desired_flags, | 29 int desired_flags, |
| 29 int32 message_id); | 30 int32 message_id); |
| 30 | 31 |
| 31 // Processes the request to delete the given DB file. | 32 // Processes the request to delete the given DB file. |
| 32 void OnDatabaseDeleteFile(const FilePath& file_name, | 33 void OnDatabaseDeleteFile(const FilePath& file_name, |
| 33 const bool& sync_dir, | 34 const bool& sync_dir, |
| 34 int32 message_id); | 35 int32 message_id); |
| 35 | 36 |
| 36 // Processes the request to return the attributes of the given DB file. | 37 // Processes the request to return the attributes of the given DB file. |
| 37 void OnDatabaseGetFileAttributes(const FilePath& file_name, | 38 void OnDatabaseGetFileAttributes(const FilePath& file_name, |
| 38 int32 message_id); | 39 int32 message_id); |
| 39 | 40 |
| 40 // Processes the request to return the size of the given file. | 41 // Processes the request to return the size of the given file. |
| 41 void OnDatabaseGetFileSize(const FilePath& file_name, | 42 void OnDatabaseGetFileSize(const FilePath& file_name, |
| 42 int32 message_id); | 43 int32 message_id); |
| 43 | 44 |
| 44 private: | |
| 45 // Determines if the message is HTML5 DB related. | |
| 46 bool IsDBMessage(const IPC::Message& message); | |
| 47 | |
| 48 // Returns the directory where all DB files are stored. | 45 // Returns the directory where all DB files are stored. |
| 49 FilePath GetDBDir(); | 46 FilePath GetDBDir(); |
| 50 | 47 |
| 51 // Returns the absolute name of the given DB file. | 48 // Returns the absolute name of the given DB file. |
| 52 FilePath GetDBFileFullPath(const FilePath& file_name); | 49 FilePath GetDBFileFullPath(const FilePath& file_name); |
| 53 | 50 |
| 54 // The user data directory. | 51 // The user data directory. |
| 55 FilePath profile_path_; | 52 FilePath profile_path_; |
| 56 | 53 |
| 57 // The ResourceMessageFilter instance of this renderer process. | 54 // The ResourceMessageFilter instance of this renderer process. Can't keep |
| 55 // a refptr or else we'll get into a cycle. It's always ok to use this in |
| 56 // the IO thread since if the RMF goes away, this object is deleted. |
| 58 ResourceMessageFilter* resource_message_filter_; | 57 ResourceMessageFilter* resource_message_filter_; |
| 59 | |
| 60 // The message loop of the file thread. | |
| 61 MessageLoop* file_thread_message_loop_; | |
| 62 }; | 58 }; |
| 63 | 59 |
| 64 #endif // CHROME_BROWSER_RENDERER_HOST_DATABASE_DISPATCHER_HOST_H_ | 60 #endif // CHROME_BROWSER_RENDERER_HOST_DATABASE_DISPATCHER_HOST_H_ |
| OLD | NEW |