| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef CHROME_BROWSER_ANDROID_NTP_POPULAR_SITES_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_NTP_POPULAR_SITES_H_ |
| 6 #define CHROME_BROWSER_ANDROID_NTP_POPULAR_SITES_H_ | 6 #define CHROME_BROWSER_ANDROID_NTP_POPULAR_SITES_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
| 17 #include "net/url_request/url_fetcher_delegate.h" | 17 #include "net/url_request/url_fetcher_delegate.h" |
| 18 #include "url/gurl.h" | 18 #include "url/gurl.h" |
| 19 | 19 |
| 20 namespace base { |
| 21 class Value; |
| 22 } |
| 23 |
| 20 namespace net { | 24 namespace net { |
| 21 class URLRequestContextGetter; | 25 class URLRequestContextGetter; |
| 22 } | 26 } |
| 23 | 27 |
| 24 namespace user_prefs { | 28 namespace user_prefs { |
| 25 class PrefRegistrySyncable; | 29 class PrefRegistrySyncable; |
| 26 } | 30 } |
| 27 | 31 |
| 28 namespace variations { | 32 namespace variations { |
| 29 class VariationsService; | 33 class VariationsService; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 std::unique_ptr<std::string> data, | 127 std::unique_ptr<std::string> data, |
| 124 bool success); | 128 bool success); |
| 125 | 129 |
| 126 // Fetch the popular sites at the given URL, overwriting any file that already | 130 // Fetch the popular sites at the given URL, overwriting any file that already |
| 127 // exists. | 131 // exists. |
| 128 void FetchPopularSites(const GURL& url); | 132 void FetchPopularSites(const GURL& url); |
| 129 | 133 |
| 130 // net::URLFetcherDelegate implementation. | 134 // net::URLFetcherDelegate implementation. |
| 131 void OnURLFetchComplete(const net::URLFetcher* source) override; | 135 void OnURLFetchComplete(const net::URLFetcher* source) override; |
| 132 | 136 |
| 133 void OnJsonSanitized(const std::string& valid_minified_json); | 137 void OnJsonParsed(bool write_to_file, std::unique_ptr<base::Value> json); |
| 134 void OnJsonSanitizationFailed(const std::string& error_message); | 138 void OnJsonParseFailed(const std::string& error_message); |
| 135 void OnFileWriteDone(const std::string& json, bool success); | 139 void OnFileWriteDone(std::unique_ptr<base::Value> json, bool success); |
| 136 void ParseSiteList(const std::string& json); | 140 void ParseSiteList(std::unique_ptr<base::Value> json); |
| 137 void OnJsonParsed(std::unique_ptr<std::vector<Site>> sites); | 141 void OnJsonUnmarshaled(std::unique_ptr<std::vector<Site>> sites); |
| 138 void OnDownloadFailed(); | 142 void OnDownloadFailed(); |
| 139 | 143 |
| 140 FinishedCallback callback_; | 144 FinishedCallback callback_; |
| 141 std::unique_ptr<net::URLFetcher> fetcher_; | 145 std::unique_ptr<net::URLFetcher> fetcher_; |
| 142 bool is_fallback_; | 146 bool is_fallback_; |
| 143 std::vector<Site> sites_; | 147 std::vector<Site> sites_; |
| 144 std::string pending_country_; | 148 std::string pending_country_; |
| 145 std::string pending_version_; | 149 std::string pending_version_; |
| 146 | 150 |
| 147 base::FilePath local_path_; | 151 base::FilePath local_path_; |
| 148 | 152 |
| 149 PrefService* prefs_; | 153 PrefService* prefs_; |
| 150 net::URLRequestContextGetter* download_context_; | 154 net::URLRequestContextGetter* download_context_; |
| 151 | 155 |
| 152 scoped_refptr<base::TaskRunner> blocking_runner_; | 156 scoped_refptr<base::TaskRunner> blocking_runner_; |
| 153 | 157 |
| 154 base::WeakPtrFactory<PopularSites> weak_ptr_factory_; | 158 base::WeakPtrFactory<PopularSites> weak_ptr_factory_; |
| 155 | 159 |
| 156 DISALLOW_COPY_AND_ASSIGN(PopularSites); | 160 DISALLOW_COPY_AND_ASSIGN(PopularSites); |
| 157 }; | 161 }; |
| 158 | 162 |
| 159 #endif // CHROME_BROWSER_ANDROID_NTP_POPULAR_SITES_H_ | 163 #endif // CHROME_BROWSER_ANDROID_NTP_POPULAR_SITES_H_ |
| OLD | NEW |