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

Unified Diff: mojo/public/python/src/python_system_helper.cc

Issue 575893004: Revert of mojo: Add a runloop utility in python (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 | « mojo/public/python/src/python_system_helper.h ('k') | mojo/python/tests/runloop_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/python/src/python_system_helper.cc
diff --git a/mojo/public/python/src/python_system_helper.cc b/mojo/public/python/src/python_system_helper.cc
deleted file mode 100644
index 91032053bff05d706deb63771da6bef7f32739fd..0000000000000000000000000000000000000000
--- a/mojo/public/python/src/python_system_helper.cc
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright 2014 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 "mojo/public/python/src/python_system_helper.h"
-
-#include "Python.h"
-
-#include "mojo/public/cpp/environment/logging.h"
-#include "mojo/public/cpp/system/macros.h"
-#include "mojo/public/cpp/utility/run_loop.h"
-
-namespace {
-
-class ScopedGIL {
- public:
- ScopedGIL() {
- state_ = PyGILState_Ensure();
- }
-
- ~ScopedGIL() {
- PyGILState_Release(state_);
- }
-
- private:
- PyGILState_STATE state_;
-
- MOJO_DISALLOW_COPY_AND_ASSIGN(ScopedGIL);
-};
-
-class PythonClosure : public mojo::Closure::Runnable {
- public:
- PythonClosure(PyObject* callable) : callable_(callable) {
- MOJO_CHECK(callable);
- Py_XINCREF(callable);
- }
-
- virtual ~PythonClosure() {
- ScopedGIL acquire_gil;
- Py_DECREF(callable_);
- }
-
- virtual void Run() const MOJO_OVERRIDE {
- ScopedGIL acquire_gil;
- PyObject* empty_tuple = PyTuple_New(0);
- if (!empty_tuple) {
- mojo::RunLoop::current()->Quit();
- return;
- }
-
- PyObject* result = PyObject_CallObject(callable_, empty_tuple);
- Py_DECREF(empty_tuple);
- if (result) {
- Py_DECREF(result);
- } else {
- mojo::RunLoop::current()->Quit();
- return;
- }
- }
-
- private:
- PyObject* callable_;
-
- MOJO_DISALLOW_COPY_AND_ASSIGN(PythonClosure);
-};
-
-} // namespace
-
-namespace mojo {
-
-Closure BuildClosure(PyObject* callable) {
- if (!PyCallable_Check(callable))
- return Closure();
-
- return Closure(
- static_cast<mojo::Closure::Runnable*>(new PythonClosure(callable)));
-}
-
-} // namespace mojo
« no previous file with comments | « mojo/public/python/src/python_system_helper.h ('k') | mojo/python/tests/runloop_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698