-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VCD: Move Ash-Chrome only codes under ash/ folder
This CL does: 1. Move CameraHalDispatcherImpl under ash/. 2. Move PowerManagerClientProxy into a standalone class under ash/. Bug: b/175168296 Test: Build successfully Change-Id: I60455aa8e593a5654c69af06957c509a26ac8964 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2589414 Reviewed-by: Shik Chen <shik@chromium.org> Reviewed-by: Scott Violet <sky@chromium.org> Commit-Queue: Wei Lee <wtlee@chromium.org> Cr-Commit-Position: refs/heads/master@{#851072}
- Loading branch information
Wei Lee
authored and
Chromium LUCI CQ
committed
Feb 5, 2021
1 parent
d8ec970
commit 3e19bbb
Showing
20 changed files
with
247 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
include_rules = [ | ||
"+crypto/random.h", | ||
"+media/capture/video/chromeos/camera_hal_dispatcher_impl.h", | ||
"+media/capture/video/chromeos/ash/camera_hal_dispatcher_impl.h", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
include_rules = [ | ||
"+ash/constants/ash_features.h", | ||
"+chromeos/dbus", | ||
"+components/chromeos_camera", | ||
"+third_party/libsync", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
include_rules = [ | ||
"+chromeos/dbus", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
media/capture/video/chromeos/ash/power_manager_client_proxy.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// Copyright 2021 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "media/capture/video/chromeos/ash/power_manager_client_proxy.h" | ||
|
||
namespace media { | ||
|
||
PowerManagerClientProxy::PowerManagerClientProxy() = default; | ||
|
||
void PowerManagerClientProxy::Init( | ||
base::WeakPtr<Observer> observer, | ||
const std::string& debug_info, | ||
scoped_refptr<base::SingleThreadTaskRunner> observer_task_runner, | ||
scoped_refptr<base::SingleThreadTaskRunner> dbus_task_runner) { | ||
observer_ = std::move(observer); | ||
debug_info_ = debug_info; | ||
observer_task_runner_ = std::move(observer_task_runner); | ||
dbus_task_runner_ = std::move(dbus_task_runner); | ||
|
||
dbus_task_runner_->PostTask( | ||
FROM_HERE, | ||
base::BindOnce(&PowerManagerClientProxy::InitOnDBusThread, this)); | ||
} | ||
|
||
void PowerManagerClientProxy::Shutdown() { | ||
dbus_task_runner_->PostTask( | ||
FROM_HERE, | ||
base::BindOnce(&PowerManagerClientProxy::ShutdownOnDBusThread, this)); | ||
} | ||
|
||
void PowerManagerClientProxy::UnblockSuspend( | ||
const base::UnguessableToken& unblock_suspend_token) { | ||
dbus_task_runner_->PostTask( | ||
FROM_HERE, | ||
base::BindOnce(&PowerManagerClientProxy::UnblockSuspendOnDBusThread, this, | ||
unblock_suspend_token)); | ||
} | ||
|
||
PowerManagerClientProxy::~PowerManagerClientProxy() = default; | ||
|
||
void PowerManagerClientProxy::InitOnDBusThread() { | ||
DCHECK(dbus_task_runner_->RunsTasksInCurrentSequence()); | ||
chromeos::PowerManagerClient::Get()->AddObserver(this); | ||
} | ||
|
||
void PowerManagerClientProxy::ShutdownOnDBusThread() { | ||
DCHECK(dbus_task_runner_->RunsTasksInCurrentSequence()); | ||
chromeos::PowerManagerClient::Get()->RemoveObserver(this); | ||
} | ||
|
||
void PowerManagerClientProxy::UnblockSuspendOnDBusThread( | ||
const base::UnguessableToken& unblock_suspend_token) { | ||
DCHECK(dbus_task_runner_->RunsTasksInCurrentSequence()); | ||
chromeos::PowerManagerClient::Get()->UnblockSuspend(unblock_suspend_token); | ||
} | ||
|
||
void PowerManagerClientProxy::SuspendImminentOnObserverThread( | ||
base::UnguessableToken unblock_suspend_token) { | ||
DCHECK(observer_task_runner_->RunsTasksInCurrentSequence()); | ||
// TODO(b/175168296): Ensure that the weak pointer |observer| is dereferenced | ||
// and invalidated on the same thread. | ||
if (observer_) { | ||
observer_->SuspendImminent(); | ||
} | ||
UnblockSuspend(std::move(unblock_suspend_token)); | ||
} | ||
|
||
void PowerManagerClientProxy::SuspendImminent( | ||
power_manager::SuspendImminent::Reason reason) { | ||
auto token = base::UnguessableToken::Create(); | ||
chromeos::PowerManagerClient::Get()->BlockSuspend(token, debug_info_); | ||
observer_task_runner_->PostTask( | ||
FROM_HERE, | ||
base::BindOnce(&PowerManagerClientProxy::SuspendImminentOnObserverThread, | ||
this, std::move(token))); | ||
} | ||
|
||
void PowerManagerClientProxy::SuspendDone(base::TimeDelta sleep_duration) { | ||
observer_task_runner_->PostTask( | ||
FROM_HERE, base::BindOnce(&Observer::SuspendDone, observer_)); | ||
} | ||
|
||
} // namespace media |
66 changes: 66 additions & 0 deletions
66
media/capture/video/chromeos/ash/power_manager_client_proxy.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright 2021 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef MEDIA_CAPTURE_VIDEO_CHROMEOS_ASH_POWER_MANAGER_CLIENT_PROXY_H_ | ||
#define MEDIA_CAPTURE_VIDEO_CHROMEOS_ASH_POWER_MANAGER_CLIENT_PROXY_H_ | ||
|
||
#include "base/memory/weak_ptr.h" | ||
#include "base/single_thread_task_runner.h" | ||
#include "base/unguessable_token.h" | ||
#include "chromeos/dbus/power/power_manager_client.h" | ||
|
||
namespace media { | ||
|
||
class PowerManagerClientProxy | ||
: public base::RefCountedThreadSafe<PowerManagerClientProxy>, | ||
public chromeos::PowerManagerClient::Observer { | ||
public: | ||
class Observer { | ||
public: | ||
virtual void SuspendDone() = 0; | ||
virtual void SuspendImminent() = 0; | ||
}; | ||
|
||
PowerManagerClientProxy(); | ||
PowerManagerClientProxy(const PowerManagerClientProxy&) = delete; | ||
PowerManagerClientProxy& operator=(const PowerManagerClientProxy&) = delete; | ||
|
||
void Init(base::WeakPtr<Observer> observer, | ||
const std::string& debug_info, | ||
scoped_refptr<base::SingleThreadTaskRunner> observer_task_runner, | ||
scoped_refptr<base::SingleThreadTaskRunner> dbus_task_runner); | ||
|
||
void Shutdown(); | ||
|
||
void UnblockSuspend(const base::UnguessableToken& unblock_suspend_token); | ||
|
||
private: | ||
friend class base::RefCountedThreadSafe<PowerManagerClientProxy>; | ||
|
||
~PowerManagerClientProxy() override; | ||
|
||
void InitOnDBusThread(); | ||
|
||
void ShutdownOnDBusThread(); | ||
|
||
void UnblockSuspendOnDBusThread( | ||
const base::UnguessableToken& unblock_suspend_token); | ||
|
||
void SuspendImminentOnObserverThread( | ||
base::UnguessableToken unblock_suspend_token); | ||
|
||
// chromeos::PowerManagerClient::Observer: | ||
void SuspendImminent(power_manager::SuspendImminent::Reason reason) final; | ||
|
||
void SuspendDone(base::TimeDelta sleep_duration) final; | ||
|
||
base::WeakPtr<Observer> observer_; | ||
std::string debug_info_; | ||
scoped_refptr<base::SingleThreadTaskRunner> observer_task_runner_; | ||
scoped_refptr<base::SingleThreadTaskRunner> dbus_task_runner_; | ||
}; | ||
|
||
} // namespace media | ||
|
||
#endif // MEDIA_CAPTURE_VIDEO_CHROMEOS_ASH_POWER_MANAGER_CLIENT_PROXY_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.