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 #include "content/browser/appcache/appcache_dispatcher_host.h" | 5 #include "content/browser/appcache/appcache_dispatcher_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "content/browser/appcache/chrome_appcache_service.h" | 9 #include "content/browser/appcache/chrome_appcache_service.h" |
10 #include "content/browser/bad_message.h" | 10 #include "content/browser/bad_message.h" |
11 #include "content/common/appcache_messages.h" | 11 #include "content/common/appcache_messages.h" |
12 #include "content/public/browser/user_metrics.h" | 12 #include "content/public/browser/user_metrics.h" |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 | 15 |
16 AppCacheDispatcherHost::AppCacheDispatcherHost( | 16 AppCacheDispatcherHost::AppCacheDispatcherHost( |
17 ChromeAppCacheService* appcache_service, | 17 ChromeAppCacheService* appcache_service, |
18 int process_id) | 18 int process_id) |
19 : BrowserMessageFilter(AppCacheMsgStart), | 19 : BrowserMessageFilter(AppCacheMsgStart), |
20 appcache_service_(appcache_service), | 20 appcache_service_(appcache_service), |
21 frontend_proxy_(this), | 21 frontend_proxy_(this), |
22 process_id_(process_id), | 22 process_id_(process_id), |
23 weak_factory_(this) { | 23 weak_factory_(this) { |
24 } | 24 } |
25 | 25 |
26 void AppCacheDispatcherHost::OnChannelConnected(int32 peer_pid) { | 26 void AppCacheDispatcherHost::OnChannelConnected(int32_t peer_pid) { |
27 if (appcache_service_.get()) { | 27 if (appcache_service_.get()) { |
28 backend_impl_.Initialize( | 28 backend_impl_.Initialize( |
29 appcache_service_.get(), &frontend_proxy_, process_id_); | 29 appcache_service_.get(), &frontend_proxy_, process_id_); |
30 get_status_callback_ = | 30 get_status_callback_ = |
31 base::Bind(&AppCacheDispatcherHost::GetStatusCallback, | 31 base::Bind(&AppCacheDispatcherHost::GetStatusCallback, |
32 weak_factory_.GetWeakPtr()); | 32 weak_factory_.GetWeakPtr()); |
33 start_update_callback_ = | 33 start_update_callback_ = |
34 base::Bind(&AppCacheDispatcherHost::StartUpdateCallback, | 34 base::Bind(&AppCacheDispatcherHost::StartUpdateCallback, |
35 weak_factory_.GetWeakPtr()); | 35 weak_factory_.GetWeakPtr()); |
36 swap_cache_callback_ = | 36 swap_cache_callback_ = |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 void AppCacheDispatcherHost::OnSetSpawningHostId( | 83 void AppCacheDispatcherHost::OnSetSpawningHostId( |
84 int host_id, int spawning_host_id) { | 84 int host_id, int spawning_host_id) { |
85 if (appcache_service_.get()) { | 85 if (appcache_service_.get()) { |
86 if (!backend_impl_.SetSpawningHostId(host_id, spawning_host_id)) | 86 if (!backend_impl_.SetSpawningHostId(host_id, spawning_host_id)) |
87 bad_message::ReceivedBadMessage(this, bad_message::ACDH_SET_SPAWNING); | 87 bad_message::ReceivedBadMessage(this, bad_message::ACDH_SET_SPAWNING); |
88 } | 88 } |
89 } | 89 } |
90 | 90 |
91 void AppCacheDispatcherHost::OnSelectCache( | 91 void AppCacheDispatcherHost::OnSelectCache( |
92 int host_id, const GURL& document_url, | 92 int host_id, |
93 int64 cache_document_was_loaded_from, | 93 const GURL& document_url, |
| 94 int64_t cache_document_was_loaded_from, |
94 const GURL& opt_manifest_url) { | 95 const GURL& opt_manifest_url) { |
95 if (appcache_service_.get()) { | 96 if (appcache_service_.get()) { |
96 if (!backend_impl_.SelectCache(host_id, | 97 if (!backend_impl_.SelectCache(host_id, |
97 document_url, | 98 document_url, |
98 cache_document_was_loaded_from, | 99 cache_document_was_loaded_from, |
99 opt_manifest_url)) { | 100 opt_manifest_url)) { |
100 bad_message::ReceivedBadMessage(this, bad_message::ACDH_SELECT_CACHE); | 101 bad_message::ReceivedBadMessage(this, bad_message::ACDH_SELECT_CACHE); |
101 } | 102 } |
102 } else { | 103 } else { |
103 frontend_proxy_.OnCacheSelected(host_id, AppCacheInfo()); | 104 frontend_proxy_.OnCacheSelected(host_id, AppCacheInfo()); |
104 } | 105 } |
105 } | 106 } |
106 | 107 |
107 void AppCacheDispatcherHost::OnSelectCacheForWorker( | 108 void AppCacheDispatcherHost::OnSelectCacheForWorker( |
108 int host_id, int parent_process_id, int parent_host_id) { | 109 int host_id, int parent_process_id, int parent_host_id) { |
109 if (appcache_service_.get()) { | 110 if (appcache_service_.get()) { |
110 if (!backend_impl_.SelectCacheForWorker( | 111 if (!backend_impl_.SelectCacheForWorker( |
111 host_id, parent_process_id, parent_host_id)) { | 112 host_id, parent_process_id, parent_host_id)) { |
112 bad_message::ReceivedBadMessage( | 113 bad_message::ReceivedBadMessage( |
113 this, bad_message::ACDH_SELECT_CACHE_FOR_WORKER); | 114 this, bad_message::ACDH_SELECT_CACHE_FOR_WORKER); |
114 } | 115 } |
115 } else { | 116 } else { |
116 frontend_proxy_.OnCacheSelected(host_id, AppCacheInfo()); | 117 frontend_proxy_.OnCacheSelected(host_id, AppCacheInfo()); |
117 } | 118 } |
118 } | 119 } |
119 | 120 |
120 void AppCacheDispatcherHost::OnSelectCacheForSharedWorker( | 121 void AppCacheDispatcherHost::OnSelectCacheForSharedWorker(int host_id, |
121 int host_id, int64 appcache_id) { | 122 int64_t appcache_id) { |
122 if (appcache_service_.get()) { | 123 if (appcache_service_.get()) { |
123 if (!backend_impl_.SelectCacheForSharedWorker(host_id, appcache_id)) | 124 if (!backend_impl_.SelectCacheForSharedWorker(host_id, appcache_id)) |
124 bad_message::ReceivedBadMessage( | 125 bad_message::ReceivedBadMessage( |
125 this, bad_message::ACDH_SELECT_CACHE_FOR_SHARED_WORKER); | 126 this, bad_message::ACDH_SELECT_CACHE_FOR_SHARED_WORKER); |
126 } else { | 127 } else { |
127 frontend_proxy_.OnCacheSelected(host_id, AppCacheInfo()); | 128 frontend_proxy_.OnCacheSelected(host_id, AppCacheInfo()); |
128 } | 129 } |
129 } | 130 } |
130 | 131 |
131 void AppCacheDispatcherHost::OnMarkAsForeignEntry( | 132 void AppCacheDispatcherHost::OnMarkAsForeignEntry( |
132 int host_id, const GURL& document_url, | 133 int host_id, |
133 int64 cache_document_was_loaded_from) { | 134 const GURL& document_url, |
| 135 int64_t cache_document_was_loaded_from) { |
134 if (appcache_service_.get()) { | 136 if (appcache_service_.get()) { |
135 if (!backend_impl_.MarkAsForeignEntry( | 137 if (!backend_impl_.MarkAsForeignEntry( |
136 host_id, document_url, cache_document_was_loaded_from)) { | 138 host_id, document_url, cache_document_was_loaded_from)) { |
137 bad_message::ReceivedBadMessage(this, | 139 bad_message::ReceivedBadMessage(this, |
138 bad_message::ACDH_MARK_AS_FOREIGN_ENTRY); | 140 bad_message::ACDH_MARK_AS_FOREIGN_ENTRY); |
139 } | 141 } |
140 } | 142 } |
141 } | 143 } |
142 | 144 |
143 void AppCacheDispatcherHost::OnGetResourceList( | 145 void AppCacheDispatcherHost::OnGetResourceList( |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 } | 225 } |
224 | 226 |
225 void AppCacheDispatcherHost::SwapCacheCallback(bool result, void* param) { | 227 void AppCacheDispatcherHost::SwapCacheCallback(bool result, void* param) { |
226 IPC::Message* reply_msg = reinterpret_cast<IPC::Message*>(param); | 228 IPC::Message* reply_msg = reinterpret_cast<IPC::Message*>(param); |
227 DCHECK_EQ(pending_reply_msg_.get(), reply_msg); | 229 DCHECK_EQ(pending_reply_msg_.get(), reply_msg); |
228 AppCacheHostMsg_SwapCache::WriteReplyParams(reply_msg, result); | 230 AppCacheHostMsg_SwapCache::WriteReplyParams(reply_msg, result); |
229 Send(pending_reply_msg_.release()); | 231 Send(pending_reply_msg_.release()); |
230 } | 232 } |
231 | 233 |
232 } // namespace content | 234 } // namespace content |
OLD | NEW |