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

Side by Side Diff: chrome/browser/search/hotword_service.cc

Issue 2067183003: Use WeakPtr in HotwordService Constructor to ensure that invokes to InitializeMicrophoneObserver ca… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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/search/hotword_service.h" 5 #include "chrome/browser/search/hotword_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 user_manager::UserManager::Get()->AddSessionStateObserver( 395 user_manager::UserManager::Get()->AddSessionStateObserver(
396 session_observer_.get()); 396 session_observer_.get());
397 } 397 }
398 #endif 398 #endif
399 399
400 // Register with the device observer list to update the microphone 400 // Register with the device observer list to update the microphone
401 // availability. 401 // availability.
402 content::BrowserThread::PostTask( 402 content::BrowserThread::PostTask(
403 content::BrowserThread::UI, FROM_HERE, 403 content::BrowserThread::UI, FROM_HERE,
404 base::Bind(&HotwordService::InitializeMicrophoneObserver, 404 base::Bind(&HotwordService::InitializeMicrophoneObserver,
405 base::Unretained(this))); 405 weak_factory_.GetWeakPtr()));
406 } 406 }
407 407
408 HotwordService::~HotwordService() { 408 HotwordService::~HotwordService() {
409 #if defined(OS_CHROMEOS) 409 #if defined(OS_CHROMEOS)
410 if (user_manager::UserManager::IsInitialized() && session_observer_) { 410 if (user_manager::UserManager::IsInitialized() && session_observer_) {
411 user_manager::UserManager::Get()->RemoveSessionStateObserver( 411 user_manager::UserManager::Get()->RemoveSessionStateObserver(
412 session_observer_.get()); 412 session_observer_.get());
413 } 413 }
414 #endif 414 #endif
415 } 415 }
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 // Only support multiple profiles and profile switching in ChromeOS. 875 // Only support multiple profiles and profile switching in ChromeOS.
876 if (user_manager::UserManager::IsInitialized()) { 876 if (user_manager::UserManager::IsInitialized()) {
877 user_manager::User* user = 877 user_manager::User* user =
878 user_manager::UserManager::Get()->GetActiveUser(); 878 user_manager::UserManager::Get()->GetActiveUser();
879 if (user && user->is_profile_created()) 879 if (user && user->is_profile_created())
880 return profile_ == ProfileManager::GetActiveUserProfile(); 880 return profile_ == ProfileManager::GetActiveUserProfile();
881 } 881 }
882 #endif 882 #endif
883 return true; 883 return true;
884 } 884 }
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