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

Unified Diff: components/arc/arc_bridge_bootstrap.cc

Issue 2397863003: Move free disk space check to session_manager. (Closed)
Patch Set: Created 4 years, 2 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: components/arc/arc_bridge_bootstrap.cc
diff --git a/components/arc/arc_bridge_bootstrap.cc b/components/arc/arc_bridge_bootstrap.cc
index 845d0ae1467885869eaafd1536ca217b08b819eb..62424e9bbc1021d766963014b5d8ddea067adf00 100644
--- a/components/arc/arc_bridge_bootstrap.cc
+++ b/components/arc/arc_bridge_bootstrap.cc
@@ -46,9 +46,9 @@ const base::FilePath::CharType kArcBridgeSocketPath[] =
const char kArcBridgeSocketGroup[] = "arc-bridge";
-const base::FilePath::CharType kDiskCheckPath[] = "/home";
-
-const int64_t kCriticalDiskFreeBytes = 64 << 20; // 64MB
+// TODO(hidehiko): Share the constant between Chrome and ChromeOS.
+constexpr char kArcLowDiskError[] =
+ "org.chromium.SessionManagerInterface.LowFreeDisk";
// This is called when StopArcInstance D-Bus method completes. Since we have the
// ArcInstanceStopped() callback and are notified if StartArcInstance fails, we
@@ -186,9 +186,6 @@ class ArcBridgeBootstrapImpl : public ArcBridgeBootstrap,
// ARC is not yet started.
NOT_STARTED,
- // Checking the disk space.
- CHECKING_DISK_SPACE,
-
// An UNIX socket is being created.
CREATING_SOCKET,
@@ -213,16 +210,15 @@ class ArcBridgeBootstrapImpl : public ArcBridgeBootstrap,
void Stop() override;
private:
- // Called after getting the device free disk space.
- void OnFreeDiskSpaceObtained(int64_t disk_free_bytes);
-
// Creates the UNIX socket on the bootstrap thread and then processes its
// file descriptor.
static base::ScopedFD CreateSocket();
void OnSocketCreated(base::ScopedFD fd);
// DBus callback for StartArcInstance().
- void OnInstanceStarted(base::ScopedFD socket_fd, bool success);
+ void OnInstanceStarted(base::ScopedFD socket_fd,
+ bool success,
+ const std::string& error);
// Synchronously accepts a connection on |socket_fd| and then processes the
// connected socket's file descriptor.
@@ -283,40 +279,8 @@ void ArcBridgeBootstrapImpl::Start() {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_EQ(state_, State::NOT_STARTED);
VLOG(2) << "Starting ARC session.";
- VLOG(2) << "Checking disk space...";
- state_ = State::CHECKING_DISK_SPACE;
-
- // TODO(crbug.com/628124): Move disk space checking logic to session_manager.
- base::PostTaskAndReplyWithResult(
- base::WorkerPool::GetTaskRunner(true).get(), FROM_HERE,
- base::Bind(&base::SysInfo::AmountOfFreeDiskSpace,
- base::FilePath(kDiskCheckPath)),
- base::Bind(&ArcBridgeBootstrapImpl::OnFreeDiskSpaceObtained,
- weak_factory_.GetWeakPtr()));
-}
-
-void ArcBridgeBootstrapImpl::OnFreeDiskSpaceObtained(int64_t disk_free_bytes) {
- DCHECK(thread_checker_.CalledOnValidThread());
- DCHECK_EQ(state_, State::CHECKING_DISK_SPACE);
-
- if (stop_requested_) {
- VLOG(1) << "Stop() called while checking disk space";
- OnStopped(ArcBridgeService::StopReason::SHUTDOWN);
- return;
- }
-
- if (disk_free_bytes < 0) {
- LOG(ERROR) << "ARC: Failed to get free disk space";
- OnStopped(ArcBridgeService::StopReason::GENERIC_BOOT_FAILURE);
- return;
- }
- if (disk_free_bytes < kCriticalDiskFreeBytes) {
- LOG(ERROR) << "ARC: The device is too low on disk space to start ARC";
- OnStopped(ArcBridgeService::StopReason::LOW_DISK_SPACE);
- return;
- }
-
VLOG(2) << "Disk space check is done. Creating socket...";
Shuhei Takahashi 2016/10/06 08:21:03 Could you remove this line?
hidehiko 2016/10/06 08:33:21 Done.
+
state_ = State::CREATING_SOCKET;
base::PostTaskAndReplyWithResult(
base::WorkerPool::GetTaskRunner(true).get(), FROM_HERE,
@@ -399,7 +363,8 @@ void ArcBridgeBootstrapImpl::OnSocketCreated(base::ScopedFD socket_fd) {
}
void ArcBridgeBootstrapImpl::OnInstanceStarted(base::ScopedFD socket_fd,
- bool success) {
+ bool success,
+ const std::string& error) {
DCHECK(thread_checker_.CalledOnValidThread());
if (state_ == State::STOPPED) {
// This is the case that error is notified via DBus before the
@@ -422,7 +387,9 @@ void ArcBridgeBootstrapImpl::OnInstanceStarted(base::ScopedFD socket_fd,
if (!success) {
LOG(ERROR) << "Failed to start ARC instance";
- OnStopped(ArcBridgeService::StopReason::GENERIC_BOOT_FAILURE);
+ OnStopped(error == kArcLowDiskError
+ ? ArcBridgeService::StopReason::LOW_DISK_SPACE
+ : ArcBridgeService::StopReason::GENERIC_BOOT_FAILURE);
return;
}
@@ -540,7 +507,6 @@ void ArcBridgeBootstrapImpl::Stop() {
OnStopped(ArcBridgeService::StopReason::SHUTDOWN);
return;
- case State::CHECKING_DISK_SPACE:
case State::CREATING_SOCKET:
case State::STARTING_INSTANCE:
// Before starting the ARC instance, we do nothing here.
« chromeos/dbus/session_manager_client.cc ('K') | « chromeos/dbus/session_manager_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698