Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(359)

Side by Side Diff: chrome/browser/extensions/webstore_install_helper.cc

Issue 8375039: Create a content::UrlFetcher interface that lives in content/public/common and convert users to i... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: review comments Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/webstore_install_helper.h" 5 #include "chrome/browser/extensions/webstore_install_helper.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 icon_decode_complete_ = true; 46 icon_decode_complete_ = true;
47 47
48 BrowserThread::PostTask( 48 BrowserThread::PostTask(
49 BrowserThread::IO, 49 BrowserThread::IO,
50 FROM_HERE, 50 FROM_HERE,
51 base::Bind(&WebstoreInstallHelper::StartWorkOnIOThread, this)); 51 base::Bind(&WebstoreInstallHelper::StartWorkOnIOThread, this));
52 52
53 if (!icon_url_.is_empty()) { 53 if (!icon_url_.is_empty()) {
54 CHECK(context_getter_); 54 CHECK(context_getter_);
55 url_fetcher_.reset(new URLFetcher(icon_url_, URLFetcher::GET, this)); 55 url_fetcher_.reset(new URLFetcher(icon_url_, URLFetcher::GET, this));
56 url_fetcher_->set_request_context(context_getter_); 56 url_fetcher_->SetRequestContext(context_getter_);
57 57
58 url_fetcher_->Start(); 58 url_fetcher_->Start();
59 // We'll get called back in OnURLFetchComplete. 59 // We'll get called back in OnURLFetchComplete.
60 } 60 }
61 } 61 }
62 62
63 void WebstoreInstallHelper::StartWorkOnIOThread() { 63 void WebstoreInstallHelper::StartWorkOnIOThread() {
64 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 64 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
65 utility_host_ = new UtilityProcessHost(this, BrowserThread::IO); 65 utility_host_ = new UtilityProcessHost(this, BrowserThread::IO);
66 utility_host_->StartBatchMode(); 66 utility_host_->StartBatchMode();
67 67
68 if (!icon_base64_data_.empty()) 68 if (!icon_base64_data_.empty())
69 utility_host_->Send( 69 utility_host_->Send(
70 new ChromeUtilityMsg_DecodeImageBase64(icon_base64_data_)); 70 new ChromeUtilityMsg_DecodeImageBase64(icon_base64_data_));
71 71
72 utility_host_->Send(new ChromeUtilityMsg_ParseJSON(manifest_)); 72 utility_host_->Send(new ChromeUtilityMsg_ParseJSON(manifest_));
73 } 73 }
74 74
75 void WebstoreInstallHelper::OnURLFetchComplete(const URLFetcher* source) { 75 void WebstoreInstallHelper::OnURLFetchComplete(
76 const content::URLFetcher* source) {
76 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 77 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
77 CHECK(source == url_fetcher_.get()); 78 CHECK(source == url_fetcher_.get());
78 if (source->status().status() != net::URLRequestStatus::SUCCESS || 79 if (source->GetStatus().status() != net::URLRequestStatus::SUCCESS ||
79 source->response_code() != 200) { 80 source->GetResponseCode() != 200) {
80 BrowserThread::PostTask( 81 BrowserThread::PostTask(
81 BrowserThread::IO, 82 BrowserThread::IO,
82 FROM_HERE, 83 FROM_HERE,
83 base::Bind(&WebstoreInstallHelper::OnDecodeImageFailed, this)); 84 base::Bind(&WebstoreInstallHelper::OnDecodeImageFailed, this));
84 } else { 85 } else {
85 std::string response_data; 86 std::string response_data;
86 source->GetResponseAsString(&response_data); 87 source->GetResponseAsString(&response_data);
87 fetched_icon_data_.insert(fetched_icon_data_.begin(), 88 fetched_icon_data_.insert(fetched_icon_data_.begin(),
88 response_data.begin(), 89 response_data.begin(),
89 response_data.end()); 90 response_data.end());
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 base::Bind(&WebstoreInstallHelper::ReportResultFromUIThread, this)); 175 base::Bind(&WebstoreInstallHelper::ReportResultFromUIThread, this));
175 } 176 }
176 177
177 void WebstoreInstallHelper::ReportResultFromUIThread() { 178 void WebstoreInstallHelper::ReportResultFromUIThread() {
178 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 179 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
179 if (error_.empty() && parsed_manifest_.get()) 180 if (error_.empty() && parsed_manifest_.get())
180 delegate_->OnWebstoreParseSuccess(icon_, parsed_manifest_.release()); 181 delegate_->OnWebstoreParseSuccess(icon_, parsed_manifest_.release());
181 else 182 else
182 delegate_->OnWebstoreParseFailure(parse_error_, error_); 183 delegate_->OnWebstoreParseFailure(parse_error_, error_);
183 } 184 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/webstore_install_helper.h ('k') | chrome/browser/google/google_url_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698