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

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

Issue 2376123003: [Sync] Move //components/sync to the syncer namespace. (Closed)
Patch Set: Fix tools and iOS. Created 4 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_android.h" 5 #include "chrome/browser/sync/profile_sync_service_android.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <string>
11 #include <vector>
11 12
12 #include "base/android/jni_android.h" 13 #include "base/android/jni_android.h"
13 #include "base/android/jni_array.h" 14 #include "base/android/jni_array.h"
14 #include "base/android/jni_string.h" 15 #include "base/android/jni_string.h"
15 #include "base/bind.h" 16 #include "base/bind.h"
16 #include "base/i18n/time_formatting.h" 17 #include "base/i18n/time_formatting.h"
17 #include "base/json/json_writer.h" 18 #include "base/json/json_writer.h"
18 #include "base/logging.h" 19 #include "base/logging.h"
19 #include "base/memory/ptr_util.h" 20 #include "base/memory/ptr_util.h"
20 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 NOTREACHED() << "Browser process or profile manager not initialized"; 93 NOTREACHED() << "Browser process or profile manager not initialized";
93 return; 94 return;
94 } 95 }
95 96
96 profile_ = ProfileManager::GetActiveUserProfile(); 97 profile_ = ProfileManager::GetActiveUserProfile();
97 if (profile_ == nullptr) { 98 if (profile_ == nullptr) {
98 NOTREACHED() << "Sync Init: Profile not found."; 99 NOTREACHED() << "Sync Init: Profile not found.";
99 return; 100 return;
100 } 101 }
101 102
102 sync_prefs_.reset(new sync_driver::SyncPrefs(profile_->GetPrefs())); 103 sync_prefs_.reset(new syncer::SyncPrefs(profile_->GetPrefs()));
103 104
104 sync_service_ = 105 sync_service_ =
105 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_); 106 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_);
106 } 107 }
107 108
108 bool ProfileSyncServiceAndroid::Init() { 109 bool ProfileSyncServiceAndroid::Init() {
109 if (sync_service_) { 110 if (sync_service_) {
110 sync_service_->AddObserver(this); 111 sync_service_->AddObserver(this);
111 sync_service_->SetPlatformSyncAllowedProvider( 112 sync_service_->SetPlatformSyncAllowedProvider(
112 base::Bind(&ProfileSyncServiceAndroid::IsSyncAllowedByAndroid, 113 base::Bind(&ProfileSyncServiceAndroid::IsSyncAllowedByAndroid,
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 } 464 }
464 465
465 // Functionality only available for testing purposes. 466 // Functionality only available for testing purposes.
466 467
467 ScopedJavaLocalRef<jstring> ProfileSyncServiceAndroid::GetAboutInfoForTest( 468 ScopedJavaLocalRef<jstring> ProfileSyncServiceAndroid::GetAboutInfoForTest(
468 JNIEnv* env, 469 JNIEnv* env,
469 const JavaParamRef<jobject>&) { 470 const JavaParamRef<jobject>&) {
470 DCHECK_CURRENTLY_ON(BrowserThread::UI); 471 DCHECK_CURRENTLY_ON(BrowserThread::UI);
471 472
472 std::unique_ptr<base::DictionaryValue> about_info = 473 std::unique_ptr<base::DictionaryValue> about_info =
473 sync_driver::sync_ui_util::ConstructAboutInformation( 474 syncer::sync_ui_util::ConstructAboutInformation(
474 sync_service_, sync_service_->signin(), chrome::GetChannel()); 475 sync_service_, sync_service_->signin(), chrome::GetChannel());
475 std::string about_info_json; 476 std::string about_info_json;
476 base::JSONWriter::Write(*about_info, &about_info_json); 477 base::JSONWriter::Write(*about_info, &about_info_json);
477 478
478 return ConvertUTF8ToJavaString(env, about_info_json); 479 return ConvertUTF8ToJavaString(env, about_info_json);
479 } 480 }
480 481
481 jlong ProfileSyncServiceAndroid::GetLastSyncedTimeForTest( 482 jlong ProfileSyncServiceAndroid::GetLastSyncedTimeForTest(
482 JNIEnv* env, 483 JNIEnv* env,
483 const JavaParamRef<jobject>& obj) { 484 const JavaParamRef<jobject>& obj) {
484 // Use profile preferences here instead of SyncPrefs to avoid an extra 485 // Use profile preferences here instead of SyncPrefs to avoid an extra
485 // conversion, since SyncPrefs::GetLastSyncedTime() converts the stored value 486 // conversion, since SyncPrefs::GetLastSyncedTime() converts the stored value
486 // to to base::Time. 487 // to to base::Time.
487 return static_cast<jlong>( 488 return static_cast<jlong>(
488 profile_->GetPrefs()->GetInt64(sync_driver::prefs::kSyncLastSyncedTime)); 489 profile_->GetPrefs()->GetInt64(syncer::prefs::kSyncLastSyncedTime));
489 } 490 }
490 491
491 void ProfileSyncServiceAndroid::OverrideNetworkResourcesForTest( 492 void ProfileSyncServiceAndroid::OverrideNetworkResourcesForTest(
492 JNIEnv* env, 493 JNIEnv* env,
493 const JavaParamRef<jobject>& obj, 494 const JavaParamRef<jobject>& obj,
494 jlong network_resources) { 495 jlong network_resources) {
495 syncer::NetworkResources* resources = 496 syncer::NetworkResources* resources =
496 reinterpret_cast<syncer::NetworkResources*>(network_resources); 497 reinterpret_cast<syncer::NetworkResources*>(network_resources);
497 sync_service_->OverrideNetworkResourcesForTest( 498 sync_service_->OverrideNetworkResourcesForTest(
498 base::WrapUnique<syncer::NetworkResources>(resources)); 499 base::WrapUnique<syncer::NetworkResources>(resources));
(...skipping 15 matching lines...) Expand all
514 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { 515 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) {
515 ProfileSyncServiceAndroid* profile_sync_service_android = 516 ProfileSyncServiceAndroid* profile_sync_service_android =
516 new ProfileSyncServiceAndroid(env, obj); 517 new ProfileSyncServiceAndroid(env, obj);
517 if (profile_sync_service_android->Init()) { 518 if (profile_sync_service_android->Init()) {
518 return reinterpret_cast<intptr_t>(profile_sync_service_android); 519 return reinterpret_cast<intptr_t>(profile_sync_service_android);
519 } else { 520 } else {
520 delete profile_sync_service_android; 521 delete profile_sync_service_android;
521 return 0; 522 return 0;
522 } 523 }
523 } 524 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698