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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_EXTENSIONS_BLOB_READER_H_
6 #define CHROME_BROWSER_EXTENSIONS_BLOB_READER_H_
10 #include "base/callback.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "net/base/io_buffer.h"
13 #include "net/url_request/url_fetcher_delegate.h"
14 #include "net/url_request/url_request.h"
22 // This class may only be used from the UI thread.
23 class BlobReader
: public net::URLFetcherDelegate
{
25 // |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()|.
27 // |blob_total_size| is -1 if it cannot be determined.
28 typedef base::Callback
<void(scoped_ptr
<std::string
> blob_data
,
29 int64 blob_total_size
)>
32 BlobReader(Profile
* profile
,
33 const std::string
& blob_uuid
,
34 BlobReadCallback callback
);
35 ~BlobReader() override
;
37 void SetByteRange(int64 offset
, int64 length
);
42 // Overridden from net::URLFetcherDelegate.
43 void OnURLFetchComplete(const net::URLFetcher
* source
) override
;
45 BlobReadCallback callback_
;
46 scoped_ptr
<net::URLFetcher
> fetcher_
;
48 DISALLOW_COPY_AND_ASSIGN(BlobReader
);
51 #endif // CHROME_BROWSER_EXTENSIONS_BLOB_READER_H_