Chromium Code Reviews| Index: chrome/browser/android/popular_sites.h |
| diff --git a/chrome/browser/android/popular_sites.h b/chrome/browser/android/popular_sites.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..937f463ef8012da0502a0546706ada7243820976 |
| --- /dev/null |
| +++ b/chrome/browser/android/popular_sites.h |
| @@ -0,0 +1,56 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_ANDROID_POPULAR_SITES_H_ |
| +#define CHROME_BROWSER_ANDROID_POPULAR_SITES_H_ |
| + |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/callback.h" |
| +#include "base/macros.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/memory/weak_ptr.h" |
| + |
| +namespace base { |
| +class FilePath; |
| +} |
| + |
| +namespace net { |
| +class URLRequestContextGetter; |
| +} |
| + |
| +class FileDownloader; |
| + |
| +class PopularSites { |
|
Bernhard Bauer
2015/08/03 17:04:51
Document this class?
Marc Treib
2015/08/04 08:16:42
Done.
|
| + public: |
| + struct Site { |
| + Site(const std::string& title, const std::string& url); |
| + |
| + std::string title; |
|
Bernhard Bauer
2015/08/03 17:04:51
Can this be a base::string16?
Marc Treib
2015/08/04 08:16:42
It could, but why? We're getting UTF8 from the jso
Bernhard Bauer
2015/08/04 08:30:02
It's a user-visible string, and we tend to store t
Marc Treib
2015/08/04 08:58:42
Alright, done.
|
| + std::string url; |
|
Bernhard Bauer
2015/08/03 17:04:51
And this a GURL?
Marc Treib
2015/08/04 08:16:42
Hm, yeah, I guess that makes for a somewhat cleane
|
| + }; |
| + |
| + using FinishedCallback = base::Callback<void(bool /* success */)>; |
| + |
| + PopularSites(net::URLRequestContextGetter* request_context, |
| + const FinishedCallback& callback); |
| + ~PopularSites(); |
| + |
| + const std::vector<Site>& sites() const { return sites_; } |
| + |
| + private: |
| + void OnDownloadDone(const base::FilePath& path, bool success); |
| + void OnJsonParsed(scoped_ptr<std::vector<Site>> sites); |
| + |
| + FinishedCallback callback_; |
| + scoped_ptr<FileDownloader> downloader_; |
| + std::vector<Site> sites_; |
| + |
| + base::WeakPtrFactory<PopularSites> weak_ptr_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PopularSites); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_ANDROID_POPULAR_SITES_H_ |