Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #include "chrome/browser/enhanced_bookmarks/chrome_bookmark_server_cluster_servi ce.h" | 5 #include "chrome/browser/enhanced_bookmarks/chrome_bookmark_server_cluster_servi ce.h" |
| 6 | 6 |
| 7 #include "chrome/browser/sync/profile_sync_service.h" | 7 #include "chrome/browser/sync/profile_sync_service.h" |
| 8 #include "components/enhanced_bookmarks/enhanced_bookmark_model.h" | 8 #include "components/enhanced_bookmarks/enhanced_bookmark_model.h" |
| 9 | 9 |
| 10 namespace enhanced_bookmarks { | 10 namespace enhanced_bookmarks { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 sync_service_(sync_service) { | 26 sync_service_(sync_service) { |
| 27 if (sync_service_) | 27 if (sync_service_) |
| 28 sync_service_->AddObserver(this); | 28 sync_service_->AddObserver(this); |
| 29 } | 29 } |
| 30 | 30 |
| 31 ChromeBookmarkServerClusterService::~ChromeBookmarkServerClusterService() { | 31 ChromeBookmarkServerClusterService::~ChromeBookmarkServerClusterService() { |
| 32 if (sync_service_) | 32 if (sync_service_) |
| 33 sync_service_->RemoveObserver(this); | 33 sync_service_->RemoveObserver(this); |
| 34 } | 34 } |
| 35 | 35 |
| 36 void ChromeBookmarkServerClusterService::AddObserver( | |
| 37 BookmarkServerServiceObserver* observer) { | |
| 38 BookmarkServerClusterService::AddObserver(observer); | |
| 39 if (sync_refresh_skipped_) { | |
| 40 sync_refresh_skipped_ = false; | |
| 41 TriggerTokenRequest(false); | |
| 42 } | |
| 43 } | |
| 44 | |
| 36 void ChromeBookmarkServerClusterService::OnStateChanged() { | 45 void ChromeBookmarkServerClusterService::OnStateChanged() { |
| 37 // Do nothing. | 46 // Do nothing. |
| 38 } | 47 } |
| 39 | 48 |
| 40 void ChromeBookmarkServerClusterService::OnSyncCycleCompleted() { | 49 void ChromeBookmarkServerClusterService::OnSyncCycleCompleted() { |
|
danduong
2014/10/20 21:05:20
I guess my real concern with this is that we'll ch
Kibeom Kim (inactive)
2014/10/21 00:40:33
discussed offline, and we decided to just comment
| |
| 41 // The stars cluster API relies on the information in chrome-sync. Sending a | 50 // 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 | 51 // cluster request immediately after a bookmark is changed from the bookmark |
| 43 // observer notification will yield the wrong results. The request must be | 52 // observer notification will yield the wrong results. The request must be |
| 44 // delayed until the sync cycle has completed. | 53 // delayed until the sync cycle has completed. |
| 45 // TODO(noyau): This might happen too often, need a way to coalesce and delay | 54 if (model_->loaded()) { |
| 46 // the notifications. | 55 if (observers_.might_have_observers()) { |
| 47 if (model_->loaded()) | 56 TriggerTokenRequest(false); |
| 48 TriggerTokenRequest(false); | 57 sync_refresh_skipped_ = false; |
| 58 } else { | |
| 59 sync_refresh_skipped_ = true; | |
| 60 } | |
| 61 } | |
| 49 } | 62 } |
| 50 | 63 |
| 51 } // namespace enhanced_bookmarks | 64 } // namespace enhanced_bookmarks |
| OLD | NEW |