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

Unified Diff: components/doodle/doodle_fetcher_impl.h

Issue 2707293002: [Doodle] Split DoodleFetcher into interface + Impl (Closed)
Patch Set: review Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/doodle/doodle_fetcher.cc ('k') | components/doodle/doodle_fetcher_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/doodle/doodle_fetcher_impl.h
diff --git a/components/doodle/doodle_fetcher.h b/components/doodle/doodle_fetcher_impl.h
similarity index 79%
copy from components/doodle/doodle_fetcher.h
copy to components/doodle/doodle_fetcher_impl.h
index 951bbad3913a5605fa4208b1b0c6e86c8805bd5c..82c9c3f885f62c9123fae806c9af5dc6631ae80b 100644
--- a/components/doodle/doodle_fetcher.h
+++ b/components/doodle/doodle_fetcher_impl.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef COMPONENTS_DOODLE_DOODLE_FETCHER_H_
-#define COMPONENTS_DOODLE_DOODLE_FETCHER_H_
+#ifndef COMPONENTS_DOODLE_DOODLE_FETCHER_IMPL_H_
+#define COMPONENTS_DOODLE_DOODLE_FETCHER_IMPL_H_
#include <memory>
#include <string>
@@ -15,6 +15,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
+#include "components/doodle/doodle_fetcher.h"
#include "components/doodle/doodle_types.h"
#include "net/url_request/url_fetcher_delegate.h"
#include "net/url_request/url_request_context_getter.h"
@@ -33,29 +34,25 @@ namespace doodle {
// This class provides information about any recent doodle.
// It works asynchronously and calls a callback when finished fetching the
// information from the remote enpoint.
-class DoodleFetcher : public net::URLFetcherDelegate {
+class DoodleFetcherImpl : public DoodleFetcher, public net::URLFetcherDelegate {
public:
- // Callback that is invoked when the fetching is done.
- // |doodle_config| will only contain a value if |state| is AVAILABLE.
- using FinishedCallback = base::OnceCallback<void(
- DoodleState state,
- const base::Optional<DoodleConfig>& doodle_config)>;
// Callback for JSON parsing to allow injecting platform-dependent code.
using ParseJSONCallback = base::Callback<void(
const std::string& unsafe_json,
const base::Callback<void(std::unique_ptr<base::Value> json)>& success,
const base::Callback<void(const std::string&)>& error)>;
- DoodleFetcher(scoped_refptr<net::URLRequestContextGetter> download_context,
- GoogleURLTracker* google_url_tracker,
- const ParseJSONCallback& json_parsing_callback);
- ~DoodleFetcher() override;
+ DoodleFetcherImpl(
+ scoped_refptr<net::URLRequestContextGetter> download_context,
+ GoogleURLTracker* google_url_tracker,
+ const ParseJSONCallback& json_parsing_callback);
+ ~DoodleFetcherImpl() override;
// Fetches a doodle asynchronously. The |callback| is called with a
// DoodleState indicating whether the request succeded in fetching a doodle.
// If a fetch is already running, the callback will be queued and invoked with
// result from the next completed request.
- void FetchDoodle(FinishedCallback callback);
+ void FetchDoodle(FinishedCallback callback) override;
// Overrides internal clock for testing purposes.
void SetClockForTesting(std::unique_ptr<base::Clock> clock) {
@@ -100,11 +97,11 @@ class DoodleFetcher : public net::URLFetcherDelegate {
std::vector<FinishedCallback> callbacks_;
std::unique_ptr<net::URLFetcher> fetcher_;
- base::WeakPtrFactory<DoodleFetcher> weak_ptr_factory_;
+ base::WeakPtrFactory<DoodleFetcherImpl> weak_ptr_factory_;
- DISALLOW_COPY_AND_ASSIGN(DoodleFetcher);
+ DISALLOW_COPY_AND_ASSIGN(DoodleFetcherImpl);
};
} // namespace doodle
-#endif // COMPONENTS_DOODLE_DOODLE_FETCHER_H_
+#endif // COMPONENTS_DOODLE_DOODLE_FETCHER_IMPL_H_
« no previous file with comments | « components/doodle/doodle_fetcher.cc ('k') | components/doodle/doodle_fetcher_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698