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

Unified Diff: ui/aura/mus/capture_synchronizer.cc

Issue 2626013005: Change CaptureSynchronizer and PointerWatcherEventRouter to support multiple CaptureClients. (Closed)
Patch Set: another approach to attach capture client Created 3 years, 11 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: ui/aura/mus/capture_synchronizer.cc
diff --git a/ui/aura/mus/capture_synchronizer.cc b/ui/aura/mus/capture_synchronizer.cc
index 67dacb4e9d5672b55204f2980242e71c5ca52f0f..cc06200bb2fc0ad62ba988b143a3ee51602dfe7e 100644
--- a/ui/aura/mus/capture_synchronizer.cc
+++ b/ui/aura/mus/capture_synchronizer.cc
@@ -14,45 +14,48 @@
namespace aura {
CaptureSynchronizer::CaptureSynchronizer(CaptureSynchronizerDelegate* delegate,
- ui::mojom::WindowTree* window_tree,
- client::CaptureClient* capture_client)
- : delegate_(delegate),
- window_tree_(window_tree),
- capture_client_(capture_client) {
- capture_client_->AddObserver(this);
-}
+ ui::mojom::WindowTree* window_tree)
+ : delegate_(delegate), window_tree_(window_tree) {}
-CaptureSynchronizer::~CaptureSynchronizer() {
- SetCaptureWindow(nullptr);
- capture_client_->RemoveObserver(this);
-}
+CaptureSynchronizer::~CaptureSynchronizer() {}
void CaptureSynchronizer::SetCaptureFromServer(WindowMus* window) {
if (window == capture_window_)
return;
DCHECK(!setting_capture_);
- // Don't immediately set |capture_client_|. It's possible the change will be
+ // Don't immediately set capture client. It's possible the change will be
// rejected.
base::AutoReset<bool> capture_reset(&setting_capture_, true);
base::AutoReset<WindowMus*> window_setting_capture_to_reset(
&window_setting_capture_to_, window);
- capture_client_->SetCapture(window ? window->GetWindow() : nullptr);
+ client::CaptureClient* capture_client =
+ window ? client::GetCaptureClient(window->GetWindow()->GetRootWindow())
+ : client::GetCaptureClient(
+ capture_window_->GetWindow()->GetRootWindow());
sadrul 2017/01/21 03:23:37 If capture-client for |window| is different from c
riajiang 2017/01/24 19:36:22 I thought if a window is going to lose capture, Re
+ capture_client->SetCapture(window ? window->GetWindow() : nullptr);
+}
+
+void CaptureSynchronizer::Attach(client::CaptureClient* capture_client) {
+ if (capture_client)
sadrul 2017/01/21 03:23:37 When can this be null?
+ capture_client->AddObserver(this);
sadrul 2017/01/21 03:23:37 Document why we never need to RemoveObserver() fro
}
void CaptureSynchronizer::SetCaptureWindow(WindowMus* window) {
if (capture_window_)
capture_window_->GetWindow()->RemoveObserver(this);
capture_window_ = window;
- if (capture_window_)
+ if (capture_window_ && !capture_window_->GetWindow()->HasObserver(this))
sadrul 2017/01/21 03:23:37 Should not need this change anymore?
riajiang 2017/01/24 19:36:22 Done.
capture_window_->GetWindow()->AddObserver(this);
}
void CaptureSynchronizer::OnWindowDestroying(Window* window) {
// The CaptureClient implementation handles resetting capture when a window
// is destroyed, but because of observer ordering this may be called first.
- DCHECK_EQ(window, capture_window_->GetWindow());
- SetCaptureWindow(nullptr);
+ if (capture_window_) {
+ DCHECK_EQ(window, capture_window_->GetWindow());
+ SetCaptureWindow(nullptr);
+ }
sadrul 2017/01/21 03:23:37 ditto
riajiang 2017/01/24 19:36:22 Don't need this anymore. Deleted.
// The server will release capture when a window is destroyed, so no need
// explicitly schedule a change.
}

Powered by Google App Engine
This is Rietveld 408576698