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/common/appcache_messages.h" | 10 #include "content/common/appcache_messages.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 int64 cache_document_was_loaded_from, | 96 int64 cache_document_was_loaded_from, |
97 const GURL& opt_manifest_url) { | 97 const GURL& opt_manifest_url) { |
98 if (appcache_service_.get()) { | 98 if (appcache_service_.get()) { |
99 if (!backend_impl_.SelectCache(host_id, | 99 if (!backend_impl_.SelectCache(host_id, |
100 document_url, | 100 document_url, |
101 cache_document_was_loaded_from, | 101 cache_document_was_loaded_from, |
102 opt_manifest_url)) { | 102 opt_manifest_url)) { |
103 BadMessageReceived(); | 103 BadMessageReceived(); |
104 } | 104 } |
105 } else { | 105 } else { |
106 frontend_proxy_.OnCacheSelected(host_id, appcache::AppCacheInfo()); | 106 frontend_proxy_.OnCacheSelected(host_id, AppCacheInfo()); |
107 } | 107 } |
108 } | 108 } |
109 | 109 |
110 void AppCacheDispatcherHost::OnSelectCacheForWorker( | 110 void AppCacheDispatcherHost::OnSelectCacheForWorker( |
111 int host_id, int parent_process_id, int parent_host_id) { | 111 int host_id, int parent_process_id, int parent_host_id) { |
112 if (appcache_service_.get()) { | 112 if (appcache_service_.get()) { |
113 if (!backend_impl_.SelectCacheForWorker( | 113 if (!backend_impl_.SelectCacheForWorker( |
114 host_id, parent_process_id, parent_host_id)) { | 114 host_id, parent_process_id, parent_host_id)) { |
115 BadMessageReceived(); | 115 BadMessageReceived(); |
116 } | 116 } |
117 } else { | 117 } else { |
118 frontend_proxy_.OnCacheSelected(host_id, appcache::AppCacheInfo()); | 118 frontend_proxy_.OnCacheSelected(host_id, AppCacheInfo()); |
119 } | 119 } |
120 } | 120 } |
121 | 121 |
122 void AppCacheDispatcherHost::OnSelectCacheForSharedWorker( | 122 void AppCacheDispatcherHost::OnSelectCacheForSharedWorker( |
123 int host_id, int64 appcache_id) { | 123 int host_id, int64 appcache_id) { |
124 if (appcache_service_.get()) { | 124 if (appcache_service_.get()) { |
125 if (!backend_impl_.SelectCacheForSharedWorker(host_id, appcache_id)) | 125 if (!backend_impl_.SelectCacheForSharedWorker(host_id, appcache_id)) |
126 BadMessageReceived(); | 126 BadMessageReceived(); |
127 } else { | 127 } else { |
128 frontend_proxy_.OnCacheSelected(host_id, appcache::AppCacheInfo()); | 128 frontend_proxy_.OnCacheSelected(host_id, AppCacheInfo()); |
129 } | 129 } |
130 } | 130 } |
131 | 131 |
132 void AppCacheDispatcherHost::OnMarkAsForeignEntry( | 132 void AppCacheDispatcherHost::OnMarkAsForeignEntry( |
133 int host_id, const GURL& document_url, | 133 int host_id, const GURL& document_url, |
134 int64 cache_document_was_loaded_from) { | 134 int64 cache_document_was_loaded_from) { |
135 if (appcache_service_.get()) { | 135 if (appcache_service_.get()) { |
136 if (!backend_impl_.MarkAsForeignEntry( | 136 if (!backend_impl_.MarkAsForeignEntry( |
137 host_id, document_url, cache_document_was_loaded_from)) { | 137 host_id, document_url, cache_document_was_loaded_from)) { |
138 BadMessageReceived(); | 138 BadMessageReceived(); |
139 } | 139 } |
140 } | 140 } |
141 } | 141 } |
142 | 142 |
143 void AppCacheDispatcherHost::OnGetResourceList( | 143 void AppCacheDispatcherHost::OnGetResourceList( |
144 int host_id, std::vector<appcache::AppCacheResourceInfo>* params) { | 144 int host_id, std::vector<AppCacheResourceInfo>* params) { |
145 if (appcache_service_.get()) | 145 if (appcache_service_.get()) |
146 backend_impl_.GetResourceList(host_id, params); | 146 backend_impl_.GetResourceList(host_id, params); |
147 } | 147 } |
148 | 148 |
149 void AppCacheDispatcherHost::OnGetStatus(int host_id, IPC::Message* reply_msg) { | 149 void AppCacheDispatcherHost::OnGetStatus(int host_id, IPC::Message* reply_msg) { |
150 if (pending_reply_msg_) { | 150 if (pending_reply_msg_) { |
151 BadMessageReceived(); | 151 BadMessageReceived(); |
152 delete reply_msg; | 152 delete reply_msg; |
153 return; | 153 return; |
154 } | 154 } |
155 | 155 |
156 pending_reply_msg_.reset(reply_msg); | 156 pending_reply_msg_.reset(reply_msg); |
157 if (appcache_service_.get()) { | 157 if (appcache_service_.get()) { |
158 if (!backend_impl_.GetStatusWithCallback( | 158 if (!backend_impl_.GetStatusWithCallback( |
159 host_id, get_status_callback_, reply_msg)) { | 159 host_id, get_status_callback_, reply_msg)) { |
160 BadMessageReceived(); | 160 BadMessageReceived(); |
161 } | 161 } |
162 return; | 162 return; |
163 } | 163 } |
164 | 164 |
165 GetStatusCallback(appcache::APPCACHE_STATUS_UNCACHED, reply_msg); | 165 GetStatusCallback(APPCACHE_STATUS_UNCACHED, reply_msg); |
166 } | 166 } |
167 | 167 |
168 void AppCacheDispatcherHost::OnStartUpdate(int host_id, | 168 void AppCacheDispatcherHost::OnStartUpdate(int host_id, |
169 IPC::Message* reply_msg) { | 169 IPC::Message* reply_msg) { |
170 if (pending_reply_msg_) { | 170 if (pending_reply_msg_) { |
171 BadMessageReceived(); | 171 BadMessageReceived(); |
172 delete reply_msg; | 172 delete reply_msg; |
173 return; | 173 return; |
174 } | 174 } |
175 | 175 |
(...skipping 22 matching lines...) Expand all Loading... |
198 host_id, swap_cache_callback_, reply_msg)) { | 198 host_id, swap_cache_callback_, reply_msg)) { |
199 BadMessageReceived(); | 199 BadMessageReceived(); |
200 } | 200 } |
201 return; | 201 return; |
202 } | 202 } |
203 | 203 |
204 SwapCacheCallback(false, reply_msg); | 204 SwapCacheCallback(false, reply_msg); |
205 } | 205 } |
206 | 206 |
207 void AppCacheDispatcherHost::GetStatusCallback( | 207 void AppCacheDispatcherHost::GetStatusCallback( |
208 appcache::AppCacheStatus status, void* param) { | 208 AppCacheStatus status, void* param) { |
209 IPC::Message* reply_msg = reinterpret_cast<IPC::Message*>(param); | 209 IPC::Message* reply_msg = reinterpret_cast<IPC::Message*>(param); |
210 DCHECK_EQ(pending_reply_msg_.get(), reply_msg); | 210 DCHECK_EQ(pending_reply_msg_.get(), reply_msg); |
211 AppCacheHostMsg_GetStatus::WriteReplyParams(reply_msg, status); | 211 AppCacheHostMsg_GetStatus::WriteReplyParams(reply_msg, status); |
212 Send(pending_reply_msg_.release()); | 212 Send(pending_reply_msg_.release()); |
213 } | 213 } |
214 | 214 |
215 void AppCacheDispatcherHost::StartUpdateCallback(bool result, void* param) { | 215 void AppCacheDispatcherHost::StartUpdateCallback(bool result, void* param) { |
216 IPC::Message* reply_msg = reinterpret_cast<IPC::Message*>(param); | 216 IPC::Message* reply_msg = reinterpret_cast<IPC::Message*>(param); |
217 DCHECK_EQ(pending_reply_msg_.get(), reply_msg); | 217 DCHECK_EQ(pending_reply_msg_.get(), reply_msg); |
218 AppCacheHostMsg_StartUpdate::WriteReplyParams(reply_msg, result); | 218 AppCacheHostMsg_StartUpdate::WriteReplyParams(reply_msg, result); |
219 Send(pending_reply_msg_.release()); | 219 Send(pending_reply_msg_.release()); |
220 } | 220 } |
221 | 221 |
222 void AppCacheDispatcherHost::SwapCacheCallback(bool result, void* param) { | 222 void AppCacheDispatcherHost::SwapCacheCallback(bool result, void* param) { |
223 IPC::Message* reply_msg = reinterpret_cast<IPC::Message*>(param); | 223 IPC::Message* reply_msg = reinterpret_cast<IPC::Message*>(param); |
224 DCHECK_EQ(pending_reply_msg_.get(), reply_msg); | 224 DCHECK_EQ(pending_reply_msg_.get(), reply_msg); |
225 AppCacheHostMsg_SwapCache::WriteReplyParams(reply_msg, result); | 225 AppCacheHostMsg_SwapCache::WriteReplyParams(reply_msg, result); |
226 Send(pending_reply_msg_.release()); | 226 Send(pending_reply_msg_.release()); |
227 } | 227 } |
228 | 228 |
229 } // namespace content | 229 } // namespace content |
OLD | NEW |