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. 4 5 #ifndef CHROME_BROWSER_EXTENSIONS_BLOB_READER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_BLOB_READER_H_ 7 8 #include <string> 9 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" 15 #include "url/gurl.h" 16 17 class Profile; 18 namespace net { 19 class URLFetcher; 20 } 21 22 class BlobReader : public net::URLFetcherDelegate { 23 public: 24 typedef base::Callback<void(scoped_ptr<std::string> blob_data)> 25 BlobReadCallback; 26 27 BlobReader(Profile* profile, 28 const std::string& blob_uuid, 29 BlobReadCallback callback); 30 virtual ~BlobReader(); 31 32 void SetByteRange(int64 offset, int64 length); 33 34 void Start(); 35 36 private: 37 // Overridden from net::URLFetcherDelegate. 38 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; 39 40 BlobReadCallback callback_; 41 scoped_ptr<net::URLFetcher> fetcher_; 42 43 DISALLOW_COPY_AND_ASSIGN(BlobReader); 44 }; 45 46 #endif // CHROME_BROWSER_EXTENSIONS_BLOB_READER_H_ 47