OLD | NEW |
---|---|
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 #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 "base/strings/string_piece.h" | |
11 #include "net/base/completion_callback.h" | 12 #include "net/base/completion_callback.h" |
12 #include "net/base/net_export.h" | 13 #include "net/base/net_export.h" |
13 #include "net/url_request/url_range_request_job.h" | 14 #include "net/url_request/url_range_request_job.h" |
14 | 15 |
15 namespace net { | 16 namespace net { |
16 | 17 |
17 class URLRequest; | 18 class URLRequest; |
18 | 19 |
19 class NET_EXPORT URLRequestSimpleJob : public URLRangeRequestJob { | 20 class NET_EXPORT URLRequestSimpleJob : public URLRangeRequestJob { |
20 public: | 21 public: |
(...skipping 13 matching lines...) Expand all Loading... | |
34 // - ERR_IO_PENDING if async processing is needed to finish obtaining data. | 35 // - ERR_IO_PENDING if async processing is needed to finish obtaining data. |
35 // This is the only case when |callback| should be called after | 36 // This is the only case when |callback| should be called after |
36 // completion of the operation. In other situations |callback| should | 37 // completion of the operation. In other situations |callback| should |
37 // never be called; | 38 // never be called; |
38 // - any other ERR_* code to indicate an error. This code will be used | 39 // - any other ERR_* code to indicate an error. This code will be used |
39 // as the error code in the URLRequestStatus when the URLRequest | 40 // as the error code in the URLRequestStatus when the URLRequest |
40 // is finished. | 41 // is finished. |
41 virtual int GetData(std::string* mime_type, | 42 virtual int GetData(std::string* mime_type, |
42 std::string* charset, | 43 std::string* charset, |
43 std::string* data, | 44 std::string* data, |
44 const CompletionCallback& callback) const = 0; | 45 const CompletionCallback& callback) const; |
46 // Similar to GetData(), except the subclass must ensure that the characters | |
47 // referred to by *data live at least as long as *this. | |
48 virtual int GetStringPieceData(std::string* mime_type, | |
49 std::string* charset, | |
50 base::StringPiece* data, | |
51 const CompletionCallback& callback); | |
mmenke
2014/11/14 22:46:40
Could be instead take a base::RefCountedMemory? S
Jeffrey Yasskin
2014/11/15 02:34:20
Ah, that's definitely better; thanks! I'm inclined
| |
45 | 52 |
46 protected: | 53 protected: |
47 void StartAsync(); | 54 void StartAsync(); |
48 | 55 |
49 private: | 56 private: |
50 void OnGetDataCompleted(int result); | 57 void OnGetDataCompleted(int result); |
51 | 58 |
52 HttpByteRange byte_range_; | 59 HttpByteRange byte_range_; |
53 std::string mime_type_; | 60 std::string mime_type_; |
54 std::string charset_; | 61 std::string charset_; |
55 std::string data_; | 62 std::string data_storage_; |
63 base::StringPiece data_; | |
56 int data_offset_; | 64 int data_offset_; |
57 base::WeakPtrFactory<URLRequestSimpleJob> weak_factory_; | 65 base::WeakPtrFactory<URLRequestSimpleJob> weak_factory_; |
58 }; | 66 }; |
59 | 67 |
60 } // namespace net | 68 } // namespace net |
61 | 69 |
62 #endif // NET_URL_REQUEST_URL_REQUEST_SIMPLE_JOB_H_ | 70 #endif // NET_URL_REQUEST_URL_REQUEST_SIMPLE_JOB_H_ |
OLD | NEW |