| 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_COMMON_APPCACHE_APPCACHE_DISPATCHER_HOST_H_ | 5 #ifndef CHROME_COMMON_APPCACHE_APPCACHE_DISPATCHER_HOST_H_ |
| 6 #define CHROME_COMMON_APPCACHE_APPCACHE_DISPATCHER_HOST_H_ | 6 #define CHROME_COMMON_APPCACHE_APPCACHE_DISPATCHER_HOST_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/process.h" | 10 #include "base/process.h" |
| 11 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
| 12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
| 13 #include "chrome/common/appcache/appcache_frontend_proxy.h" | 13 #include "chrome/common/appcache/appcache_frontend_proxy.h" |
| 14 #include "ipc/ipc_message.h" | 14 #include "ipc/ipc_message.h" |
| 15 #include "webkit/appcache/appcache_backend_impl.h" | 15 #include "webkit/appcache/appcache_backend_impl.h" |
| 16 | 16 |
| 17 class ChromeAppCacheService; | 17 class ChromeAppCacheService; |
| 18 class URLRequestContextGetter; |
| 18 | 19 |
| 19 // Handles appcache related messages sent to the main browser process from | 20 // Handles appcache related messages sent to the main browser process from |
| 20 // its child processes. There is a distinct host for each child process. | 21 // its child processes. There is a distinct host for each child process. |
| 21 // Messages are handled on the IO thread. The ResourceMessageFilter creates | 22 // Messages are handled on the IO thread. The ResourceMessageFilter creates |
| 22 // an instance and delegates calls to it. | 23 // an instance and delegates calls to it. |
| 23 class AppCacheDispatcherHost { | 24 class AppCacheDispatcherHost { |
| 24 public: | 25 public: |
| 25 explicit AppCacheDispatcherHost(ChromeAppCacheService* appcache_service); | 26 explicit AppCacheDispatcherHost( |
| 27 URLRequestContextGetter* request_context_getter); |
| 26 | 28 |
| 27 void Initialize(IPC::Message::Sender* sender, int process_id, | 29 void Initialize(IPC::Message::Sender* sender, int process_id, |
| 28 base::ProcessHandle process_handle); | 30 base::ProcessHandle process_handle); |
| 29 bool OnMessageReceived(const IPC::Message& msg, bool* msg_is_ok); | 31 bool OnMessageReceived(const IPC::Message& msg, bool* msg_is_ok); |
| 30 | 32 |
| 31 int process_id() const { return backend_impl_.process_id(); } | 33 int process_id() const { return backend_impl_.process_id(); } |
| 32 | 34 |
| 33 // Note: needed to satisfy ipc message dispatching macros. | 35 // Note: needed to satisfy ipc message dispatching macros. |
| 34 bool Send(IPC::Message* msg) { | 36 bool Send(IPC::Message* msg) { |
| 35 return frontend_proxy_.sender()->Send(msg); | 37 return frontend_proxy_.sender()->Send(msg); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 49 void OnSwapCache(int host_id, IPC::Message* reply_msg); | 51 void OnSwapCache(int host_id, IPC::Message* reply_msg); |
| 50 | 52 |
| 51 void GetStatusCallback(appcache::Status status, void* param); | 53 void GetStatusCallback(appcache::Status status, void* param); |
| 52 void StartUpdateCallback(bool result, void* param); | 54 void StartUpdateCallback(bool result, void* param); |
| 53 void SwapCacheCallback(bool result, void* param); | 55 void SwapCacheCallback(bool result, void* param); |
| 54 | 56 |
| 55 void ReceivedBadMessage(uint16 msg_type); | 57 void ReceivedBadMessage(uint16 msg_type); |
| 56 | 58 |
| 57 AppCacheFrontendProxy frontend_proxy_; | 59 AppCacheFrontendProxy frontend_proxy_; |
| 58 appcache::AppCacheBackendImpl backend_impl_; | 60 appcache::AppCacheBackendImpl backend_impl_; |
| 61 |
| 62 // Temporary until Initializer() can be called from the IO thread, |
| 63 // which will extract the AppCacheService from the URLRequestContext. |
| 64 scoped_refptr<URLRequestContextGetter> request_context_getter_; |
| 65 |
| 66 // This is only valid once Initialize() has been called. |
| 59 scoped_refptr<ChromeAppCacheService> appcache_service_; | 67 scoped_refptr<ChromeAppCacheService> appcache_service_; |
| 68 |
| 60 scoped_ptr<appcache::GetStatusCallback> get_status_callback_; | 69 scoped_ptr<appcache::GetStatusCallback> get_status_callback_; |
| 61 scoped_ptr<appcache::StartUpdateCallback> start_update_callback_; | 70 scoped_ptr<appcache::StartUpdateCallback> start_update_callback_; |
| 62 scoped_ptr<appcache::SwapCacheCallback> swap_cache_callback_; | 71 scoped_ptr<appcache::SwapCacheCallback> swap_cache_callback_; |
| 63 base::ProcessHandle process_handle_; | 72 base::ProcessHandle process_handle_; |
| 64 scoped_ptr<IPC::Message> pending_reply_msg_; | 73 scoped_ptr<IPC::Message> pending_reply_msg_; |
| 65 | 74 |
| 66 DISALLOW_COPY_AND_ASSIGN(AppCacheDispatcherHost); | 75 DISALLOW_COPY_AND_ASSIGN(AppCacheDispatcherHost); |
| 67 }; | 76 }; |
| 68 | 77 |
| 69 #endif // CHROME_COMMON_APPCACHE_APPCACHE_DISPATCHER_HOST_H_ | 78 #endif // CHROME_COMMON_APPCACHE_APPCACHE_DISPATCHER_HOST_H_ |
| OLD | NEW |