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

Side by Side Diff: chrome/browser/sync/profile_sync_service.cc

Issue 1128523002: Usage of ThreadTaskRunner in lieu of in [chrome/browser/sync],[components/sync_driver] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed Review Comments Created 5 years, 7 months 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 unified diff | Download patch
OLDNEW
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_tracker.h" 22 #include "base/profiler/scoped_tracker.h"
23 #include "base/strings/string16.h" 23 #include "base/strings/string16.h"
24 #include "base/strings/stringprintf.h" 24 #include "base/strings/stringprintf.h"
25 #include "base/thread_task_runner_handle.h"
25 #include "base/threading/thread_restrictions.h" 26 #include "base/threading/thread_restrictions.h"
26 #include "build/build_config.h" 27 #include "build/build_config.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"
32 #include "chrome/browser/net/chrome_cookie_notification_details.h" 33 #include "chrome/browser/net/chrome_cookie_notification_details.h"
33 #include "chrome/browser/password_manager/password_store_factory.h" 34 #include "chrome/browser/password_manager/password_store_factory.h"
34 #include "chrome/browser/prefs/chrome_pref_service_factory.h" 35 #include "chrome/browser/prefs/chrome_pref_service_factory.h"
(...skipping 2598 matching lines...) Expand 10 before | Expand all | Expand 10 after
2633 (last_synced_time.is_null() || 2634 (last_synced_time.is_null() ||
2634 base::Time::Now() - last_synced_time >= 2635 base::Time::Now() - last_synced_time >=
2635 base::TimeDelta::FromDays(1))) { 2636 base::TimeDelta::FromDays(1))) {
2636 // If sync thread is set, need to serialize check on sync thread after 2637 // If sync thread is set, need to serialize check on sync thread after
2637 // closing backup DB. 2638 // closing backup DB.
2638 if (sync_thread_) { 2639 if (sync_thread_) {
2639 sync_thread_->message_loop_proxy()->PostTask( 2640 sync_thread_->message_loop_proxy()->PostTask(
2640 FROM_HERE, 2641 FROM_HERE,
2641 base::Bind(syncer::CheckSyncDbLastModifiedTime, 2642 base::Bind(syncer::CheckSyncDbLastModifiedTime,
2642 profile_->GetPath().Append(kSyncBackupDataFolderName), 2643 profile_->GetPath().Append(kSyncBackupDataFolderName),
2643 base::MessageLoopProxy::current(), 2644 base::ThreadTaskRunnerHandle::Get(),
2644 base::Bind(&ProfileSyncService::CheckSyncBackupCallback, 2645 base::Bind(&ProfileSyncService::CheckSyncBackupCallback,
2645 weak_factory_.GetWeakPtr()))); 2646 weak_factory_.GetWeakPtr())));
2646 } else { 2647 } else {
2647 content::BrowserThread::PostTask( 2648 content::BrowserThread::PostTask(
2648 content::BrowserThread::FILE, FROM_HERE, 2649 content::BrowserThread::FILE, FROM_HERE,
2649 base::Bind(syncer::CheckSyncDbLastModifiedTime, 2650 base::Bind(syncer::CheckSyncDbLastModifiedTime,
2650 profile_->GetPath().Append(kSyncBackupDataFolderName), 2651 profile_->GetPath().Append(kSyncBackupDataFolderName),
2651 base::MessageLoopProxy::current(), 2652 base::ThreadTaskRunnerHandle::Get(),
2652 base::Bind(&ProfileSyncService::CheckSyncBackupCallback, 2653 base::Bind(&ProfileSyncService::CheckSyncBackupCallback,
2653 weak_factory_.GetWeakPtr()))); 2654 weak_factory_.GetWeakPtr())));
2654 } 2655 }
2655 } 2656 }
2656 #endif 2657 #endif
2657 } 2658 }
2658 2659
2659 void ProfileSyncService::CheckSyncBackupCallback(base::Time backup_time) { 2660 void ProfileSyncService::CheckSyncBackupCallback(base::Time backup_time) {
2660 last_backup_time_.reset(new base::Time(backup_time)); 2661 last_backup_time_.reset(new base::Time(backup_time));
2661 2662
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2712 std::string birthday; 2713 std::string birthday;
2713 syncer::UserShare* user_share = GetUserShare(); 2714 syncer::UserShare* user_share = GetUserShare();
2714 if (user_share && user_share->directory.get()) { 2715 if (user_share && user_share->directory.get()) {
2715 birthday = user_share->directory->store_birthday(); 2716 birthday = user_share->directory->store_birthday();
2716 } 2717 }
2717 if (!access_token_.empty() && !cache_guid.empty() && !birthday.empty()) { 2718 if (!access_token_.empty() && !cache_guid.empty() && !birthday.empty()) {
2718 sync_stopped_reporter_->ReportSyncStopped( 2719 sync_stopped_reporter_->ReportSyncStopped(
2719 access_token_, cache_guid, birthday); 2720 access_token_, cache_guid, birthday);
2720 } 2721 }
2721 } 2722 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698