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

Unified Diff: mojo/android/system/src/org/chromium/mojo/system/HandleBase.java

Issue 294043016: Refactor java packages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 7 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: mojo/android/system/src/org/chromium/mojo/system/HandleBase.java
diff --git a/mojo/android/system/src/org/chromium/mojo/system/HandleBase.java b/mojo/android/system/src/org/chromium/mojo/system/HandleBase.java
deleted file mode 100644
index 5d9fd470a07e3a5937a33c0758926ffca4d5e503..0000000000000000000000000000000000000000
--- a/mojo/android/system/src/org/chromium/mojo/system/HandleBase.java
+++ /dev/null
@@ -1,119 +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.
-
-package org.chromium.mojo.system;
-
-import android.util.Log;
-
-import org.chromium.mojo.system.Core.WaitFlags;
-
-/**
- * Implementation of {@link Handle}.
- */
-abstract class HandleBase implements Handle {
-
- private static final String TAG = "HandleImpl";
-
- /**
- * The pointer to the scoped handle owned by this object.
- */
- private int mMojoHandle;
-
- /**
- * The core implementation. Will be used to delegate all behavior.
- */
- protected CoreImpl mCore;
-
- /**
- * Base constructor. Takes ownership of the passed handle.
- */
- HandleBase(CoreImpl core, int mojoHandle) {
- mCore = core;
- mMojoHandle = mojoHandle;
- }
-
- /**
- * Constructor for transforming {@link HandleBase} into a specific one. It is used to transform
- * an {@link UntypedHandle} into a typed one, or any handle into an {@link UntypedHandle}.
- */
- protected HandleBase(HandleBase other) {
- mCore = other.mCore;
- HandleBase otherAsHandleImpl = other;
- int mojoHandle = otherAsHandleImpl.mMojoHandle;
- otherAsHandleImpl.mMojoHandle = CoreImpl.INVALID_HANDLE;
- mMojoHandle = mojoHandle;
- }
-
- /**
- * @see org.chromium.mojo.system.Handle#close()
- */
- @Override
- public void close() {
- if (mMojoHandle != CoreImpl.INVALID_HANDLE) {
- // After a close, the handle is invalid whether the close succeed or not.
- int handle = mMojoHandle;
- mMojoHandle = CoreImpl.INVALID_HANDLE;
- mCore.close(handle);
- }
- }
-
- /**
- * @see org.chromium.mojo.system.Handle#wait(WaitFlags, long)
- */
- @Override
- public int wait(WaitFlags flags, long deadline) {
- return mCore.wait(this, flags, deadline);
- }
-
- /**
- * @see org.chromium.mojo.system.Handle#isValid()
- */
- @Override
- public boolean isValid() {
- return mMojoHandle != CoreImpl.INVALID_HANDLE;
- }
-
- /**
- * @see org.chromium.mojo.system.Handle#toUntypedHandle()
- */
- @Override
- public UntypedHandle toUntypedHandle() {
- return new UntypedHandleImpl(this);
- }
-
- /**
- * Getter for the native scoped handle.
- *
- * @return the native scoped handle.
- */
- int getMojoHandle() {
- return mMojoHandle;
- }
-
- /**
- * invalidate the handle. The caller must ensures that the handle does not leak.
- */
- void invalidateHandle() {
- mMojoHandle = CoreImpl.INVALID_HANDLE;
- }
-
- /**
- * Close the handle if it is valid. Necessary because we cannot let handle leak, and we cannot
- * ensure that every handle will be manually closed.
- *
- * @see java.lang.Object#finalize()
- */
- @Override
- protected final void finalize() throws Throwable {
- if (isValid()) {
- // This should not happen, as the user of this class should close the handle. Adding a
- // warning.
- Log.w(TAG, "Handle was not closed.");
- // Ignore result at this point.
- mCore.closeWithResult(mMojoHandle);
- }
- super.finalize();
- }
-
-}

Powered by Google App Engine
This is Rietveld 408576698