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_harness.h" | 5 #include "chrome/browser/sync/profile_sync_service_harness.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <ostream> | 9 #include <ostream> |
10 #include <set> | 10 #include <set> |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 waiting_for_status_change_(false) { | 114 waiting_for_status_change_(false) { |
115 if (IsSyncAlreadySetup()) { | 115 if (IsSyncAlreadySetup()) { |
116 service_ = ProfileSyncServiceFactory::GetInstance()->GetForProfile( | 116 service_ = ProfileSyncServiceFactory::GetInstance()->GetForProfile( |
117 profile_); | 117 profile_); |
118 service_->AddObserver(this); | 118 service_->AddObserver(this); |
119 ignore_result(TryListeningToMigrationEvents()); | 119 ignore_result(TryListeningToMigrationEvents()); |
120 wait_state_ = FULLY_SYNCED; | 120 wait_state_ = FULLY_SYNCED; |
121 } | 121 } |
122 } | 122 } |
123 | 123 |
124 ProfileSyncServiceHarness::~ProfileSyncServiceHarness() {} | 124 ProfileSyncServiceHarness::~ProfileSyncServiceHarness() { |
| 125 if (service_->HasObserver(this)) |
| 126 service_->RemoveObserver(this); |
| 127 } |
125 | 128 |
126 // static | 129 // static |
127 ProfileSyncServiceHarness* ProfileSyncServiceHarness::CreateAndAttach( | 130 ProfileSyncServiceHarness* ProfileSyncServiceHarness::CreateAndAttach( |
128 Profile* profile) { | 131 Profile* profile) { |
129 ProfileSyncServiceFactory* f = ProfileSyncServiceFactory::GetInstance(); | 132 ProfileSyncServiceFactory* f = ProfileSyncServiceFactory::GetInstance(); |
130 if (!f->HasProfileSyncService(profile)) { | 133 if (!f->HasProfileSyncService(profile)) { |
131 NOTREACHED() << "Profile has never signed into sync."; | 134 NOTREACHED() << "Profile has never signed into sync."; |
132 return NULL; | 135 return NULL; |
133 } | 136 } |
134 return new ProfileSyncServiceHarness(profile, "", ""); | 137 return new ProfileSyncServiceHarness(profile, "", ""); |
(...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1122 | 1125 |
1123 std::string ProfileSyncServiceHarness::GetServiceStatus() { | 1126 std::string ProfileSyncServiceHarness::GetServiceStatus() { |
1124 scoped_ptr<DictionaryValue> value( | 1127 scoped_ptr<DictionaryValue> value( |
1125 sync_ui_util::ConstructAboutInformation(service_)); | 1128 sync_ui_util::ConstructAboutInformation(service_)); |
1126 std::string service_status; | 1129 std::string service_status; |
1127 base::JSONWriter::WriteWithOptions(value.get(), | 1130 base::JSONWriter::WriteWithOptions(value.get(), |
1128 base::JSONWriter::OPTIONS_PRETTY_PRINT, | 1131 base::JSONWriter::OPTIONS_PRETTY_PRINT, |
1129 &service_status); | 1132 &service_status); |
1130 return service_status; | 1133 return service_status; |
1131 } | 1134 } |
OLD | NEW |