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

Side by Side Diff: chrome/browser/android/most_visited_sites.cc

Issue 501973004: [Sync] Fix a crash when sign into sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698