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

Side by Side Diff: chrome/browser/metrics/thread_watcher.cc

Issue 1282473002: Remove listening of OMNIBOX_OPENED_URL from metrics code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 (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/metrics/thread_watcher.h" 5 #include "chrome/browser/metrics/thread_watcher.h"
6 6
7 #include <math.h> // ceil 7 #include <math.h> // ceil
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 content::NotificationService::AllSources()); 681 content::NotificationService::AllSources());
682 observer->registrar_.Add(observer, 682 observer->registrar_.Add(observer,
683 content::NOTIFICATION_LOAD_STOP, 683 content::NOTIFICATION_LOAD_STOP,
684 content::NotificationService::AllSources()); 684 content::NotificationService::AllSources());
685 observer->registrar_.Add(observer, 685 observer->registrar_.Add(observer,
686 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, 686 content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
687 content::NotificationService::AllSources()); 687 content::NotificationService::AllSources());
688 observer->registrar_.Add(observer, 688 observer->registrar_.Add(observer,
689 content::NOTIFICATION_RENDER_WIDGET_HOST_HANG, 689 content::NOTIFICATION_RENDER_WIDGET_HOST_HANG,
690 content::NotificationService::AllSources()); 690 content::NotificationService::AllSources());
691 observer->registrar_.Add(observer, 691 observer->omnibox_url_opened_subscription_ =
692 chrome::NOTIFICATION_OMNIBOX_OPENED_URL, 692 OmniboxEventGlobalTracker::GetInstance()->RegisterCallback(
693 content::NotificationService::AllSources()); 693 base::Bind(&ThreadWatcherObserver::OnURLOpenedFromOmnibox,
694 base::Unretained(observer)));
694 } 695 }
695 696
696 // static 697 // static
697 void ThreadWatcherObserver::RemoveNotifications() { 698 void ThreadWatcherObserver::RemoveNotifications() {
698 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 699 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
699 if (!g_thread_watcher_observer_) 700 if (!g_thread_watcher_observer_)
700 return; 701 return;
701 g_thread_watcher_observer_->registrar_.RemoveAll(); 702 g_thread_watcher_observer_->registrar_.RemoveAll();
702 delete g_thread_watcher_observer_; 703 delete g_thread_watcher_observer_;
703 } 704 }
704 705
705 void ThreadWatcherObserver::Observe( 706 void ThreadWatcherObserver::Observe(
706 int type, 707 int type,
707 const content::NotificationSource& source, 708 const content::NotificationSource& source,
708 const content::NotificationDetails& details) { 709 const content::NotificationDetails& details) {
710 OnUserActivityDetected();
711 }
712
713 void ThreadWatcherObserver::OnURLOpenedFromOmnibox(OmniboxLog* log) {
714 OnUserActivityDetected();
715 }
Alexei Svitkine (slow) 2015/08/07 14:57:37 Nit: Add an empty line after this.
blundell 2015/08/17 09:24:01 Done.
716 void ThreadWatcherObserver::OnUserActivityDetected() {
709 // There is some user activity, see if thread watchers are to be awakened. 717 // There is some user activity, see if thread watchers are to be awakened.
710 base::TimeTicks now = base::TimeTicks::Now(); 718 base::TimeTicks now = base::TimeTicks::Now();
711 if ((now - last_wakeup_time_) < wakeup_interval_) 719 if ((now - last_wakeup_time_) < wakeup_interval_)
712 return; 720 return;
713 last_wakeup_time_ = now; 721 last_wakeup_time_ = now;
714 WatchDogThread::PostTask( 722 WatchDogThread::PostTask(
715 FROM_HERE, 723 FROM_HERE,
716 base::Bind(&ThreadWatcherList::WakeUpAll)); 724 base::Bind(&ThreadWatcherList::WakeUpAll));
717 } 725 }
718 726
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 938
931 #if defined(OS_WIN) 939 #if defined(OS_WIN)
932 // On Windows XP, give twice the time for shutdown. 940 // On Windows XP, give twice the time for shutdown.
933 if (base::win::GetVersion() <= base::win::VERSION_XP) 941 if (base::win::GetVersion() <= base::win::VERSION_XP)
934 actual_duration *= 2; 942 actual_duration *= 2;
935 #endif 943 #endif
936 944
937 shutdown_watchdog_ = new ShutdownWatchDogThread(actual_duration); 945 shutdown_watchdog_ = new ShutdownWatchDogThread(actual_duration);
938 shutdown_watchdog_->Arm(); 946 shutdown_watchdog_->Arm();
939 } 947 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698