| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_UI_ASH_APP_SYNC_UI_STATE_H_ | 5 #ifndef CHROME_BROWSER_UI_ASH_APP_SYNC_UI_STATE_H_ |
| 6 #define CHROME_BROWSER_UI_ASH_APP_SYNC_UI_STATE_H_ | 6 #define CHROME_BROWSER_UI_ASH_APP_SYNC_UI_STATE_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 namespace extensions { | 25 namespace extensions { |
| 26 class ExtensionRegistry; | 26 class ExtensionRegistry; |
| 27 } // namespace extensions | 27 } // namespace extensions |
| 28 | 28 |
| 29 // AppSyncUIState watches app sync and installation and change its state | 29 // AppSyncUIState watches app sync and installation and change its state |
| 30 // accordingly. Its status is for UI display only. It only watches for new | 30 // accordingly. Its status is for UI display only. It only watches for new |
| 31 // normal user profile (i.e. it does not watch for guest profile or exsiting | 31 // normal user profile (i.e. it does not watch for guest profile or exsiting |
| 32 // user profile) and lasts for at the most 1 minute. | 32 // user profile) and lasts for at the most 1 minute. |
| 33 class AppSyncUIState : public KeyedService, | 33 class AppSyncUIState : public KeyedService, |
| 34 public sync_driver::SyncServiceObserver, | 34 public syncer::SyncServiceObserver, |
| 35 public extensions::ExtensionRegistryObserver { | 35 public extensions::ExtensionRegistryObserver { |
| 36 public: | 36 public: |
| 37 enum Status { | 37 enum Status { |
| 38 STATUS_NORMAL, | 38 STATUS_NORMAL, |
| 39 STATUS_SYNCING, // Syncing apps or installing synced apps. | 39 STATUS_SYNCING, // Syncing apps or installing synced apps. |
| 40 STATUS_TIMED_OUT, // Timed out when waiting for sync to finish. | 40 STATUS_TIMED_OUT, // Timed out when waiting for sync to finish. |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 // Returns the instance for the given |profile|. It's a convenience wrapper | 43 // Returns the instance for the given |profile|. It's a convenience wrapper |
| 44 // of AppSyncUIStateFactory::GetForProfile. Note this function returns | 44 // of AppSyncUIStateFactory::GetForProfile. Note this function returns |
| (...skipping 18 matching lines...) Expand all Loading... |
| 63 void SetStatus(Status status); | 63 void SetStatus(Status status); |
| 64 | 64 |
| 65 // Checks and sets app sync status. If sync has not setup, do nothing. If sync | 65 // Checks and sets app sync status. If sync has not setup, do nothing. If sync |
| 66 // is completed and there is no pending synced extension install, sets | 66 // is completed and there is no pending synced extension install, sets |
| 67 // STATUS_SYNCING. Otherwise, sets STATUS_NORMAL. | 67 // STATUS_SYNCING. Otherwise, sets STATUS_NORMAL. |
| 68 void CheckAppSync(); | 68 void CheckAppSync(); |
| 69 | 69 |
| 70 // Invoked when |max_syncing_status_timer_| fires. | 70 // Invoked when |max_syncing_status_timer_| fires. |
| 71 void OnMaxSyncingTimer(); | 71 void OnMaxSyncingTimer(); |
| 72 | 72 |
| 73 // sync_driver::SyncServiceObserver overrides: | 73 // syncer::SyncServiceObserver overrides: |
| 74 void OnStateChanged() override; | 74 void OnStateChanged() override; |
| 75 | 75 |
| 76 // extensions::ExtensionRegistryObserver overrides: | 76 // extensions::ExtensionRegistryObserver overrides: |
| 77 void OnExtensionLoaded(content::BrowserContext* browser_context, | 77 void OnExtensionLoaded(content::BrowserContext* browser_context, |
| 78 const extensions::Extension* extension) override; | 78 const extensions::Extension* extension) override; |
| 79 | 79 |
| 80 Profile* profile_; | 80 Profile* profile_; |
| 81 browser_sync::ProfileSyncService* sync_service_; | 81 browser_sync::ProfileSyncService* sync_service_; |
| 82 | 82 |
| 83 // Timer to limit how much time STATUS_SYNCING is allowed. | 83 // Timer to limit how much time STATUS_SYNCING is allowed. |
| 84 base::OneShotTimer max_syncing_status_timer_; | 84 base::OneShotTimer max_syncing_status_timer_; |
| 85 | 85 |
| 86 Status status_; | 86 Status status_; |
| 87 base::ObserverList<AppSyncUIStateObserver> observers_; | 87 base::ObserverList<AppSyncUIStateObserver> observers_; |
| 88 | 88 |
| 89 extensions::ExtensionRegistry* extension_registry_; | 89 extensions::ExtensionRegistry* extension_registry_; |
| 90 | 90 |
| 91 DISALLOW_COPY_AND_ASSIGN(AppSyncUIState); | 91 DISALLOW_COPY_AND_ASSIGN(AppSyncUIState); |
| 92 }; | 92 }; |
| 93 | 93 |
| 94 #endif // CHROME_BROWSER_UI_ASH_APP_SYNC_UI_STATE_H_ | 94 #endif // CHROME_BROWSER_UI_ASH_APP_SYNC_UI_STATE_H_ |
| OLD | NEW |