| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_COMMON_APPCACHE_APPCACHE_DISPATCHER_HOST_H_ | |
| 6 #define CHROME_COMMON_APPCACHE_APPCACHE_DISPATCHER_HOST_H_ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "base/process.h" | |
| 11 #include "base/ref_counted.h" | |
| 12 #include "base/scoped_ptr.h" | |
| 13 #include "chrome/common/appcache/appcache_frontend_proxy.h" | |
| 14 #include "ipc/ipc_message.h" | |
| 15 #include "webkit/appcache/appcache_backend_impl.h" | |
| 16 | |
| 17 class ChromeAppCacheService; | |
| 18 class URLRequestContextGetter; | |
| 19 | |
| 20 // Handles appcache related messages sent to the main browser process from | |
| 21 // its child processes. There is a distinct host for each child process. | |
| 22 // Messages are handled on the IO thread. The ResourceMessageFilter creates | |
| 23 // an instance and delegates calls to it. | |
| 24 class AppCacheDispatcherHost { | |
| 25 public: | |
| 26 explicit AppCacheDispatcherHost( | |
| 27 URLRequestContextGetter* request_context_getter); | |
| 28 | |
| 29 void Initialize(IPC::Message::Sender* sender, int process_id, | |
| 30 base::ProcessHandle process_handle); | |
| 31 bool OnMessageReceived(const IPC::Message& msg, bool* msg_is_ok); | |
| 32 | |
| 33 int process_id() const { return backend_impl_.process_id(); } | |
| 34 | |
| 35 // Note: needed to satisfy ipc message dispatching macros. | |
| 36 bool Send(IPC::Message* msg) { | |
| 37 return frontend_proxy_.sender()->Send(msg); | |
| 38 } | |
| 39 | |
| 40 private: | |
| 41 // Ipc message handlers | |
| 42 void OnRegisterHost(int host_id); | |
| 43 void OnUnregisterHost(int host_id); | |
| 44 void OnSelectCache(int host_id, const GURL& document_url, | |
| 45 int64 cache_document_was_loaded_from, | |
| 46 const GURL& opt_manifest_url); | |
| 47 void OnMarkAsForeignEntry(int host_id, const GURL& document_url, | |
| 48 int64 cache_document_was_loaded_from); | |
| 49 void OnGetStatus(int host_id, IPC::Message* reply_msg); | |
| 50 void OnStartUpdate(int host_id, IPC::Message* reply_msg); | |
| 51 void OnSwapCache(int host_id, IPC::Message* reply_msg); | |
| 52 | |
| 53 void GetStatusCallback(appcache::Status status, void* param); | |
| 54 void StartUpdateCallback(bool result, void* param); | |
| 55 void SwapCacheCallback(bool result, void* param); | |
| 56 | |
| 57 void ReceivedBadMessage(uint32 msg_type); | |
| 58 | |
| 59 AppCacheFrontendProxy frontend_proxy_; | |
| 60 appcache::AppCacheBackendImpl backend_impl_; | |
| 61 | |
| 62 // Temporary until Initialize() 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. | |
| 67 scoped_refptr<ChromeAppCacheService> appcache_service_; | |
| 68 | |
| 69 scoped_ptr<appcache::GetStatusCallback> get_status_callback_; | |
| 70 scoped_ptr<appcache::StartUpdateCallback> start_update_callback_; | |
| 71 scoped_ptr<appcache::SwapCacheCallback> swap_cache_callback_; | |
| 72 base::ProcessHandle process_handle_; | |
| 73 scoped_ptr<IPC::Message> pending_reply_msg_; | |
| 74 | |
| 75 DISALLOW_COPY_AND_ASSIGN(AppCacheDispatcherHost); | |
| 76 }; | |
| 77 | |
| 78 #endif // CHROME_COMMON_APPCACHE_APPCACHE_DISPATCHER_HOST_H_ | |
| OLD | NEW |