OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/appcache/appcache_dispatcher_host.h" | 5 #include "chrome/browser/appcache/appcache_dispatcher_host.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "chrome/browser/appcache/chrome_appcache_service.h" | 8 #include "chrome/browser/appcache/chrome_appcache_service.h" |
9 #include "chrome/browser/renderer_host/browser_render_process_host.h" | 9 #include "chrome/browser/renderer_host/browser_render_process_host.h" |
10 #include "chrome/browser/net/chrome_url_request_context.h" | 10 #include "chrome/browser/net/chrome_url_request_context.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 } | 54 } |
55 | 55 |
56 bool AppCacheDispatcherHost::OnMessageReceived(const IPC::Message& msg, | 56 bool AppCacheDispatcherHost::OnMessageReceived(const IPC::Message& msg, |
57 bool *msg_ok) { | 57 bool *msg_ok) { |
58 DCHECK(receiver_); | 58 DCHECK(receiver_); |
59 *msg_ok = true; | 59 *msg_ok = true; |
60 bool handled = true; | 60 bool handled = true; |
61 IPC_BEGIN_MESSAGE_MAP_EX(AppCacheDispatcherHost, msg, *msg_ok) | 61 IPC_BEGIN_MESSAGE_MAP_EX(AppCacheDispatcherHost, msg, *msg_ok) |
62 IPC_MESSAGE_HANDLER(AppCacheMsg_RegisterHost, OnRegisterHost); | 62 IPC_MESSAGE_HANDLER(AppCacheMsg_RegisterHost, OnRegisterHost); |
63 IPC_MESSAGE_HANDLER(AppCacheMsg_UnregisterHost, OnUnregisterHost); | 63 IPC_MESSAGE_HANDLER(AppCacheMsg_UnregisterHost, OnUnregisterHost); |
| 64 IPC_MESSAGE_HANDLER(AppCacheMsg_GetResourceList, OnGetResourceList); |
64 IPC_MESSAGE_HANDLER(AppCacheMsg_SelectCache, OnSelectCache); | 65 IPC_MESSAGE_HANDLER(AppCacheMsg_SelectCache, OnSelectCache); |
65 IPC_MESSAGE_HANDLER(AppCacheMsg_SelectCacheForWorker, | 66 IPC_MESSAGE_HANDLER(AppCacheMsg_SelectCacheForWorker, |
66 OnSelectCacheForWorker); | 67 OnSelectCacheForWorker); |
67 IPC_MESSAGE_HANDLER(AppCacheMsg_SelectCacheForSharedWorker, | 68 IPC_MESSAGE_HANDLER(AppCacheMsg_SelectCacheForSharedWorker, |
68 OnSelectCacheForSharedWorker); | 69 OnSelectCacheForSharedWorker); |
69 IPC_MESSAGE_HANDLER(AppCacheMsg_MarkAsForeignEntry, OnMarkAsForeignEntry); | 70 IPC_MESSAGE_HANDLER(AppCacheMsg_MarkAsForeignEntry, OnMarkAsForeignEntry); |
70 IPC_MESSAGE_HANDLER_DELAY_REPLY(AppCacheMsg_GetStatus, OnGetStatus); | 71 IPC_MESSAGE_HANDLER_DELAY_REPLY(AppCacheMsg_GetStatus, OnGetStatus); |
71 IPC_MESSAGE_HANDLER_DELAY_REPLY(AppCacheMsg_StartUpdate, OnStartUpdate); | 72 IPC_MESSAGE_HANDLER_DELAY_REPLY(AppCacheMsg_StartUpdate, OnStartUpdate); |
72 IPC_MESSAGE_HANDLER_DELAY_REPLY(AppCacheMsg_SwapCache, OnSwapCache); | 73 IPC_MESSAGE_HANDLER_DELAY_REPLY(AppCacheMsg_SwapCache, OnSwapCache); |
73 IPC_MESSAGE_UNHANDLED(handled = false) | 74 IPC_MESSAGE_UNHANDLED(handled = false) |
(...skipping 21 matching lines...) Expand all Loading... |
95 int host_id, const GURL& document_url, | 96 int host_id, const GURL& document_url, |
96 int64 cache_document_was_loaded_from, | 97 int64 cache_document_was_loaded_from, |
97 const GURL& opt_manifest_url) { | 98 const GURL& opt_manifest_url) { |
98 if (appcache_service_.get()) { | 99 if (appcache_service_.get()) { |
99 if (!backend_impl_.SelectCache(host_id, document_url, | 100 if (!backend_impl_.SelectCache(host_id, document_url, |
100 cache_document_was_loaded_from, | 101 cache_document_was_loaded_from, |
101 opt_manifest_url)) { | 102 opt_manifest_url)) { |
102 ReceivedBadMessage(AppCacheMsg_SelectCache::ID); | 103 ReceivedBadMessage(AppCacheMsg_SelectCache::ID); |
103 } | 104 } |
104 } else { | 105 } else { |
105 frontend_proxy_.OnCacheSelected( | 106 frontend_proxy_.OnCacheSelected(host_id, appcache::AppCacheInfo()); |
106 host_id, appcache::kNoCacheId, appcache::UNCACHED); | |
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 ReceivedBadMessage(AppCacheMsg_SelectCacheForWorker::ID); | 115 ReceivedBadMessage(AppCacheMsg_SelectCacheForWorker::ID); |
116 } | 116 } |
117 } else { | 117 } else { |
118 frontend_proxy_.OnCacheSelected( | 118 frontend_proxy_.OnCacheSelected(host_id, appcache::AppCacheInfo()); |
119 host_id, appcache::kNoCacheId, appcache::UNCACHED); | |
120 } | 119 } |
121 } | 120 } |
122 | 121 |
123 void AppCacheDispatcherHost::OnSelectCacheForSharedWorker( | 122 void AppCacheDispatcherHost::OnSelectCacheForSharedWorker( |
124 int host_id, int64 appcache_id) { | 123 int host_id, int64 appcache_id) { |
125 if (appcache_service_.get()) { | 124 if (appcache_service_.get()) { |
126 if (!backend_impl_.SelectCacheForSharedWorker(host_id, appcache_id)) | 125 if (!backend_impl_.SelectCacheForSharedWorker(host_id, appcache_id)) |
127 ReceivedBadMessage(AppCacheMsg_SelectCacheForSharedWorker::ID); | 126 ReceivedBadMessage(AppCacheMsg_SelectCacheForSharedWorker::ID); |
128 } else { | 127 } else { |
129 frontend_proxy_.OnCacheSelected( | 128 frontend_proxy_.OnCacheSelected(host_id, appcache::AppCacheInfo()); |
130 host_id, appcache::kNoCacheId, appcache::UNCACHED); | |
131 } | 129 } |
132 } | 130 } |
133 | 131 |
134 void AppCacheDispatcherHost::OnMarkAsForeignEntry( | 132 void AppCacheDispatcherHost::OnMarkAsForeignEntry( |
135 int host_id, const GURL& document_url, | 133 int host_id, const GURL& document_url, |
136 int64 cache_document_was_loaded_from) { | 134 int64 cache_document_was_loaded_from) { |
137 if (appcache_service_.get()) { | 135 if (appcache_service_.get()) { |
138 if (!backend_impl_.MarkAsForeignEntry(host_id, document_url, | 136 if (!backend_impl_.MarkAsForeignEntry(host_id, document_url, |
139 cache_document_was_loaded_from)) { | 137 cache_document_was_loaded_from)) { |
140 ReceivedBadMessage(AppCacheMsg_MarkAsForeignEntry::ID); | 138 ReceivedBadMessage(AppCacheMsg_MarkAsForeignEntry::ID); |
141 } | 139 } |
142 } | 140 } |
143 } | 141 } |
144 | 142 |
| 143 void AppCacheDispatcherHost::OnGetResourceList( |
| 144 int host_id, std::vector<appcache::AppCacheResourceInfo>* params) { |
| 145 if (appcache_service_.get()) |
| 146 backend_impl_.GetResourceList(host_id, params); |
| 147 } |
| 148 |
145 void AppCacheDispatcherHost::OnGetStatus(int host_id, | 149 void AppCacheDispatcherHost::OnGetStatus(int host_id, |
146 IPC::Message* reply_msg) { | 150 IPC::Message* reply_msg) { |
147 if (pending_reply_msg_.get()) { | 151 if (pending_reply_msg_.get()) { |
148 ReceivedBadMessage(AppCacheMsg_GetStatus::ID); | 152 ReceivedBadMessage(AppCacheMsg_GetStatus::ID); |
149 delete reply_msg; | 153 delete reply_msg; |
150 return; | 154 return; |
151 } | 155 } |
152 | 156 |
153 pending_reply_msg_.reset(reply_msg); | 157 pending_reply_msg_.reset(reply_msg); |
154 if (appcache_service_.get()) { | 158 if (appcache_service_.get()) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 AppCacheMsg_SwapCache::WriteReplyParams(reply_msg, result); | 227 AppCacheMsg_SwapCache::WriteReplyParams(reply_msg, result); |
224 frontend_proxy_.sender()->Send(pending_reply_msg_.release()); | 228 frontend_proxy_.sender()->Send(pending_reply_msg_.release()); |
225 } | 229 } |
226 | 230 |
227 void AppCacheDispatcherHost::ReceivedBadMessage(uint32 msg_type) { | 231 void AppCacheDispatcherHost::ReceivedBadMessage(uint32 msg_type) { |
228 // TODO(michaeln): Consider gathering UMA stats | 232 // TODO(michaeln): Consider gathering UMA stats |
229 // http://code.google.com/p/chromium/issues/detail?id=24634 | 233 // http://code.google.com/p/chromium/issues/detail?id=24634 |
230 BrowserRenderProcessHost::BadMessageTerminateProcess( | 234 BrowserRenderProcessHost::BadMessageTerminateProcess( |
231 msg_type, receiver_->handle()); | 235 msg_type, receiver_->handle()); |
232 } | 236 } |
OLD | NEW |