| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 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 profile_(profile), |
| 18 weak_ptr_factory_(this) { |
| 19 fetcher_ = net::URLFetcher::Create( |
| 20 blob_url, net::URLFetcher::GET, |
| 21 this); |
| 22 fetcher_->SetRequestContext(profile->GetRequestContext()); |
| 23 } |
| 24 |
| 25 BlobReader::~BlobReader() { |
| 26 } |
| 27 |
| 28 void BlobReader::Start() { |
| 29 fetcher_->Start(); |
| 30 } |
| 31 |
| 32 // Overridden from net::URLFetcherDelegate. |
| 33 void BlobReader::OnURLFetchComplete(const net::URLFetcher* source) { |
| 34 scoped_ptr<std::string> response(new std::string); |
| 35 source->GetResponseAsString(response.get()); |
| 36 callback_.Run(response.Pass()); |
| 37 |
| 38 delete this; |
| 39 } |
| OLD | NEW |