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