Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: content/browser/appcache/appcache_dispatcher_host.cc

Issue 16294003: Update content/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/appcache/chrome_appcache_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "content/public/browser/user_metrics.h" 11 #include "content/public/browser/user_metrics.h"
12 12
13 namespace content { 13 namespace content {
14 14
15 AppCacheDispatcherHost::AppCacheDispatcherHost( 15 AppCacheDispatcherHost::AppCacheDispatcherHost(
16 ChromeAppCacheService* appcache_service, 16 ChromeAppCacheService* appcache_service,
17 int process_id) 17 int process_id)
18 : appcache_service_(appcache_service), 18 : appcache_service_(appcache_service),
19 frontend_proxy_(this), 19 frontend_proxy_(this),
20 process_id_(process_id) { 20 process_id_(process_id) {
21 } 21 }
22 22
23 void AppCacheDispatcherHost::OnChannelConnected(int32 peer_pid) { 23 void AppCacheDispatcherHost::OnChannelConnected(int32 peer_pid) {
24 BrowserMessageFilter::OnChannelConnected(peer_pid); 24 BrowserMessageFilter::OnChannelConnected(peer_pid);
25 if (appcache_service_) { 25 if (appcache_service_.get()) {
26 backend_impl_.Initialize( 26 backend_impl_.Initialize(
27 appcache_service_.get(), &frontend_proxy_, process_id_); 27 appcache_service_.get(), &frontend_proxy_, process_id_);
28 get_status_callback_ = 28 get_status_callback_ =
29 base::Bind(&AppCacheDispatcherHost::GetStatusCallback, 29 base::Bind(&AppCacheDispatcherHost::GetStatusCallback,
30 base::Unretained(this)); 30 base::Unretained(this));
31 start_update_callback_ = 31 start_update_callback_ =
32 base::Bind(&AppCacheDispatcherHost::StartUpdateCallback, 32 base::Bind(&AppCacheDispatcherHost::StartUpdateCallback,
33 base::Unretained(this)); 33 base::Unretained(this));
34 swap_cache_callback_ = 34 swap_cache_callback_ =
35 base::Bind(&AppCacheDispatcherHost::SwapCacheCallback, 35 base::Bind(&AppCacheDispatcherHost::SwapCacheCallback,
(...skipping 26 matching lines...) Expand all
62 } 62 }
63 63
64 AppCacheDispatcherHost::~AppCacheDispatcherHost() {} 64 AppCacheDispatcherHost::~AppCacheDispatcherHost() {}
65 65
66 void AppCacheDispatcherHost::BadMessageReceived() { 66 void AppCacheDispatcherHost::BadMessageReceived() {
67 RecordAction(UserMetricsAction("BadMessageTerminate_ACDH")); 67 RecordAction(UserMetricsAction("BadMessageTerminate_ACDH"));
68 BrowserMessageFilter::BadMessageReceived(); 68 BrowserMessageFilter::BadMessageReceived();
69 } 69 }
70 70
71 void AppCacheDispatcherHost::OnRegisterHost(int host_id) { 71 void AppCacheDispatcherHost::OnRegisterHost(int host_id) {
72 if (appcache_service_) { 72 if (appcache_service_.get()) {
73 if (!backend_impl_.RegisterHost(host_id)) { 73 if (!backend_impl_.RegisterHost(host_id)) {
74 BadMessageReceived(); 74 BadMessageReceived();
75 } 75 }
76 } 76 }
77 } 77 }
78 78
79 void AppCacheDispatcherHost::OnUnregisterHost(int host_id) { 79 void AppCacheDispatcherHost::OnUnregisterHost(int host_id) {
80 if (appcache_service_) { 80 if (appcache_service_.get()) {
81 if (!backend_impl_.UnregisterHost(host_id)) { 81 if (!backend_impl_.UnregisterHost(host_id)) {
82 BadMessageReceived(); 82 BadMessageReceived();
83 } 83 }
84 } 84 }
85 } 85 }
86 86
87 void AppCacheDispatcherHost::OnSetSpawningHostId( 87 void AppCacheDispatcherHost::OnSetSpawningHostId(
88 int host_id, int spawning_host_id) { 88 int host_id, int spawning_host_id) {
89 if (appcache_service_) { 89 if (appcache_service_.get()) {
90 if (!backend_impl_.SetSpawningHostId(host_id, spawning_host_id)) 90 if (!backend_impl_.SetSpawningHostId(host_id, spawning_host_id))
91 BadMessageReceived(); 91 BadMessageReceived();
92 } 92 }
93 } 93 }
94 94
95 void AppCacheDispatcherHost::OnSelectCache( 95 void AppCacheDispatcherHost::OnSelectCache(
96 int host_id, const GURL& document_url, 96 int host_id, const GURL& document_url,
97 int64 cache_document_was_loaded_from, 97 int64 cache_document_was_loaded_from,
98 const GURL& opt_manifest_url) { 98 const GURL& opt_manifest_url) {
99 if (appcache_service_) { 99 if (appcache_service_.get()) {
100 if (!backend_impl_.SelectCache(host_id, document_url, 100 if (!backend_impl_.SelectCache(host_id,
101 document_url,
101 cache_document_was_loaded_from, 102 cache_document_was_loaded_from,
102 opt_manifest_url)) { 103 opt_manifest_url)) {
103 BadMessageReceived(); 104 BadMessageReceived();
104 } 105 }
105 } else { 106 } else {
106 frontend_proxy_.OnCacheSelected(host_id, appcache::AppCacheInfo()); 107 frontend_proxy_.OnCacheSelected(host_id, appcache::AppCacheInfo());
107 } 108 }
108 } 109 }
109 110
110 void AppCacheDispatcherHost::OnSelectCacheForWorker( 111 void AppCacheDispatcherHost::OnSelectCacheForWorker(
111 int host_id, int parent_process_id, int parent_host_id) { 112 int host_id, int parent_process_id, int parent_host_id) {
112 if (appcache_service_) { 113 if (appcache_service_.get()) {
113 if (!backend_impl_.SelectCacheForWorker( 114 if (!backend_impl_.SelectCacheForWorker(
114 host_id, parent_process_id, parent_host_id)) { 115 host_id, parent_process_id, parent_host_id)) {
115 BadMessageReceived(); 116 BadMessageReceived();
116 } 117 }
117 } else { 118 } else {
118 frontend_proxy_.OnCacheSelected(host_id, appcache::AppCacheInfo()); 119 frontend_proxy_.OnCacheSelected(host_id, appcache::AppCacheInfo());
119 } 120 }
120 } 121 }
121 122
122 void AppCacheDispatcherHost::OnSelectCacheForSharedWorker( 123 void AppCacheDispatcherHost::OnSelectCacheForSharedWorker(
123 int host_id, int64 appcache_id) { 124 int host_id, int64 appcache_id) {
124 if (appcache_service_) { 125 if (appcache_service_.get()) {
125 if (!backend_impl_.SelectCacheForSharedWorker(host_id, appcache_id)) 126 if (!backend_impl_.SelectCacheForSharedWorker(host_id, appcache_id))
126 BadMessageReceived(); 127 BadMessageReceived();
127 } else { 128 } else {
128 frontend_proxy_.OnCacheSelected(host_id, appcache::AppCacheInfo()); 129 frontend_proxy_.OnCacheSelected(host_id, appcache::AppCacheInfo());
129 } 130 }
130 } 131 }
131 132
132 void AppCacheDispatcherHost::OnMarkAsForeignEntry( 133 void AppCacheDispatcherHost::OnMarkAsForeignEntry(
133 int host_id, const GURL& document_url, 134 int host_id, const GURL& document_url,
134 int64 cache_document_was_loaded_from) { 135 int64 cache_document_was_loaded_from) {
135 if (appcache_service_) { 136 if (appcache_service_.get()) {
136 if (!backend_impl_.MarkAsForeignEntry(host_id, document_url, 137 if (!backend_impl_.MarkAsForeignEntry(
137 cache_document_was_loaded_from)) { 138 host_id, document_url, cache_document_was_loaded_from)) {
138 BadMessageReceived(); 139 BadMessageReceived();
139 } 140 }
140 } 141 }
141 } 142 }
142 143
143 void AppCacheDispatcherHost::OnGetResourceList( 144 void AppCacheDispatcherHost::OnGetResourceList(
144 int host_id, std::vector<appcache::AppCacheResourceInfo>* params) { 145 int host_id, std::vector<appcache::AppCacheResourceInfo>* params) {
145 if (appcache_service_) 146 if (appcache_service_.get())
146 backend_impl_.GetResourceList(host_id, params); 147 backend_impl_.GetResourceList(host_id, params);
147 } 148 }
148 149
149 void AppCacheDispatcherHost::OnGetStatus(int host_id, IPC::Message* reply_msg) { 150 void AppCacheDispatcherHost::OnGetStatus(int host_id, IPC::Message* reply_msg) {
150 if (pending_reply_msg_) { 151 if (pending_reply_msg_) {
151 BadMessageReceived(); 152 BadMessageReceived();
152 delete reply_msg; 153 delete reply_msg;
153 return; 154 return;
154 } 155 }
155 156
156 pending_reply_msg_.reset(reply_msg); 157 pending_reply_msg_.reset(reply_msg);
157 if (appcache_service_) { 158 if (appcache_service_.get()) {
158 if (!backend_impl_.GetStatusWithCallback(host_id, get_status_callback_, 159 if (!backend_impl_.GetStatusWithCallback(
159 reply_msg)) { 160 host_id, get_status_callback_, reply_msg)) {
160 BadMessageReceived(); 161 BadMessageReceived();
161 } 162 }
162 return; 163 return;
163 } 164 }
164 165
165 GetStatusCallback(appcache::UNCACHED, reply_msg); 166 GetStatusCallback(appcache::UNCACHED, reply_msg);
166 } 167 }
167 168
168 void AppCacheDispatcherHost::OnStartUpdate(int host_id, 169 void AppCacheDispatcherHost::OnStartUpdate(int host_id,
169 IPC::Message* reply_msg) { 170 IPC::Message* reply_msg) {
170 if (pending_reply_msg_) { 171 if (pending_reply_msg_) {
171 BadMessageReceived(); 172 BadMessageReceived();
172 delete reply_msg; 173 delete reply_msg;
173 return; 174 return;
174 } 175 }
175 176
176 pending_reply_msg_.reset(reply_msg); 177 pending_reply_msg_.reset(reply_msg);
177 if (appcache_service_) { 178 if (appcache_service_.get()) {
178 if (!backend_impl_.StartUpdateWithCallback(host_id, start_update_callback_, 179 if (!backend_impl_.StartUpdateWithCallback(
179 reply_msg)) { 180 host_id, start_update_callback_, reply_msg)) {
180 BadMessageReceived(); 181 BadMessageReceived();
181 } 182 }
182 return; 183 return;
183 } 184 }
184 185
185 StartUpdateCallback(false, reply_msg); 186 StartUpdateCallback(false, reply_msg);
186 } 187 }
187 188
188 void AppCacheDispatcherHost::OnSwapCache(int host_id, IPC::Message* reply_msg) { 189 void AppCacheDispatcherHost::OnSwapCache(int host_id, IPC::Message* reply_msg) {
189 if (pending_reply_msg_) { 190 if (pending_reply_msg_) {
190 BadMessageReceived(); 191 BadMessageReceived();
191 delete reply_msg; 192 delete reply_msg;
192 return; 193 return;
193 } 194 }
194 195
195 pending_reply_msg_.reset(reply_msg); 196 pending_reply_msg_.reset(reply_msg);
196 if (appcache_service_) { 197 if (appcache_service_.get()) {
197 if (!backend_impl_.SwapCacheWithCallback(host_id, swap_cache_callback_, 198 if (!backend_impl_.SwapCacheWithCallback(
198 reply_msg)) { 199 host_id, swap_cache_callback_, reply_msg)) {
199 BadMessageReceived(); 200 BadMessageReceived();
200 } 201 }
201 return; 202 return;
202 } 203 }
203 204
204 SwapCacheCallback(false, reply_msg); 205 SwapCacheCallback(false, reply_msg);
205 } 206 }
206 207
207 void AppCacheDispatcherHost::GetStatusCallback( 208 void AppCacheDispatcherHost::GetStatusCallback(
208 appcache::Status status, void* param) { 209 appcache::Status status, void* param) {
(...skipping 11 matching lines...) Expand all
220 } 221 }
221 222
222 void AppCacheDispatcherHost::SwapCacheCallback(bool result, void* param) { 223 void AppCacheDispatcherHost::SwapCacheCallback(bool result, void* param) {
223 IPC::Message* reply_msg = reinterpret_cast<IPC::Message*>(param); 224 IPC::Message* reply_msg = reinterpret_cast<IPC::Message*>(param);
224 DCHECK_EQ(pending_reply_msg_.get(), reply_msg); 225 DCHECK_EQ(pending_reply_msg_.get(), reply_msg);
225 AppCacheHostMsg_SwapCache::WriteReplyParams(reply_msg, result); 226 AppCacheHostMsg_SwapCache::WriteReplyParams(reply_msg, result);
226 Send(pending_reply_msg_.release()); 227 Send(pending_reply_msg_.release());
227 } 228 }
228 229
229 } // namespace content 230 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/appcache/chrome_appcache_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698