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

Unified Diff: chrome/browser/metrics/metrics_service.cc

Issue 10917198: Switch NOTIFICATION_TAB_PARENTED to use WebContents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/metrics/metrics_service.h ('k') | chrome/browser/sessions/session_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/metrics/metrics_service.cc
diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc
index 4ce7d7d459d62720c260b71f9de0ae61cc32073b..8dc8dcff1087d123df9423b12dd2bcdc4e8283a6 100644
--- a/chrome/browser/metrics/metrics_service.cc
+++ b/chrome/browser/metrics/metrics_service.cc
@@ -197,6 +197,7 @@
#include "content/public/browser/plugin_service.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/user_metrics.h"
+#include "content/public/browser/web_contents.h"
#include "net/base/load_flags.h"
#include "net/url_request/url_fetcher.h"
#include "webkit/plugins/webplugininfo.h"
@@ -679,14 +680,26 @@ void MetricsService::Observe(int type,
break;
case chrome::NOTIFICATION_BROWSER_OPENED:
- case chrome::NOTIFICATION_BROWSER_CLOSED:
- LogWindowChange(type, source, details);
+ case chrome::NOTIFICATION_BROWSER_CLOSED: {
+ Browser* browser = content::Source<Browser>(source).ptr();
+ LogWindowOrTabChange(type, reinterpret_cast<uintptr_t>(browser));
break;
+ }
- case chrome::NOTIFICATION_TAB_PARENTED:
- case chrome::NOTIFICATION_TAB_CLOSING:
- LogWindowChange(type, source, details);
+ case chrome::NOTIFICATION_TAB_PARENTED: {
+ content::WebContents* web_contents =
+ content::Source<content::WebContents>(source).ptr();
+ LogWindowOrTabChange(type, reinterpret_cast<uintptr_t>(web_contents));
break;
+ }
+
+ case chrome::NOTIFICATION_TAB_CLOSING: {
+ content::NavigationController* controller =
+ content::Source<content::NavigationController>(source).ptr();
+ content::WebContents* web_contents = controller->GetWebContents();
+ LogWindowOrTabChange(type, reinterpret_cast<uintptr_t>(web_contents));
+ break;
+ }
case content::NOTIFICATION_LOAD_STOP:
LogLoadComplete(type, source, details);
@@ -1518,12 +1531,8 @@ void MetricsService::OnURLFetchComplete(const net::URLFetcher* source) {
}
}
-void MetricsService::LogWindowChange(
- int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
+void MetricsService::LogWindowOrTabChange(int type, uintptr_t window_or_tab) {
int controller_id = -1;
- uintptr_t window_or_tab = source.map_key();
MetricsLog::WindowEventType window_type;
// Note: since we stop all logging when a single OTR session is active, it is
« no previous file with comments | « chrome/browser/metrics/metrics_service.h ('k') | chrome/browser/sessions/session_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698