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

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

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header Created 4 years, 8 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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_data_fetcher.h" 5 #include "chrome/browser/extensions/webstore_data_fetcher.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 net::LOAD_DISABLE_CACHE); 48 net::LOAD_DISABLE_CACHE);
49 if (max_auto_retries_ > 0) { 49 if (max_auto_retries_ > 0) {
50 webstore_data_url_fetcher_->SetMaxRetriesOn5xx(max_auto_retries_); 50 webstore_data_url_fetcher_->SetMaxRetriesOn5xx(max_auto_retries_);
51 webstore_data_url_fetcher_->SetAutomaticallyRetryOnNetworkChanges( 51 webstore_data_url_fetcher_->SetAutomaticallyRetryOnNetworkChanges(
52 max_auto_retries_); 52 max_auto_retries_);
53 } 53 }
54 webstore_data_url_fetcher_->Start(); 54 webstore_data_url_fetcher_->Start();
55 } 55 }
56 56
57 void WebstoreDataFetcher::OnJsonParseSuccess( 57 void WebstoreDataFetcher::OnJsonParseSuccess(
58 scoped_ptr<base::Value> parsed_json) { 58 std::unique_ptr<base::Value> parsed_json) {
59 if (!parsed_json->IsType(base::Value::TYPE_DICTIONARY)) { 59 if (!parsed_json->IsType(base::Value::TYPE_DICTIONARY)) {
60 OnJsonParseFailure(kInvalidWebstoreResponseError); 60 OnJsonParseFailure(kInvalidWebstoreResponseError);
61 return; 61 return;
62 } 62 }
63 63
64 delegate_->OnWebstoreResponseParseSuccess(scoped_ptr<base::DictionaryValue>( 64 delegate_->OnWebstoreResponseParseSuccess(
65 static_cast<base::DictionaryValue*>(parsed_json.release()))); 65 std::unique_ptr<base::DictionaryValue>(
66 static_cast<base::DictionaryValue*>(parsed_json.release())));
66 } 67 }
67 68
68 void WebstoreDataFetcher::OnJsonParseFailure( 69 void WebstoreDataFetcher::OnJsonParseFailure(
69 const std::string& error) { 70 const std::string& error) {
70 delegate_->OnWebstoreResponseParseFailure(error); 71 delegate_->OnWebstoreResponseParseFailure(error);
71 } 72 }
72 73
73 void WebstoreDataFetcher::OnURLFetchComplete(const net::URLFetcher* source) { 74 void WebstoreDataFetcher::OnURLFetchComplete(const net::URLFetcher* source) {
74 CHECK_EQ(webstore_data_url_fetcher_.get(), source); 75 CHECK_EQ(webstore_data_url_fetcher_.get(), source);
75 76
76 scoped_ptr<net::URLFetcher> fetcher(std::move(webstore_data_url_fetcher_)); 77 std::unique_ptr<net::URLFetcher> fetcher(
78 std::move(webstore_data_url_fetcher_));
77 79
78 if (!fetcher->GetStatus().is_success() || 80 if (!fetcher->GetStatus().is_success() ||
79 fetcher->GetResponseCode() != 200) { 81 fetcher->GetResponseCode() != 200) {
80 delegate_->OnWebstoreRequestFailure(); 82 delegate_->OnWebstoreRequestFailure();
81 return; 83 return;
82 } 84 }
83 85
84 std::string webstore_json_data; 86 std::string webstore_json_data;
85 fetcher->GetResponseAsString(&webstore_json_data); 87 fetcher->GetResponseAsString(&webstore_json_data);
86 88
87 // The parser will call us back via one of the callbacks. 89 // The parser will call us back via one of the callbacks.
88 safe_json::SafeJsonParser::Parse( 90 safe_json::SafeJsonParser::Parse(
89 webstore_json_data, 91 webstore_json_data,
90 base::Bind(&WebstoreDataFetcher::OnJsonParseSuccess, AsWeakPtr()), 92 base::Bind(&WebstoreDataFetcher::OnJsonParseSuccess, AsWeakPtr()),
91 base::Bind(&WebstoreDataFetcher::OnJsonParseFailure, AsWeakPtr())); 93 base::Bind(&WebstoreDataFetcher::OnJsonParseFailure, AsWeakPtr()));
92 } 94 }
93 95
94 } // namespace extensions 96 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/webstore_data_fetcher.h ('k') | chrome/browser/extensions/webstore_data_fetcher_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698