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 class BlobReader
: public net::URLFetcherDelegate
{
24 // |blob_data| contains the portion of the Blob requested. |blob_total_size|
25 // is the total size of the Blob, and may be larger than |blob_data->size()|.
26 // |blob_total_size| is -1 if it cannot be determined.
27 typedef base::Callback
<void(scoped_ptr
<std::string
> blob_data
,
28 int64 blob_total_size
)>
31 BlobReader(Profile
* profile
,
32 const std::string
& blob_uuid
,
33 BlobReadCallback callback
);
34 virtual ~BlobReader();
36 void SetByteRange(int64 offset
, int64 length
);
41 // Overridden from net::URLFetcherDelegate.
42 virtual void OnURLFetchComplete(const net::URLFetcher
* source
) OVERRIDE
;
44 BlobReadCallback callback_
;
45 scoped_ptr
<net::URLFetcher
> fetcher_
;
47 DISALLOW_COPY_AND_ASSIGN(BlobReader
);
50 #endif // CHROME_BROWSER_EXTENSIONS_BLOB_READER_H_