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

Side by Side Diff: net/url_request/url_request_simple_job.h

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
« no previous file with comments | « net/url_request/url_request_data_job.cc ('k') | net/url_request/url_request_simple_job.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef NET_URL_REQUEST_URL_REQUEST_SIMPLE_JOB_H_ 5 #ifndef NET_URL_REQUEST_URL_REQUEST_SIMPLE_JOB_H_
6 #define NET_URL_REQUEST_URL_REQUEST_SIMPLE_JOB_H_ 6 #define NET_URL_REQUEST_URL_REQUEST_SIMPLE_JOB_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "net/base/completion_callback.h"
11 #include "net/base/net_export.h" 12 #include "net/base/net_export.h"
12 #include "net/url_request/url_request_job.h" 13 #include "net/url_request/url_request_job.h"
13 14
14 namespace net { 15 namespace net {
15 16
16 class URLRequest; 17 class URLRequest;
17 18
18 class NET_EXPORT URLRequestSimpleJob : public URLRequestJob { 19 class NET_EXPORT URLRequestSimpleJob : public URLRequestJob {
19 public: 20 public:
20 explicit URLRequestSimpleJob(URLRequest* request); 21 explicit URLRequestSimpleJob(URLRequest* request);
21 22
22 virtual void Start() OVERRIDE; 23 virtual void Start() OVERRIDE;
23 virtual bool ReadRawData(IOBuffer* buf, 24 virtual bool ReadRawData(IOBuffer* buf,
24 int buf_size, 25 int buf_size,
25 int *bytes_read) OVERRIDE; 26 int *bytes_read) OVERRIDE;
26 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; 27 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE;
27 virtual bool GetCharset(std::string* charset) OVERRIDE; 28 virtual bool GetCharset(std::string* charset) OVERRIDE;
28 29
29 protected: 30 protected:
30 virtual ~URLRequestSimpleJob(); 31 virtual ~URLRequestSimpleJob();
31 32
32 // subclasses must override the way response data is determined. 33 // Subclasses must override the way response data is determined.
33 virtual bool GetData(std::string* mime_type, 34 // The return value should be:
34 std::string* charset, 35 // - OK if data is obtained;
35 std::string* data) const = 0; 36 // - ERR_IO_PENDING if async processing is needed to finish obtaining data.
37 // This is the only case when |callback| should be called after
38 // completion of the operation. In other situations |callback| should
39 // never be called;
40 // - any other ERR_* code to indicate an error. This code will be used
41 // as the error code in the URLRequestStatus when the URLRequest
42 // is finished.
43 virtual int GetData(std::string* mime_type,
44 std::string* charset,
45 std::string* data,
46 const CompletionCallback& callback) const = 0;
36 47
37 protected: 48 protected:
38 void StartAsync(); 49 void StartAsync();
39 50
40 private: 51 private:
52 void OnGetDataCompleted(int result);
53
41 std::string mime_type_; 54 std::string mime_type_;
42 std::string charset_; 55 std::string charset_;
43 std::string data_; 56 std::string data_;
44 int data_offset_; 57 int data_offset_;
45 base::WeakPtrFactory<URLRequestSimpleJob> weak_factory_; 58 base::WeakPtrFactory<URLRequestSimpleJob> weak_factory_;
46 }; 59 };
47 60
48 } // namespace net 61 } // namespace net
49 62
50 #endif // NET_URL_REQUEST_URL_REQUEST_SIMPLE_JOB_H_ 63 #endif // NET_URL_REQUEST_URL_REQUEST_SIMPLE_JOB_H_
OLDNEW
« no previous file with comments | « net/url_request/url_request_data_job.cc ('k') | net/url_request/url_request_simple_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698