Adding instrumentation to locate the source of jankiness
[chromium-blink-merge.git] / chrome / browser / enhanced_bookmarks / chrome_bookmark_server_cluster_service.cc
blob8f1540deadcc474b0fe9f89a4bfa0c63d57720c8
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/enhanced_bookmarks/chrome_bookmark_server_cluster_service.h"
7 #include "chrome/browser/sync/profile_sync_service.h"
8 #include "components/enhanced_bookmarks/enhanced_bookmark_model.h"
10 namespace enhanced_bookmarks {
12 ChromeBookmarkServerClusterService::ChromeBookmarkServerClusterService(
13 const std::string& application_language_code,
14 scoped_refptr<net::URLRequestContextGetter> request_context_getter,
15 ProfileOAuth2TokenService* token_service,
16 SigninManagerBase* signin_manager,
17 EnhancedBookmarkModel* enhanced_bookmark_model,
18 PrefService* pref_service,
19 ProfileSyncService* sync_service)
20 : BookmarkServerClusterService(application_language_code,
21 request_context_getter,
22 token_service,
23 signin_manager,
24 enhanced_bookmark_model,
25 pref_service),
26 sync_service_(sync_service) {
27 if (sync_service_)
28 sync_service_->AddObserver(this);
31 ChromeBookmarkServerClusterService::~ChromeBookmarkServerClusterService() {
32 if (sync_service_)
33 sync_service_->RemoveObserver(this);
36 void ChromeBookmarkServerClusterService::OnStateChanged() {
37 // Do nothing.
40 void ChromeBookmarkServerClusterService::OnSyncCycleCompleted() {
41 // The stars cluster API relies on the information in chrome-sync. Sending a
42 // cluster request immediately after a bookmark is changed from the bookmark
43 // observer notification will yield the wrong results. The request must be
44 // delayed until the sync cycle has completed.
45 // TODO(noyau): This might happen too often, need a way to coalesce and delay
46 // the notifications.
47 if (model_->loaded())
48 TriggerTokenRequest(false);
51 } // namespace enhanced_bookmarks