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

Side by Side Diff: components/ntp_snippets/ntp_snippets_fetcher_unittest.cc

Issue 2257793002: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 3 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/ntp_snippets/ntp_snippets_fetcher.h" 5 #include "components/ntp_snippets/ntp_snippets_fetcher.h"
6 6
7 #include <map> 7 #include <map>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 104
105 MOCK_METHOD1(Run, void(NTPSnippetsFetcher::OptionalSnippets* snippets)); 105 MOCK_METHOD1(Run, void(NTPSnippetsFetcher::OptionalSnippets* snippets));
106 }; 106 };
107 107
108 // Factory for FakeURLFetcher objects that always generate errors. 108 // Factory for FakeURLFetcher objects that always generate errors.
109 class FailingFakeURLFetcherFactory : public net::URLFetcherFactory { 109 class FailingFakeURLFetcherFactory : public net::URLFetcherFactory {
110 public: 110 public:
111 std::unique_ptr<net::URLFetcher> CreateURLFetcher( 111 std::unique_ptr<net::URLFetcher> CreateURLFetcher(
112 int id, const GURL& url, net::URLFetcher::RequestType request_type, 112 int id, const GURL& url, net::URLFetcher::RequestType request_type,
113 net::URLFetcherDelegate* d) override { 113 net::URLFetcherDelegate* d) override {
114 return base::WrapUnique(new net::FakeURLFetcher( 114 return base::MakeUnique<net::FakeURLFetcher>(
115 url, d, /*response_data=*/std::string(), net::HTTP_NOT_FOUND, 115 url, d, /*response_data=*/std::string(), net::HTTP_NOT_FOUND,
116 net::URLRequestStatus::FAILED)); 116 net::URLRequestStatus::FAILED);
117 } 117 }
118 }; 118 };
119 119
120 void ParseJson( 120 void ParseJson(
121 const std::string& json, 121 const std::string& json,
122 const ntp_snippets::NTPSnippetsFetcher::SuccessCallback& success_callback, 122 const ntp_snippets::NTPSnippetsFetcher::SuccessCallback& success_callback,
123 const ntp_snippets::NTPSnippetsFetcher::ErrorCallback& error_callback) { 123 const ntp_snippets::NTPSnippetsFetcher::ErrorCallback& error_callback) {
124 base::JSONReader json_reader; 124 base::JSONReader json_reader;
125 std::unique_ptr<base::Value> value = json_reader.ReadToValue(json); 125 std::unique_ptr<base::Value> value = json_reader.ReadToValue(json);
126 if (value) 126 if (value)
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 if (snippets) { 805 if (snippets) {
806 // Matchers above aren't any more precise than this, so this is sufficient 806 // Matchers above aren't any more precise than this, so this is sufficient
807 // for test-failure diagnostics. 807 // for test-failure diagnostics.
808 return os << "list with " << snippets->size() << " elements"; 808 return os << "list with " << snippets->size() << " elements";
809 } else { 809 } else {
810 return os << "null"; 810 return os << "null";
811 } 811 }
812 } 812 }
813 813
814 } // namespace ntp_snippets 814 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « components/ntp_snippets/ntp_snippets_database.cc ('k') | components/precache/core/precache_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698