| OLD | NEW |
| 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/android/most_visited_sites.h" | 5 #include "chrome/browser/android/most_visited_sites.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 // Register this class as an observer to the sync service. It is important to | 202 // Register this class as an observer to the sync service. It is important to |
| 203 // be notified of changes in the sync state such as initialization, sync | 203 // be notified of changes in the sync state such as initialization, sync |
| 204 // being enabled or disabled, etc. | 204 // being enabled or disabled, etc. |
| 205 ProfileSyncService* profile_sync_service = | 205 ProfileSyncService* profile_sync_service = |
| 206 ProfileSyncServiceFactory::GetForProfile(profile_); | 206 ProfileSyncServiceFactory::GetForProfile(profile_); |
| 207 if (profile_sync_service) | 207 if (profile_sync_service) |
| 208 profile_sync_service->AddObserver(this); | 208 profile_sync_service->AddObserver(this); |
| 209 } | 209 } |
| 210 | 210 |
| 211 MostVisitedSites::~MostVisitedSites() { | 211 MostVisitedSites::~MostVisitedSites() { |
| 212 ProfileSyncService* profile_sync_service = |
| 213 ProfileSyncServiceFactory::GetForProfile(profile_); |
| 214 if (profile_sync_service && profile_sync_service->HasObserver(this)) |
| 215 profile_sync_service->RemoveObserver(this); |
| 212 } | 216 } |
| 213 | 217 |
| 214 void MostVisitedSites::Destroy(JNIEnv* env, jobject obj) { | 218 void MostVisitedSites::Destroy(JNIEnv* env, jobject obj) { |
| 215 delete this; | 219 delete this; |
| 216 } | 220 } |
| 217 | 221 |
| 218 void MostVisitedSites::OnLoadingComplete(JNIEnv* env, jobject obj) { | 222 void MostVisitedSites::OnLoadingComplete(JNIEnv* env, jobject obj) { |
| 219 RecordUMAMetrics(); | 223 RecordUMAMetrics(); |
| 220 } | 224 } |
| 221 | 225 |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 num_empty_thumbs_ = 0; | 516 num_empty_thumbs_ = 0; |
| 513 UMA_HISTOGRAM_SPARSE_SLOWLY(kNumServerTilesHistogramName, num_server_thumbs_); | 517 UMA_HISTOGRAM_SPARSE_SLOWLY(kNumServerTilesHistogramName, num_server_thumbs_); |
| 514 num_server_thumbs_ = 0; | 518 num_server_thumbs_ = 0; |
| 515 } | 519 } |
| 516 | 520 |
| 517 static jlong Init(JNIEnv* env, jobject obj, jobject jprofile) { | 521 static jlong Init(JNIEnv* env, jobject obj, jobject jprofile) { |
| 518 MostVisitedSites* most_visited_sites = | 522 MostVisitedSites* most_visited_sites = |
| 519 new MostVisitedSites(ProfileAndroid::FromProfileAndroid(jprofile)); | 523 new MostVisitedSites(ProfileAndroid::FromProfileAndroid(jprofile)); |
| 520 return reinterpret_cast<intptr_t>(most_visited_sites); | 524 return reinterpret_cast<intptr_t>(most_visited_sites); |
| 521 } | 525 } |
| OLD | NEW |