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

Unified Diff: content/browser/media/capture/web_contents_tracker.h

Issue 1135823004: Implement all resolution change policies for desktop and tab capture. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@resolution_change_policy_constraints_ITEM1_CR1
Patch Set: Addressed Wez's second round comments. Created 5 years, 7 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
Index: content/browser/media/capture/web_contents_tracker.h
diff --git a/content/browser/media/capture/web_contents_tracker.h b/content/browser/media/capture/web_contents_tracker.h
index 613c971d44531c1d47aa3d7c125357e59cea21d7..0130272e492d06ba399a7bf4f6b16ff2df06cbff 100644
--- a/content/browser/media/capture/web_contents_tracker.h
+++ b/content/browser/media/capture/web_contents_tracker.h
@@ -42,6 +42,10 @@ class CONTENT_EXPORT WebContentsTracker
// Callback to indicate a new RenderWidgetHost should be targeted for capture.
// This is also invoked with NULL to indicate tracking will not continue
// (i.e., the WebContents instance was not found or has been destroyed).
+ //
+ // WARNING: It is only safe to dereference |rwh| on the UI BrowserThread, and
+ // only if the Start() method was called on the UI BrowserThread. Otherwise,
+ // this pointer could be invalid at the time the callback is run.
Wez 2015/05/15 00:55:42 This warning makes ThreadingKitty sad. >.<
miu 2015/05/15 21:14:01 Acknowledged.
typedef base::Callback<void(RenderWidgetHost* rwh)> ChangeCallback;
// Start tracking. The last-known |render_process_id| and
@@ -59,6 +63,12 @@ class CONTENT_EXPORT WebContentsTracker
// Current target. This must only be called on the UI BrowserThread.
RenderWidgetHost* GetTargetRenderWidgetHost() const;
+ // Set a callback that is run whenever the main frame of the WebContents is
+ // resized. This method must be called on the same thread that calls
+ // Start()/Stop(), and |callback| will be run on that same thread. Calling
+ // the Stop() method guarantees the callback will never be invoked again.
+ void SetResizeChangeCallback(const ChangeCallback& callback);
+
protected:
friend class base::RefCountedThreadSafe<WebContentsTracker>;
~WebContentsTracker() override;
@@ -74,6 +84,11 @@ class CONTENT_EXPORT WebContentsTracker
// callback is still valid and, if so, runs it.
void MaybeDoCallback(RenderWidgetHost* rwh);
+ // Called on the thread that Start()/Stop() are called on. Checks whether the
+ // callback is still valid and, if so, runs it to indicate the main frame has
+ // changed in size.
+ void MaybeDoResizeCallback(RenderWidgetHost* rwh);
+
// Look-up the current WebContents instance associated with the given
// |render_process_id| and |main_render_frame_id| and begin observing it.
void StartObservingWebContents(int render_process_id,
@@ -86,6 +101,10 @@ class CONTENT_EXPORT WebContentsTracker
void RenderFrameHostChanged(RenderFrameHost* old_host,
RenderFrameHost* new_host) override;
+ // WebContentsObserver override to notify the client that the source size has
+ // changed.
+ void MainFrameWasResized(bool width_changed) override;
+
// WebContentsObserver override to notify the client that the capture target
// has been permanently lost.
void WebContentsDestroyed() override;
@@ -109,6 +128,9 @@ class CONTENT_EXPORT WebContentsTracker
// This is used to eliminate duplicate callback runs.
RenderWidgetHost* last_target_;
+ // Callback to run when the target RenderWidgetHost has resized.
+ ChangeCallback resize_callback_;
+
DISALLOW_COPY_AND_ASSIGN(WebContentsTracker);
};

Powered by Google App Engine
This is Rietveld 408576698