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

Side by Side Diff: net/url_request/url_request_data_job.cc

Issue 10696135: Offload disk accesses to WorkerPool in ExtensionProtocolHandler (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 // Simple implementation of a data: protocol handler. 5 // Simple implementation of a data: protocol handler.
6 6
7 #include "net/url_request/url_request_data_job.h" 7 #include "net/url_request/url_request_data_job.h"
8 8
9 #include "net/base/data_url.h" 9 #include "net/base/data_url.h"
10 #include "net/base/net_errors.h"
10 11
11 namespace net { 12 namespace net {
12 13
13 URLRequestDataJob::URLRequestDataJob(URLRequest* request) 14 URLRequestDataJob::URLRequestDataJob(URLRequest* request)
14 : URLRequestSimpleJob(request) { 15 : URLRequestSimpleJob(request) {
15 } 16 }
16 17
17 // static 18 // static
18 URLRequestJob* URLRequestDataJob::Factory(URLRequest* request, 19 URLRequestJob* URLRequestDataJob::Factory(URLRequest* request,
19 const std::string& scheme) { 20 const std::string& scheme) {
20 return new URLRequestDataJob(request); 21 return new URLRequestDataJob(request);
21 } 22 }
22 23
23 bool URLRequestDataJob::GetData(std::string* mime_type, 24 int URLRequestDataJob::GetData(std::string* mime_type,
24 std::string* charset, 25 std::string* charset,
25 std::string* data) const { 26 std::string* data,
27 const CompletionCallback& callback) const {
26 // Check if data URL is valid. If not, don't bother to try to extract data. 28 // Check if data URL is valid. If not, don't bother to try to extract data.
27 // Otherwise, parse the data from the data URL. 29 // Otherwise, parse the data from the data URL.
28 const GURL& url = request_->url(); 30 const GURL& url = request_->url();
29 if (!url.is_valid()) 31 if (!url.is_valid())
30 return false; 32 return ERR_FAILED;
31 return DataURL::Parse(url, mime_type, charset, data); 33 return DataURL::Parse(url, mime_type, charset, data)? OK: ERR_FAILED;
32 } 34 }
33 35
34 URLRequestDataJob::~URLRequestDataJob() { 36 URLRequestDataJob::~URLRequestDataJob() {
35 } 37 }
36 38
37 } // namespace net 39 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698