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

Unified Diff: components/suggestions/suggestions_service_impl.h

Issue 2568133005: [SuggestionsService] Split SuggestionsService interface from impl (Closed)
Patch Set: Moved impl to dedicated file. Created 4 years 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/suggestions/suggestions_service.cc ('k') | components/suggestions/suggestions_service_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/suggestions/suggestions_service_impl.h
diff --git a/components/suggestions/suggestions_service.h b/components/suggestions/suggestions_service_impl.h
similarity index 68%
copy from components/suggestions/suggestions_service.h
copy to components/suggestions/suggestions_service_impl.h
index 5b118e11d2a62c80503d63e46b964bf57d0ecd97..fe304719c37c9efc0d5d4b1792a635e609cf0fd5 100644
--- a/components/suggestions/suggestions_service.h
+++ b/components/suggestions/suggestions_service_impl.h
@@ -1,9 +1,9 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
+// Copyright 2016 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 COMPONENTS_SUGGESTIONS_SUGGESTIONS_SERVICE_H_
-#define COMPONENTS_SUGGESTIONS_SUGGESTIONS_SERVICE_H_
+#ifndef COMPONENTS_SUGGESTIONS_SUGGESTIONS_SERVICE_IMPL_H_
+#define COMPONENTS_SUGGESTIONS_SUGGESTIONS_SERVICE_IMPL_H_
#include <stdint.h>
@@ -15,11 +15,12 @@
#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
+#include "base/optional.h"
#include "base/scoped_observer.h"
#include "base/threading/thread_checker.h"
#include "base/time/time.h"
-#include "components/keyed_service/core/keyed_service.h"
#include "components/suggestions/proto/suggestions.pb.h"
+#include "components/suggestions/suggestions_service.h"
#include "components/sync/driver/sync_service_observer.h"
#include "net/url_request/url_fetcher_delegate.h"
#include "url/gurl.h"
@@ -27,10 +28,6 @@
class OAuth2TokenService;
class SigninManagerBase;
-namespace gfx {
-class Image;
-} // namespce gfx
-
namespace net {
class URLRequestContextGetter;
} // namespace net
@@ -49,59 +46,34 @@ class BlacklistStore;
class ImageManager;
class SuggestionsStore;
-// An interface to fetch server suggestions asynchronously.
-class SuggestionsService : public KeyedService,
- public net::URLFetcherDelegate,
- public syncer::SyncServiceObserver {
+// Actual (non-test) implementation of the SuggestionsService interface.
+class SuggestionsServiceImpl : public SuggestionsService,
+ public net::URLFetcherDelegate,
+ public syncer::SyncServiceObserver {
public:
- using ResponseCallback = base::Callback<void(const SuggestionsProfile&)>;
- using BitmapCallback = base::Callback<void(const GURL&, const gfx::Image&)>;
-
- using ResponseCallbackList =
- base::CallbackList<void(const SuggestionsProfile&)>;
-
- SuggestionsService(const SigninManagerBase* signin_manager,
- OAuth2TokenService* token_service,
- syncer::SyncService* sync_service,
- net::URLRequestContextGetter* url_request_context,
- std::unique_ptr<SuggestionsStore> suggestions_store,
- std::unique_ptr<ImageManager> thumbnail_manager,
- std::unique_ptr<BlacklistStore> blacklist_store);
- ~SuggestionsService() override;
-
- // Initiates a network request for suggestions if sync state allows and there
- // is no pending request. Returns true iff sync state allowed for a request,
- // whether a new request was actually sent or not.
- bool FetchSuggestionsData();
-
- // Returns the current set of suggestions from the cache.
- SuggestionsProfile GetSuggestionsDataFromCache() const;
-
- // Adds a callback that is called when the suggestions are updated.
+ SuggestionsServiceImpl(const SigninManagerBase* signin_manager,
+ OAuth2TokenService* token_service,
+ syncer::SyncService* sync_service,
+ net::URLRequestContextGetter* url_request_context,
+ std::unique_ptr<SuggestionsStore> suggestions_store,
+ std::unique_ptr<ImageManager> thumbnail_manager,
+ std::unique_ptr<BlacklistStore> blacklist_store);
+ ~SuggestionsServiceImpl() override;
+
+ // SuggestionsService implementation.
+ bool FetchSuggestionsData() override;
+ base::Optional<SuggestionsProfile> GetSuggestionsDataFromCache()
+ const override;
std::unique_ptr<ResponseCallbackList::Subscription> AddCallback(
- const ResponseCallback& callback) WARN_UNUSED_RESULT;
-
- // Retrieves stored thumbnail for website |url| asynchronously. Calls
- // |callback| with Bitmap pointer if found, and NULL otherwise.
- void GetPageThumbnail(const GURL& url, const BitmapCallback& callback);
-
- // A version of |GetPageThumbnail| that explicitly supplies the download URL
- // for the thumbnail. Replaces any pre-existing thumbnail URL with the
- // supplied one.
+ const ResponseCallback& callback) override WARN_UNUSED_RESULT;
+ void GetPageThumbnail(const GURL& url,
+ const BitmapCallback& callback) override;
void GetPageThumbnailWithURL(const GURL& url,
const GURL& thumbnail_url,
- const BitmapCallback& callback);
-
- // Adds a URL to the blacklist cache, returning true on success or false on
- // failure. The URL will eventually be uploaded to the server.
- bool BlacklistURL(const GURL& candidate_url);
-
- // Removes a URL from the local blacklist, returning true on success or false
- // on failure.
- bool UndoBlacklistURL(const GURL& url);
-
- // Removes all URLs from the blacklist.
- void ClearBlacklist();
+ const BitmapCallback& callback) override;
+ bool BlacklistURL(const GURL& candidate_url) override;
+ bool UndoBlacklistURL(const GURL& url) override;
+ void ClearBlacklist() override;
// Determines which URL a blacklist request was for, irrespective of the
// request's status. Returns false if |request| is not a blacklist request.
@@ -183,8 +155,7 @@ class SuggestionsService : public KeyedService,
// Test seams.
base::TimeDelta blacklist_delay() const { return scheduling_delay_; }
- void set_blacklist_delay(base::TimeDelta delay) {
- scheduling_delay_ = delay; }
+ void set_blacklist_delay(base::TimeDelta delay) { scheduling_delay_ = delay; }
base::ThreadChecker thread_checker_;
@@ -222,11 +193,11 @@ class SuggestionsService : public KeyedService,
ResponseCallbackList callback_list_;
// For callbacks may be run after destruction.
- base::WeakPtrFactory<SuggestionsService> weak_ptr_factory_;
+ base::WeakPtrFactory<SuggestionsServiceImpl> weak_ptr_factory_;
- DISALLOW_COPY_AND_ASSIGN(SuggestionsService);
+ DISALLOW_COPY_AND_ASSIGN(SuggestionsServiceImpl);
};
} // namespace suggestions
-#endif // COMPONENTS_SUGGESTIONS_SUGGESTIONS_SERVICE_H_
+#endif // COMPONENTS_SUGGESTIONS_SUGGESTIONS_SERVICE_IMPL_H_
« no previous file with comments | « components/suggestions/suggestions_service.cc ('k') | components/suggestions/suggestions_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698