Home | History | Annotate | Download | only in feedback_private
      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 #include "chrome/browser/extensions/api/feedback_private/blob_reader.h"
      6 
      7 #include "chrome/browser/profiles/profile.h"
      8 #include "content/public/browser/browser_thread.h"
      9 #include "net/url_request/url_fetcher.h"
     10 #include "net/url_request/url_request_context.h"
     11 #include "net/url_request/url_request_context_getter.h"
     12 
     13 BlobReader::BlobReader(Profile* profile,
     14                        const GURL& blob_url,
     15                        BlobReadCallback callback)
     16     : callback_(callback) {
     17   fetcher_ = net::URLFetcher::Create(
     18       blob_url, net::URLFetcher::GET,
     19       this);
     20   fetcher_->SetRequestContext(profile->GetRequestContext());
     21 }
     22 
     23 BlobReader::~BlobReader() {
     24 }
     25 
     26 void BlobReader::Start() {
     27   fetcher_->Start();
     28 }
     29 
     30 // Overridden from net::URLFetcherDelegate.
     31 void BlobReader::OnURLFetchComplete(const net::URLFetcher* source) {
     32   scoped_ptr<std::string> response(new std::string);
     33   source->GetResponseAsString(response.get());
     34   callback_.Run(response.Pass());
     35 
     36   delete this;
     37 }
     38