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

Unified Diff: components/arc/standalone/service_helper.cc

Issue 2384173004: arc: Remove components/arc/standalone (Closed)
Patch Set: Rebased to ToT 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
« no previous file with comments | « components/arc/standalone/service_helper.h ('k') | components/arc/standalone/service_helper_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/arc/standalone/service_helper.cc
diff --git a/components/arc/standalone/service_helper.cc b/components/arc/standalone/service_helper.cc
deleted file mode 100644
index 07640b85e4df0b66c4c402b8a7084948867ef2ee..0000000000000000000000000000000000000000
--- a/components/arc/standalone/service_helper.cc
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2016 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 "components/arc/standalone/service_helper.h"
-
-#include "base/bind.h"
-#include "base/files/file_util.h"
-#include "base/logging.h"
-#include "base/posix/eintr_wrapper.h"
-
-namespace arc {
-
-// static
-ServiceHelper* ServiceHelper::self_ = nullptr;
-
-ServiceHelper::ServiceHelper() {
-}
-
-ServiceHelper::~ServiceHelper() {
- // Best efforts clean up, ignore the return values.
- sigaction(SIGINT, &old_sigint_, NULL);
- sigaction(SIGTERM, &old_sigterm_, NULL);
-}
-
-void ServiceHelper::Init(const base::Closure& closure) {
- CHECK(!ServiceHelper::self_);
- ServiceHelper::self_ = this;
- closure_ = closure;
-
- // Initialize pipe
- int pipe_fd[2];
- CHECK_EQ(0, pipe(pipe_fd));
- read_fd_.reset(pipe_fd[0]);
- write_fd_.reset(pipe_fd[1]);
- CHECK(base::SetNonBlocking(write_fd_.get()));
- watch_controller_ = base::FileDescriptorWatcher::WatchReadable(
- read_fd_.get(), base::Bind(&ServiceHelper::OnFileCanReadWithoutBlocking,
- base::Unretained(this)));
-
- struct sigaction action = {};
- CHECK_EQ(0, sigemptyset(&action.sa_mask));
- action.sa_handler = ServiceHelper::TerminationHandler;
- action.sa_flags = 0;
-
- CHECK_EQ(0, sigaction(SIGINT, &action, &old_sigint_));
- CHECK_EQ(0, sigaction(SIGTERM, &action, &old_sigterm_));
-}
-
-// static
-void ServiceHelper::TerminationHandler(int /* signum */) {
- if (HANDLE_EINTR(write(self_->write_fd_.get(), "1", 1)) < 0) {
- _exit(2); // We still need to exit the program, but in a brute force way.
- }
-}
-
-void ServiceHelper::OnFileCanReadWithoutBlocking() {
- char c;
- // We don't really care about the return value, since it indicates closing.
- HANDLE_EINTR(read(read_fd_.get(), &c, 1));
- closure_.Run();
-}
-
-} // namespace arc
« no previous file with comments | « components/arc/standalone/service_helper.h ('k') | components/arc/standalone/service_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698