| 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 #include "chrome/browser/sync/profile_sync_service.h" | 5 #include "chrome/browser/sync/profile_sync_service.h" |
| 6 | 6 |
| 7 #include <cstddef> | 7 #include <cstddef> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
| 17 #include "base/files/file_util.h" | 17 #include "base/files/file_util.h" |
| 18 #include "base/logging.h" | 18 #include "base/logging.h" |
| 19 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
| 20 #include "base/message_loop/message_loop.h" | 20 #include "base/message_loop/message_loop.h" |
| 21 #include "base/metrics/histogram.h" | 21 #include "base/metrics/histogram.h" |
| 22 #include "base/profiler/scoped_profile.h" |
| 22 #include "base/strings/string16.h" | 23 #include "base/strings/string16.h" |
| 23 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
| 24 #include "base/threading/thread_restrictions.h" | 25 #include "base/threading/thread_restrictions.h" |
| 25 #include "build/build_config.h" | 26 #include "build/build_config.h" |
| 26 #include "chrome/browser/bookmarks/enhanced_bookmarks_features.h" | 27 #include "chrome/browser/bookmarks/enhanced_bookmarks_features.h" |
| 27 #include "chrome/browser/browser_process.h" | 28 #include "chrome/browser/browser_process.h" |
| 28 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 29 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 29 #include "chrome/browser/chrome_notification_types.h" | 30 #include "chrome/browser/chrome_notification_types.h" |
| 30 #include "chrome/browser/defaults.h" | 31 #include "chrome/browser/defaults.h" |
| 31 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" | 32 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 LOG(ERROR) << "Unexpected persistent error: " << error.ToString(); | 749 LOG(ERROR) << "Unexpected persistent error: " << error.ToString(); |
| 749 } | 750 } |
| 750 // Show error to user. | 751 // Show error to user. |
| 751 UpdateAuthErrorState(error); | 752 UpdateAuthErrorState(error); |
| 752 } | 753 } |
| 753 } | 754 } |
| 754 } | 755 } |
| 755 | 756 |
| 756 void ProfileSyncService::OnRefreshTokenAvailable( | 757 void ProfileSyncService::OnRefreshTokenAvailable( |
| 757 const std::string& account_id) { | 758 const std::string& account_id) { |
| 759 // TODO(vadimt): Remove ScopedProfile below once crbug.com/422460 is fixed. |
| 760 tracked_objects::ScopedProfile tracking_profile( |
| 761 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 762 "422460 ProfileSyncService::OnRefreshTokenAvailable")); |
| 763 |
| 758 if (account_id == signin_->GetAccountIdToUse()) | 764 if (account_id == signin_->GetAccountIdToUse()) |
| 759 OnRefreshTokensLoaded(); | 765 OnRefreshTokensLoaded(); |
| 760 } | 766 } |
| 761 | 767 |
| 762 void ProfileSyncService::OnRefreshTokenRevoked( | 768 void ProfileSyncService::OnRefreshTokenRevoked( |
| 763 const std::string& account_id) { | 769 const std::string& account_id) { |
| 764 if (!IsOAuthRefreshTokenAvailable()) { | 770 if (!IsOAuthRefreshTokenAvailable()) { |
| 765 access_token_.clear(); | 771 access_token_.clear(); |
| 766 // The additional check around IsOAuthRefreshTokenAvailable() above | 772 // The additional check around IsOAuthRefreshTokenAvailable() above |
| 767 // prevents us sounding the alarm if we actually have a valid token but | 773 // prevents us sounding the alarm if we actually have a valid token but |
| (...skipping 1942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2710 base::Time ProfileSyncService::GetDeviceBackupTimeForTesting() const { | 2716 base::Time ProfileSyncService::GetDeviceBackupTimeForTesting() const { |
| 2711 return device_info_sync_service_->GetLocalDeviceBackupTime(); | 2717 return device_info_sync_service_->GetLocalDeviceBackupTime(); |
| 2712 } | 2718 } |
| 2713 | 2719 |
| 2714 void ProfileSyncService::FlushDirectory() const { | 2720 void ProfileSyncService::FlushDirectory() const { |
| 2715 // backend_initialized_ implies backend_ isn't NULL and the manager exists. | 2721 // backend_initialized_ implies backend_ isn't NULL and the manager exists. |
| 2716 // If sync is not initialized yet, we fail silently. | 2722 // If sync is not initialized yet, we fail silently. |
| 2717 if (backend_initialized_) | 2723 if (backend_initialized_) |
| 2718 backend_->FlushDirectory(); | 2724 backend_->FlushDirectory(); |
| 2719 } | 2725 } |
| OLD | NEW |