OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_BROWSER_APPCACHE_APPCACHE_DISPATCHER_HOST_H_ | 5 #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_DISPATCHER_HOST_H_ |
6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_DISPATCHER_HOST_H_ | 6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_DISPATCHER_HOST_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 20 matching lines...) Expand all Loading... |
31 int process_id); | 31 int process_id); |
32 | 32 |
33 // BrowserIOMessageFilter implementation | 33 // BrowserIOMessageFilter implementation |
34 void OnChannelConnected(int32_t peer_pid) override; | 34 void OnChannelConnected(int32_t peer_pid) override; |
35 bool OnMessageReceived(const IPC::Message& message) override; | 35 bool OnMessageReceived(const IPC::Message& message) override; |
36 | 36 |
37 protected: | 37 protected: |
38 ~AppCacheDispatcherHost() override; | 38 ~AppCacheDispatcherHost() override; |
39 | 39 |
40 private: | 40 private: |
| 41 // PlzNavigate: |
| 42 // The AppCacheHost is precreated by the AppCacheNavigationHandleCore class |
| 43 // when a navigation is initiated. We register the host with the backend in |
| 44 // this function and ignore registrations for this host id from the renderer. |
| 45 void RegisterPrecreatedHost(std::unique_ptr<AppCacheHost> host); |
| 46 |
| 47 // PlzNavigate: A pending host is registered when a navigation is initiated |
| 48 // by the browser. The registration completes when the renderer sends the |
| 49 // AppCacheHostMsg_RegisterHost message to us. This function should be called |
| 50 // on the IO thread. |
| 51 void RegisterPendingHost(int host); |
| 52 |
41 // IPC message handlers | 53 // IPC message handlers |
42 void OnRegisterHost(int host_id); | 54 void OnRegisterHost(int host_id); |
43 void OnUnregisterHost(int host_id); | 55 void OnUnregisterHost(int host_id); |
44 void OnSetSpawningHostId(int host_id, int spawning_host_id); | 56 void OnSetSpawningHostId(int host_id, int spawning_host_id); |
45 void OnSelectCache(int host_id, | 57 void OnSelectCache(int host_id, |
46 const GURL& document_url, | 58 const GURL& document_url, |
47 int64_t cache_document_was_loaded_from, | 59 int64_t cache_document_was_loaded_from, |
48 const GURL& opt_manifest_url); | 60 const GURL& opt_manifest_url); |
49 void OnSelectCacheForWorker(int host_id, int parent_process_id, | 61 void OnSelectCacheForWorker(int host_id, int parent_process_id, |
50 int parent_host_id); | 62 int parent_host_id); |
51 void OnSelectCacheForSharedWorker(int host_id, int64_t appcache_id); | 63 void OnSelectCacheForSharedWorker(int host_id, int64_t appcache_id); |
52 void OnMarkAsForeignEntry(int host_id, | 64 void OnMarkAsForeignEntry(int host_id, |
53 const GURL& document_url, | 65 const GURL& document_url, |
54 int64_t cache_document_was_loaded_from); | 66 int64_t cache_document_was_loaded_from); |
55 void OnGetStatus(int host_id, IPC::Message* reply_msg); | 67 void OnGetStatus(int host_id, IPC::Message* reply_msg); |
56 void OnStartUpdate(int host_id, IPC::Message* reply_msg); | 68 void OnStartUpdate(int host_id, IPC::Message* reply_msg); |
57 void OnSwapCache(int host_id, IPC::Message* reply_msg); | 69 void OnSwapCache(int host_id, IPC::Message* reply_msg); |
58 void OnGetResourceList( | 70 void OnGetResourceList( |
59 int host_id, | 71 int host_id, |
60 std::vector<AppCacheResourceInfo>* resource_infos); | 72 std::vector<AppCacheResourceInfo>* resource_infos); |
61 void GetStatusCallback(AppCacheStatus status, void* param); | 73 void GetStatusCallback(AppCacheStatus status, void* param); |
62 void StartUpdateCallback(bool result, void* param); | 74 void StartUpdateCallback(bool result, void* param); |
63 void SwapCacheCallback(bool result, void* param); | 75 void SwapCacheCallback(bool result, void* param); |
64 | 76 |
| 77 // Returns the AppCacheDispatcherHost instance associated with the |
| 78 // |process_id| passed in. |
| 79 static scoped_refptr<AppCacheDispatcherHost> GetHostForProcess( |
| 80 int process_id); |
65 | 81 |
66 scoped_refptr<ChromeAppCacheService> appcache_service_; | 82 scoped_refptr<ChromeAppCacheService> appcache_service_; |
67 AppCacheFrontendProxy frontend_proxy_; | 83 AppCacheFrontendProxy frontend_proxy_; |
68 AppCacheBackendImpl backend_impl_; | 84 AppCacheBackendImpl backend_impl_; |
69 | 85 |
70 content::GetStatusCallback get_status_callback_; | 86 content::GetStatusCallback get_status_callback_; |
71 content::StartUpdateCallback start_update_callback_; | 87 content::StartUpdateCallback start_update_callback_; |
72 content::SwapCacheCallback swap_cache_callback_; | 88 content::SwapCacheCallback swap_cache_callback_; |
73 std::unique_ptr<IPC::Message> pending_reply_msg_; | 89 std::unique_ptr<IPC::Message> pending_reply_msg_; |
74 | 90 |
75 // The corresponding ChildProcessHost object's id(). | 91 // The corresponding ChildProcessHost object's id(). |
76 int process_id_; | 92 int process_id_; |
77 | 93 |
| 94 // PlzNavigate: Contains a list of pending hosts which have been registered |
| 95 // via the RegisterPendingHost() function. The host is removed from the list |
| 96 // when we receive the AppCacheHostMsg_RegisterHost IPC message. |
| 97 std::set<int> pending_hosts_; |
| 98 |
| 99 // PlzNavigate: |
| 100 // This class needs to invoke functionality to register the precreated host |
| 101 // with the AppCacheDispatcherHost. |
| 102 friend class AppCacheNavigationHandleCore; |
| 103 |
78 base::WeakPtrFactory<AppCacheDispatcherHost> weak_factory_; | 104 base::WeakPtrFactory<AppCacheDispatcherHost> weak_factory_; |
79 | 105 |
80 DISALLOW_COPY_AND_ASSIGN(AppCacheDispatcherHost); | 106 DISALLOW_COPY_AND_ASSIGN(AppCacheDispatcherHost); |
81 }; | 107 }; |
82 | 108 |
83 } // namespace content | 109 } // namespace content |
84 | 110 |
85 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_DISPATCHER_HOST_H_ | 111 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_DISPATCHER_HOST_H_ |
OLD | NEW |