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

Side by Side Diff: content/browser/webui/url_data_manager_backend.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
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/webui/url_data_manager_backend.h" 5 #include "content/browser/webui/url_data_manager_backend.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 bool URLRequestChromeJob::GetMimeType(std::string* mime_type) const { 239 bool URLRequestChromeJob::GetMimeType(std::string* mime_type) const {
240 *mime_type = mime_type_; 240 *mime_type = mime_type_;
241 return !mime_type_.empty(); 241 return !mime_type_.empty();
242 } 242 }
243 243
244 int URLRequestChromeJob::GetResponseCode() const { 244 int URLRequestChromeJob::GetResponseCode() const {
245 return net::HTTP_OK; 245 return net::HTTP_OK;
246 } 246 }
247 247
248 void URLRequestChromeJob::GetResponseInfo(net::HttpResponseInfo* info) { 248 void URLRequestChromeJob::GetResponseInfo(net::HttpResponseInfo* info) {
249 DCHECK(!info->headers); 249 DCHECK(!info->headers.get());
250 // Set the headers so that requests serviced by ChromeURLDataManager return a 250 // Set the headers so that requests serviced by ChromeURLDataManager return a
251 // status code of 200. Without this they return a 0, which makes the status 251 // status code of 200. Without this they return a 0, which makes the status
252 // indistiguishable from other error types. Instant relies on getting a 200. 252 // indistiguishable from other error types. Instant relies on getting a 200.
253 info->headers = new net::HttpResponseHeaders("HTTP/1.1 200 OK"); 253 info->headers = new net::HttpResponseHeaders("HTTP/1.1 200 OK");
254 254
255 // Determine the least-privileged content security policy header, if any, 255 // Determine the least-privileged content security policy header, if any,
256 // that is compatible with a given WebUI URL, and append it to the existing 256 // that is compatible with a given WebUI URL, and append it to the existing
257 // response headers. 257 // response headers.
258 if (add_content_security_policy_) { 258 if (add_content_security_policy_) {
259 std::string base = kChromeURLContentSecurityPolicyHeaderBase; 259 std::string base = kChromeURLContentSecurityPolicyHeaderBase;
(...skipping 16 matching lines...) Expand all
276 276
277 void URLRequestChromeJob::DataAvailable(base::RefCountedMemory* bytes) { 277 void URLRequestChromeJob::DataAvailable(base::RefCountedMemory* bytes) {
278 TRACE_EVENT_ASYNC_END0("browser", "DataManager:Request", this); 278 TRACE_EVENT_ASYNC_END0("browser", "DataManager:Request", this);
279 if (bytes) { 279 if (bytes) {
280 // The request completed, and we have all the data. 280 // The request completed, and we have all the data.
281 // Clear any IO pending status. 281 // Clear any IO pending status.
282 SetStatus(net::URLRequestStatus()); 282 SetStatus(net::URLRequestStatus());
283 283
284 data_ = bytes; 284 data_ = bytes;
285 int bytes_read; 285 int bytes_read;
286 if (pending_buf_) { 286 if (pending_buf_.get()) {
287 CHECK(pending_buf_->data()); 287 CHECK(pending_buf_->data());
288 CompleteRead(pending_buf_, pending_buf_size_, &bytes_read); 288 CompleteRead(pending_buf_.get(), pending_buf_size_, &bytes_read);
289 pending_buf_ = NULL; 289 pending_buf_ = NULL;
290 NotifyReadComplete(bytes_read); 290 NotifyReadComplete(bytes_read);
291 } 291 }
292 } else { 292 } else {
293 // The request failed. 293 // The request failed.
294 NotifyDone(net::URLRequestStatus(net::URLRequestStatus::FAILED, 294 NotifyDone(net::URLRequestStatus(net::URLRequestStatus::FAILED,
295 net::ERR_FAILED)); 295 net::ERR_FAILED));
296 } 296 }
297 } 297 }
298 298
299 bool URLRequestChromeJob::ReadRawData(net::IOBuffer* buf, int buf_size, 299 bool URLRequestChromeJob::ReadRawData(net::IOBuffer* buf, int buf_size,
300 int* bytes_read) { 300 int* bytes_read) {
301 if (!data_) { 301 if (!data_.get()) {
302 SetStatus(net::URLRequestStatus(net::URLRequestStatus::IO_PENDING, 0)); 302 SetStatus(net::URLRequestStatus(net::URLRequestStatus::IO_PENDING, 0));
303 DCHECK(!pending_buf_.get()); 303 DCHECK(!pending_buf_.get());
304 CHECK(buf->data()); 304 CHECK(buf->data());
305 pending_buf_ = buf; 305 pending_buf_ = buf;
306 pending_buf_size_ = buf_size; 306 pending_buf_size_ = buf_size;
307 return false; // Tell the caller we're still waiting for data. 307 return false; // Tell the caller we're still waiting for data.
308 } 308 }
309 309
310 // Otherwise, the data is available. 310 // Otherwise, the data is available.
311 CompleteRead(buf, buf_size, bytes_read); 311 CompleteRead(buf, buf_size, bytes_read);
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 // Parse the URL into a request for a source and path. 485 // Parse the URL into a request for a source and path.
486 std::string source_name; 486 std::string source_name;
487 std::string path; 487 std::string path;
488 URLToRequest(request->url(), &source_name, &path); 488 URLToRequest(request->url(), &source_name, &path);
489 489
490 // Look up the data source for the request. 490 // Look up the data source for the request.
491 DataSourceMap::iterator i = data_sources_.find(source_name); 491 DataSourceMap::iterator i = data_sources_.find(source_name);
492 if (i == data_sources_.end()) 492 if (i == data_sources_.end())
493 return false; 493 return false;
494 494
495 URLDataSourceImpl* source = i->second; 495 URLDataSourceImpl* source = i->second.get();
496 496
497 if (!source->source()->ShouldServiceRequest(request)) 497 if (!source->source()->ShouldServiceRequest(request))
498 return false; 498 return false;
499 source->source()->WillServiceRequest(request, &path); 499 source->source()->WillServiceRequest(request, &path);
500 500
501 // Save this request so we know where to send the data. 501 // Save this request so we know where to send the data.
502 RequestID request_id = next_request_id_++; 502 RequestID request_id = next_request_id_++;
503 pending_requests_.insert(std::make_pair(request_id, job)); 503 pending_requests_.insert(std::make_pair(request_id, job));
504 504
505 job->set_allow_caching(source->source()->AllowCaching()); 505 job->set_allow_caching(source->source()->AllowCaching());
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 645
646 } // namespace 646 } // namespace
647 647
648 net::URLRequestJobFactory::ProtocolHandler* 648 net::URLRequestJobFactory::ProtocolHandler*
649 CreateDevToolsProtocolHandler(content::ResourceContext* resource_context, 649 CreateDevToolsProtocolHandler(content::ResourceContext* resource_context,
650 bool is_incognito) { 650 bool is_incognito) {
651 return new DevToolsJobFactory(resource_context, is_incognito); 651 return new DevToolsJobFactory(resource_context, is_incognito);
652 } 652 }
653 653
654 } // namespace content 654 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/webui/shared_resources_data_source.cc ('k') | content/browser/webui/url_data_source_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698