OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROME_BROWSER_EXTENSIONS_BLOB_READER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_BLOB_READER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_BLOB_READER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_BLOB_READER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
| 10 #include <memory> |
10 #include <string> | 11 #include <string> |
11 | 12 |
12 #include "base/callback.h" | 13 #include "base/callback.h" |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "base/memory/scoped_ptr.h" | |
15 #include "net/base/io_buffer.h" | 15 #include "net/base/io_buffer.h" |
16 #include "net/url_request/url_fetcher_delegate.h" | 16 #include "net/url_request/url_fetcher_delegate.h" |
17 #include "net/url_request/url_request.h" | 17 #include "net/url_request/url_request.h" |
18 #include "url/gurl.h" | 18 #include "url/gurl.h" |
19 | 19 |
20 class Profile; | 20 class Profile; |
21 namespace net { | 21 namespace net { |
22 class URLFetcher; | 22 class URLFetcher; |
23 } | 23 } |
24 | 24 |
25 // This class may only be used from the UI thread. | 25 // This class may only be used from the UI thread. |
26 class BlobReader : public net::URLFetcherDelegate { | 26 class BlobReader : public net::URLFetcherDelegate { |
27 public: | 27 public: |
28 // |blob_data| contains the portion of the Blob requested. |blob_total_size| | 28 // |blob_data| contains the portion of the Blob requested. |blob_total_size| |
29 // is the total size of the Blob, and may be larger than |blob_data->size()|. | 29 // is the total size of the Blob, and may be larger than |blob_data->size()|. |
30 // |blob_total_size| is -1 if it cannot be determined. | 30 // |blob_total_size| is -1 if it cannot be determined. |
31 typedef base::Callback<void(scoped_ptr<std::string> blob_data, | 31 typedef base::Callback<void(std::unique_ptr<std::string> blob_data, |
32 int64_t blob_total_size)> BlobReadCallback; | 32 int64_t blob_total_size)> |
| 33 BlobReadCallback; |
33 | 34 |
34 BlobReader(Profile* profile, | 35 BlobReader(Profile* profile, |
35 const std::string& blob_uuid, | 36 const std::string& blob_uuid, |
36 BlobReadCallback callback); | 37 BlobReadCallback callback); |
37 ~BlobReader() override; | 38 ~BlobReader() override; |
38 | 39 |
39 void SetByteRange(int64_t offset, int64_t length); | 40 void SetByteRange(int64_t offset, int64_t length); |
40 | 41 |
41 void Start(); | 42 void Start(); |
42 | 43 |
43 private: | 44 private: |
44 // Overridden from net::URLFetcherDelegate. | 45 // Overridden from net::URLFetcherDelegate. |
45 void OnURLFetchComplete(const net::URLFetcher* source) override; | 46 void OnURLFetchComplete(const net::URLFetcher* source) override; |
46 | 47 |
47 BlobReadCallback callback_; | 48 BlobReadCallback callback_; |
48 scoped_ptr<net::URLFetcher> fetcher_; | 49 std::unique_ptr<net::URLFetcher> fetcher_; |
49 | 50 |
50 DISALLOW_COPY_AND_ASSIGN(BlobReader); | 51 DISALLOW_COPY_AND_ASSIGN(BlobReader); |
51 }; | 52 }; |
52 | 53 |
53 #endif // CHROME_BROWSER_EXTENSIONS_BLOB_READER_H_ | 54 #endif // CHROME_BROWSER_EXTENSIONS_BLOB_READER_H_ |
OLD | NEW |