Chromium Code Reviews| Index: athena/env/athena_env_impl.cc |
| diff --git a/athena/env/athena_env_impl.cc b/athena/env/athena_env_impl.cc |
| index 98658ca6baed0ff108cb2d6537f8f981ac3ce446..93460d8e743f5dab71923199a1af8832e85b9a18 100644 |
| --- a/athena/env/athena_env_impl.cc |
| +++ b/athena/env/athena_env_impl.cc |
| @@ -4,6 +4,8 @@ |
| #include "athena/env/public/athena_env.h" |
| +#include <vector> |
| + |
| #include "athena/common/fill_layout_manager.h" |
| #include "base/sys_info.h" |
| #include "ui/aura/client/aura_constants.h" |
| @@ -247,13 +249,50 @@ class AthenaEnvImpl : public AthenaEnv, |
| } |
| private: |
| - virtual aura::WindowTreeHost* GetHost() OVERRIDE { return host_.get(); } |
| + struct Finder { |
| + explicit Finder(const base::Closure& c) : closure(c) {} |
| + bool operator()(const base::Closure& other) { |
| + return closure.Equals(other); |
| + } |
| + base::Closure closure; |
| + }; |
| // AthenaEnv: |
| + virtual aura::WindowTreeHost* GetHost() OVERRIDE { return host_.get(); } |
| + |
| virtual void SetDisplayWorkAreaInsets(const gfx::Insets& insets) OVERRIDE { |
| screen_->SetWorkAreaInsets(insets); |
| } |
| + virtual void AddTerminatingCallback(const base::Closure& closure) OVERRIDE { |
|
Jun Mukai
2014/09/10 00:07:10
Rather than bundling terminating callbacks here, i
oshima
2014/09/10 00:47:49
I'd like to use callback for a couple of reasons.
Jun Mukai
2014/09/10 00:51:48
Okay, in that case.
I imagine that this type of t
|
| + if (closure.is_null()) |
| + return; |
| + DCHECK(terminating_callbacks_.end() == |
| + std::find_if(terminating_callbacks_.begin(), |
| + terminating_callbacks_.end(), |
| + Finder(closure))); |
| + terminating_callbacks_.push_back(closure); |
| + } |
| + |
| + virtual void RemoveTerminatingCallback( |
| + const base::Closure& closure) OVERRIDE { |
| + std::vector<base::Closure>::iterator iter = |
| + std::find_if(terminating_callbacks_.begin(), |
| + terminating_callbacks_.end(), |
| + Finder(closure)); |
| + if (iter != terminating_callbacks_.end()) |
| + terminating_callbacks_.erase(iter); |
| + } |
| + |
| + virtual void OnTerminating() OVERRIDE { |
| + for (std::vector<base::Closure>::iterator iter = |
| + terminating_callbacks_.begin(); |
| + iter != terminating_callbacks_.end(); |
| + ++iter) { |
| + (*iter).Run(); |
|
Jun Mukai
2014/09/10 00:24:30
iter->Run();
oshima
2014/09/10 00:47:50
Done.
|
| + } |
| + } |
| + |
| // ui::DisplayConfigurator::Observer: |
| virtual void OnDisplayModeChanged(const std::vector< |
| ui::DisplayConfigurator::DisplayState>& displays) OVERRIDE { |