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

Side by Side Diff: mojo/public/python/src/common.cc

Issue 796373006: Content handler for python. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/public/python/src/common.h" 5 #include "mojo/public/python/src/common.h"
6 6
7 #include <Python.h> 7 #include <Python.h>
8 8
9 #include "mojo/public/c/environment/async_waiter.h" 9 #include "mojo/public/c/environment/async_waiter.h"
10 #include "mojo/public/cpp/bindings/callback.h" 10 #include "mojo/public/cpp/bindings/callback.h"
(...skipping 26 matching lines...) Expand all
37 } 37 }
38 38
39 ScopedPyRef::ScopedPyRef(PyObject* object) : object_(object) { 39 ScopedPyRef::ScopedPyRef(PyObject* object) : object_(object) {
40 } 40 }
41 41
42 ScopedPyRef::ScopedPyRef(PyObject* object, ScopedPyRefAcquire) 42 ScopedPyRef::ScopedPyRef(PyObject* object, ScopedPyRefAcquire)
43 : object_(object) { 43 : object_(object) {
44 Py_XINCREF(object_); 44 Py_XINCREF(object_);
45 } 45 }
46 46
47 PyObject* ScopedPyRef::Release() {
48 PyObject* object = object_;
49 object_ = nullptr;
50 return object;
51 }
52
47 ScopedPyRef::~ScopedPyRef() { 53 ScopedPyRef::~ScopedPyRef() {
48 if (object_) { 54 if (object_) {
49 ScopedGIL acquire_gil; 55 ScopedGIL acquire_gil;
50 Py_DECREF(object_); 56 Py_DECREF(object_);
51 } 57 }
52 } 58 }
53 59
54 ScopedPyRef::operator PyObject*() const { 60 ScopedPyRef::operator PyObject*() const {
55 return object_; 61 return object_;
56 } 62 }
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 170
165 void PythonAsyncWaiter::CancelWait(MojoAsyncWaitID wait_id) { 171 void PythonAsyncWaiter::CancelWait(MojoAsyncWaitID wait_id) {
166 if (callbacks_.find(wait_id) != callbacks_.end()) { 172 if (callbacks_.find(wait_id) != callbacks_.end()) {
167 async_waiter_->CancelWait(wait_id); 173 async_waiter_->CancelWait(wait_id);
168 callbacks_.erase(wait_id); 174 callbacks_.erase(wait_id);
169 } 175 }
170 } 176 }
171 177
172 } // namespace python 178 } // namespace python
173 } // namespace mojo 179 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/python/src/common.h ('k') | mojo/public/tools/bindings/generators/mojom_python_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698