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

Unified Diff: chrome/browser/android/vr_shell/vr_usage_monitor.h

Issue 2572013003: Remove unnecessary threading concerns from VrMetricsHelper. (Closed)
Patch Set: Created 4 years 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/android/vr_shell/vr_shell.cc ('k') | chrome/browser/android/vr_shell/vr_usage_monitor.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/vr_shell/vr_usage_monitor.h
diff --git a/chrome/browser/android/vr_shell/vr_usage_monitor.h b/chrome/browser/android/vr_shell/vr_usage_monitor.h
index 7e1c6e2941e7b624212a9e1c583a3d4591895d7a..594f34841f07235fb3327585e4050f6857269520 100644
--- a/chrome/browser/android/vr_shell/vr_usage_monitor.h
+++ b/chrome/browser/android/vr_shell/vr_usage_monitor.h
@@ -5,7 +5,9 @@
#ifndef CHROME_BROWSER_ANDROID_VR_SHELL_VR_USAGE_MONITOR_H_
#define CHROME_BROWSER_ANDROID_VR_SHELL_VR_USAGE_MONITOR_H_
-#include "base/threading/platform_thread.h"
+#include <memory>
+
+#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/web_contents.h"
@@ -51,21 +53,15 @@ class SessionTimer {
DISALLOW_COPY_AND_ASSIGN(SessionTimer);
};
-// Most methods of this class are not threadsafe - they must be called
-// on the Browser's main thread. This happens by default except for
-// SetWebVREnabled and SetVRActive, where we'll post a message to get to the
-// correct thread.
-// Destruction must happen on the main thread, or there could be corruption when
-// WebContentsObserver unregisters itself from the web_contents_.
-// There are DCHECKS to ensure these threading rules are satisfied.
-class VrMetricsHelper : public content::WebContentsObserver,
- public base::RefCountedThreadSafe<VrMetricsHelper> {
+// This class is not threadsafe and must only be used from the main thread.
+class VrMetricsHelper : public content::WebContentsObserver {
public:
explicit VrMetricsHelper(content::WebContents*);
-
+ ~VrMetricsHelper() override;
void SetWebVREnabled(bool is_webvr_presenting);
void SetVRActive(bool is_vr_enabled);
+ private:
// WebContentObserver
void MediaStartedPlaying(const MediaPlayerInfo& media_info,
const MediaPlayerId&) override;
@@ -75,13 +71,6 @@ class VrMetricsHelper : public content::WebContentsObserver,
void DidToggleFullscreenModeForTab(bool entered_fullscreen,
bool will_cause_resize) override;
- protected:
- friend class base::RefCountedThreadSafe<VrMetricsHelper>;
- ~VrMetricsHelper() override;
-
- void SetWebVREnabledOnMainThread(bool is_webvr_presenting);
- void SetVRActiveOnMainThread(bool is_vr_enabled);
-
void SetVrMode(VRMode mode);
void UpdateMode();
@@ -102,9 +91,6 @@ class VrMetricsHelper : public content::WebContentsObserver,
int num_session_video_playback_ = 0;
GURL origin_;
-
- // not thread safe, so ensure we are on the same thread at all times:
- base::PlatformThreadId thread_id_;
};
} // namespace vr_shell
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell.cc ('k') | chrome/browser/android/vr_shell/vr_usage_monitor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698