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

Unified Diff: ui/wm/core/capture_controller.cc

Issue 2466023003: Makes CaptureController be created and owned by WMState (Closed)
Patch Set: moar Created 4 years, 1 month 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 | « ui/wm/core/capture_controller.h ('k') | ui/wm/core/capture_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/wm/core/capture_controller.cc
diff --git a/ui/wm/core/capture_controller.cc b/ui/wm/core/capture_controller.cc
index 08238de931378184056d7b4e2184a40a227ee008..fbc045d425df378a22a364e4fec3e1b99fb6569c 100644
--- a/ui/wm/core/capture_controller.cc
+++ b/ui/wm/core/capture_controller.cc
@@ -12,9 +12,23 @@
namespace wm {
+// static
+CaptureController* CaptureController::instance_ = nullptr;
+
////////////////////////////////////////////////////////////////////////////////
// CaptureController, public:
+CaptureController::CaptureController()
+ : capture_window_(nullptr), capture_delegate_(nullptr) {
+ DCHECK(!instance_);
+ instance_ = this;
+}
+
+CaptureController::~CaptureController() {
+ DCHECK_EQ(instance_, this);
+ instance_ = nullptr;
+}
+
void CaptureController::Attach(aura::Window* root) {
DCHECK_EQ(0u, delegates_.count(root));
delegates_[root] = root->GetHost()->dispatcher();
@@ -103,39 +117,18 @@ void CaptureController::RemoveObserver(
}
////////////////////////////////////////////////////////////////////////////////
-// CaptureController, private:
-
-CaptureController::CaptureController()
- : capture_window_(nullptr),
- capture_delegate_(nullptr) {
-}
-
-CaptureController::~CaptureController() {
-}
-
-////////////////////////////////////////////////////////////////////////////////
// ScopedCaptureClient:
-// static
-CaptureController* ScopedCaptureClient::capture_controller_ = nullptr;
-
ScopedCaptureClient::ScopedCaptureClient(aura::Window* root)
: root_window_(root) {
root->AddObserver(this);
- if (!capture_controller_)
- capture_controller_ = new CaptureController;
- capture_controller_->Attach(root);
+ CaptureController::Get()->Attach(root);
}
ScopedCaptureClient::~ScopedCaptureClient() {
Shutdown();
}
-// static
-bool ScopedCaptureClient::IsActive() {
- return capture_controller_ && capture_controller_->is_active();
-}
-
void ScopedCaptureClient::OnWindowDestroyed(aura::Window* window) {
DCHECK_EQ(window, root_window_);
Shutdown();
@@ -146,11 +139,7 @@ void ScopedCaptureClient::Shutdown() {
return;
root_window_->RemoveObserver(this);
- capture_controller_->Detach(root_window_);
- if (!capture_controller_->is_active()) {
- delete capture_controller_;
- capture_controller_ = nullptr;
- }
+ CaptureController::Get()->Detach(root_window_);
root_window_ = nullptr;
}
@@ -159,7 +148,7 @@ void ScopedCaptureClient::Shutdown() {
void ScopedCaptureClient::TestApi::SetDelegate(
aura::client::CaptureDelegate* delegate) {
- client_->capture_controller_->delegates_[client_->root_window_] = delegate;
+ CaptureController::Get()->delegates_[client_->root_window_] = delegate;
}
} // namespace wm
« no previous file with comments | « ui/wm/core/capture_controller.h ('k') | ui/wm/core/capture_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698