| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 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_APPCACHE_APPCACHE_DISPATCHER_HOST_H_ | |
| 6 #define CHROME_BROWSER_APPCACHE_APPCACHE_DISPATCHER_HOST_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/process.h" | |
| 12 #include "base/ref_counted.h" | |
| 13 #include "base/scoped_ptr.h" | |
| 14 #include "chrome/browser/appcache/appcache_frontend_proxy.h" | |
| 15 #include "chrome/browser/browser_message_filter.h" | |
| 16 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | |
| 17 #include "ipc/ipc_message.h" | |
| 18 #include "webkit/appcache/appcache_backend_impl.h" | |
| 19 | |
| 20 class ChromeAppCacheService; | |
| 21 class URLRequestContextGetter; | |
| 22 | |
| 23 namespace net { | |
| 24 class URLRequestContext; | |
| 25 } // namespace net | |
| 26 | |
| 27 // Handles appcache related messages sent to the main browser process from | |
| 28 // its child processes. There is a distinct host for each child process. | |
| 29 // Messages are handled on the IO thread. The BrowserRenderProcessHost and | |
| 30 // WorkerProcessHost create an instance and delegates calls to it. | |
| 31 class AppCacheDispatcherHost : public BrowserMessageFilter { | |
| 32 public: | |
| 33 // Constructor for use on the IO thread. | |
| 34 AppCacheDispatcherHost(net::URLRequestContext* request_context, | |
| 35 int process_id); | |
| 36 | |
| 37 // Constructor for use on the UI thread. | |
| 38 AppCacheDispatcherHost(URLRequestContextGetter* request_context_getter, | |
| 39 int process_id); | |
| 40 | |
| 41 ~AppCacheDispatcherHost(); | |
| 42 | |
| 43 // BrowserIOMessageFilter implementation | |
| 44 virtual void OnChannelConnected(int32 peer_pid); | |
| 45 virtual bool OnMessageReceived(const IPC::Message& message, | |
| 46 bool* message_was_ok); | |
| 47 | |
| 48 private: | |
| 49 // BrowserMessageFilter override. | |
| 50 virtual void BadMessageReceived(); | |
| 51 | |
| 52 // IPC message handlers | |
| 53 void OnRegisterHost(int host_id); | |
| 54 void OnUnregisterHost(int host_id); | |
| 55 void OnSelectCache(int host_id, const GURL& document_url, | |
| 56 int64 cache_document_was_loaded_from, | |
| 57 const GURL& opt_manifest_url); | |
| 58 void OnSelectCacheForWorker(int host_id, int parent_process_id, | |
| 59 int parent_host_id); | |
| 60 void OnSelectCacheForSharedWorker(int host_id, int64 appcache_id); | |
| 61 void OnMarkAsForeignEntry(int host_id, const GURL& document_url, | |
| 62 int64 cache_document_was_loaded_from); | |
| 63 void OnGetStatus(int host_id, IPC::Message* reply_msg); | |
| 64 void OnStartUpdate(int host_id, IPC::Message* reply_msg); | |
| 65 void OnSwapCache(int host_id, IPC::Message* reply_msg); | |
| 66 void OnGetResourceList( | |
| 67 int host_id, | |
| 68 std::vector<appcache::AppCacheResourceInfo>* resource_infos); | |
| 69 void GetStatusCallback(appcache::Status status, void* param); | |
| 70 void StartUpdateCallback(bool result, void* param); | |
| 71 void SwapCacheCallback(bool result, void* param); | |
| 72 | |
| 73 // This is only valid once Initialize() has been called. This MUST be defined | |
| 74 // before backend_impl_ since the latter maintains a (non-refcounted) pointer | |
| 75 // to it. | |
| 76 scoped_refptr<ChromeAppCacheService> appcache_service_; | |
| 77 | |
| 78 AppCacheFrontendProxy frontend_proxy_; | |
| 79 appcache::AppCacheBackendImpl backend_impl_; | |
| 80 | |
| 81 // Temporary until OnChannelConnected() can be called from the IO thread, | |
| 82 // which will extract the AppCacheService from the net::URLRequestContext. | |
| 83 scoped_refptr<net::URLRequestContext> request_context_; | |
| 84 scoped_refptr<URLRequestContextGetter> request_context_getter_; | |
| 85 | |
| 86 scoped_ptr<appcache::GetStatusCallback> get_status_callback_; | |
| 87 scoped_ptr<appcache::StartUpdateCallback> start_update_callback_; | |
| 88 scoped_ptr<appcache::SwapCacheCallback> swap_cache_callback_; | |
| 89 scoped_ptr<IPC::Message> pending_reply_msg_; | |
| 90 | |
| 91 // The corresponding ChildProcessHost object's id(). | |
| 92 int process_id_; | |
| 93 | |
| 94 DISALLOW_COPY_AND_ASSIGN(AppCacheDispatcherHost); | |
| 95 }; | |
| 96 | |
| 97 #endif // CHROME_BROWSER_APPCACHE_APPCACHE_DISPATCHER_HOST_H_ | |
| OLD | NEW |