Mojo: Move common type/constant definitions from mojo/public/c/system/core.h to .../types.h.

The plan is to further split the file: functions.h (or something like
that) for common/basic functions, message_pipe.h, data_pipe.h, etc.

R=sky@chromium.org

Review URL: https://codereview.chromium.org/307533002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273008 0039d316-1c4b-4281-b951-d872f2087c98
parent f706d3dc
......@@ -29,6 +29,7 @@
'public/c/system/core.h',
'public/c/system/macros.h',
'public/c/system/system_export.h',
'public/c/system/types.h',
'public/platform/native/system_thunks.cc',
'public/platform/native/system_thunks.h',
],
......
......@@ -11,158 +11,11 @@
#include "mojo/public/c/system/macros.h"
#include "mojo/public/c/system/system_export.h"
#include "mojo/public/c/system/types.h"
// Types/constants -------------------------------------------------------------
// TODO(vtl): Notes: Use of undefined flags will lead to undefined behavior
// (typically they'll be ignored), not necessarily an error.
// |MojoTimeTicks|: Used to specify time ticks. Value is in microseconds.
typedef int64_t MojoTimeTicks;
// |MojoHandle|: Handles to Mojo objects.
// |MOJO_HANDLE_INVALID| - A value that is never a valid handle.
typedef uint32_t MojoHandle;
#ifdef __cplusplus
const MojoHandle MOJO_HANDLE_INVALID = 0;
#else
#define MOJO_HANDLE_INVALID ((MojoHandle) 0)
#endif
// |MojoResult|: Result codes for Mojo operations. Non-negative values are
// success codes; negative values are error/failure codes.
// |MOJO_RESULT_OK| - Not an error; returned on success. Note that positive
// |MojoResult|s may also be used to indicate success.
// |MOJO_RESULT_CANCELLED| - Operation was cancelled, typically by the caller.
// |MOJO_RESULT_UNKNOWN| - Unknown error (e.g., if not enough information is
// available for a more specific error).
// |MOJO_RESULT_INVALID_ARGUMENT| - Caller specified an invalid argument. This
// differs from |MOJO_RESULT_FAILED_PRECONDITION| in that the former
// indicates arguments that are invalid regardless of the state of the
// system.
// |MOJO_RESULT_DEADLINE_EXCEEDED| - Deadline expired before the operation
// could complete.
// |MOJO_RESULT_NOT_FOUND| - Some requested entity was not found (i.e., does
// not exist).
// |MOJO_RESULT_ALREADY_EXISTS| - Some entity or condition that we attempted
// to create already exists.
// |MOJO_RESULT_PERMISSION_DENIED| - The caller does not have permission to
// for the operation (use |MOJO_RESULT_RESOURCE_EXHAUSTED| for rejections
// caused by exhausting some resource instead).
// |MOJO_RESULT_RESOURCE_EXHAUSTED| - Some resource required for the call
// (possibly some quota) has been exhausted.
// |MOJO_RESULT_FAILED_PRECONDITION| - The system is not in a state required
// for the operation (use this if the caller must do something to rectify
// the state before retrying).
// |MOJO_RESULT_ABORTED| - The operation was aborted by the system, possibly
// due to a concurrency issue (use this if the caller may retry at a
// higher level).
// |MOJO_RESULT_OUT_OF_RANGE| - The operation was attempted past the valid
// range. Unlike |MOJO_RESULT_INVALID_ARGUMENT|, this indicates that the
// operation may be/become valid depending on the system state. (This
// error is similar to |MOJO_RESULT_FAILED_PRECONDITION|, but is more
// specific.)
// |MOJO_RESULT_UNIMPLEMENTED| - The operation is not implemented, supported,
// or enabled.
// |MOJO_RESULT_INTERNAL| - Internal error: this should never happen and
// indicates that some invariant expected by the system has been broken.
// |MOJO_RESULT_UNAVAILABLE| - The operation is (temporarily) currently
// unavailable. The caller may simply retry the operation (possibly with a
// backoff).
// |MOJO_RESULT_DATA_LOSS| - Unrecoverable data loss or corruption.
// |MOJO_RESULT_BUSY| - One of the resources involved is currently being used
// (possibly on another thread) in a way that prevents the current
// operation from proceeding, e.g., if the other operation may result in
// the resource being invalidated.
// |MOJO_RESULT_SHOULD_WAIT| - The request cannot currently be completed
// (e.g., if the data requested is not yet available). The caller should
// wait for it to be feasible using |MojoWait()| or |MojoWaitMany()|.
//
// Note that positive values are also available as success codes.
//
// The codes from |MOJO_RESULT_OK| to |MOJO_RESULT_DATA_LOSS| come from
// Google3's canonical error codes.
//
// TODO(vtl): Add a |MOJO_RESULT_UNSATISFIABLE|?
typedef int32_t MojoResult;
#ifdef __cplusplus
const MojoResult MOJO_RESULT_OK = 0;
const MojoResult MOJO_RESULT_CANCELLED = -1;
const MojoResult MOJO_RESULT_UNKNOWN = -2;
const MojoResult MOJO_RESULT_INVALID_ARGUMENT = -3;
const MojoResult MOJO_RESULT_DEADLINE_EXCEEDED = -4;
const MojoResult MOJO_RESULT_NOT_FOUND = -5;
const MojoResult MOJO_RESULT_ALREADY_EXISTS = -6;
const MojoResult MOJO_RESULT_PERMISSION_DENIED = -7;
const MojoResult MOJO_RESULT_RESOURCE_EXHAUSTED = -8;
const MojoResult MOJO_RESULT_FAILED_PRECONDITION = -9;
const MojoResult MOJO_RESULT_ABORTED = -10;
const MojoResult MOJO_RESULT_OUT_OF_RANGE = -11;
const MojoResult MOJO_RESULT_UNIMPLEMENTED = -12;
const MojoResult MOJO_RESULT_INTERNAL = -13;
const MojoResult MOJO_RESULT_UNAVAILABLE = -14;
const MojoResult MOJO_RESULT_DATA_LOSS = -15;
const MojoResult MOJO_RESULT_BUSY = -16;
const MojoResult MOJO_RESULT_SHOULD_WAIT = -17;
#else
#define MOJO_RESULT_OK ((MojoResult) 0)
#define MOJO_RESULT_CANCELLED ((MojoResult) -1)
#define MOJO_RESULT_UNKNOWN ((MojoResult) -2)
#define MOJO_RESULT_INVALID_ARGUMENT ((MojoResult) -3)
#define MOJO_RESULT_DEADLINE_EXCEEDED ((MojoResult) -4)
#define MOJO_RESULT_NOT_FOUND ((MojoResult) -5)
#define MOJO_RESULT_ALREADY_EXISTS ((MojoResult) -6)
#define MOJO_RESULT_PERMISSION_DENIED ((MojoResult) -7)
#define MOJO_RESULT_RESOURCE_EXHAUSTED ((MojoResult) -8)
#define MOJO_RESULT_FAILED_PRECONDITION ((MojoResult) -9)
#define MOJO_RESULT_ABORTED ((MojoResult) -10)
#define MOJO_RESULT_OUT_OF_RANGE ((MojoResult) -11)
#define MOJO_RESULT_UNIMPLEMENTED ((MojoResult) -12)
#define MOJO_RESULT_INTERNAL ((MojoResult) -13)
#define MOJO_RESULT_UNAVAILABLE ((MojoResult) -14)
#define MOJO_RESULT_DATA_LOSS ((MojoResult) -15)
#define MOJO_RESULT_BUSY ((MojoResult) -16)
#define MOJO_RESULT_SHOULD_WAIT ((MojoResult) -17)
#endif
// |MojoDeadline|: Used to specify deadlines (timeouts), in microseconds (except
// for |MOJO_DEADLINE_INDEFINITE|).
// |MOJO_DEADLINE_INDEFINITE| - Used to indicate "forever".
typedef uint64_t MojoDeadline;
#ifdef __cplusplus
const MojoDeadline MOJO_DEADLINE_INDEFINITE = static_cast<MojoDeadline>(-1);
#else
#define MOJO_DEADLINE_INDEFINITE ((MojoDeadline) -1)
#endif
// |MojoWaitFlags|: Used to specify the state of a handle to wait on (e.g., the
// ability to read or write to it).
// |MOJO_WAIT_FLAG_NONE| - No flags. |MojoWait()|, etc. will return
// |MOJO_RESULT_FAILED_PRECONDITION| if you attempt to wait on this.
// |MOJO_WAIT_FLAG_READABLE| - Can read (e.g., a message) from the handle.
// |MOJO_WAIT_FLAG_WRITABLE| - Can write (e.g., a message) to the handle.
// |MOJO_WAIT_FLAG_EVERYTHING| - All flags.
typedef uint32_t MojoWaitFlags;
#ifdef __cplusplus
const MojoWaitFlags MOJO_WAIT_FLAG_NONE = 0;
const MojoWaitFlags MOJO_WAIT_FLAG_READABLE = 1 << 0;
const MojoWaitFlags MOJO_WAIT_FLAG_WRITABLE = 1 << 1;
const MojoWaitFlags MOJO_WAIT_FLAG_EVERYTHING = ~0;
#else
#define MOJO_WAIT_FLAG_NONE ((MojoWaitFlags) 0)
#define MOJO_WAIT_FLAG_READABLE ((MojoWaitFlags) 1 << 0)
#define MOJO_WAIT_FLAG_WRITABLE ((MojoWaitFlags) 1 << 1)
#define MOJO_WAIT_FLAG_EVERYTHING (~((MojoWaitFlags) 0))
#endif
// TODO(vtl): Split these into their own header files.
// Message pipe:
......
// 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.
// This file contains types and constants/macros common to different Mojo system
// APIs.
#ifndef MOJO_PUBLIC_C_SYSTEM_TYPES_H_
#define MOJO_PUBLIC_C_SYSTEM_TYPES_H_
// Note: This header should be compilable as C.
#include <stdint.h>
// Types/constants -------------------------------------------------------------
// TODO(vtl): Notes: Use of undefined flags will lead to undefined behavior
// (typically they'll be ignored), not necessarily an error.
// |MojoTimeTicks|: Used to specify time ticks. Value is in microseconds.
typedef int64_t MojoTimeTicks;
// |MojoHandle|: Handles to Mojo objects.
// |MOJO_HANDLE_INVALID| - A value that is never a valid handle.
typedef uint32_t MojoHandle;
#ifdef __cplusplus
const MojoHandle MOJO_HANDLE_INVALID = 0;
#else
#define MOJO_HANDLE_INVALID ((MojoHandle) 0)
#endif
// |MojoResult|: Result codes for Mojo operations. Non-negative values are
// success codes; negative values are error/failure codes.
// |MOJO_RESULT_OK| - Not an error; returned on success. Note that positive
// |MojoResult|s may also be used to indicate success.
// |MOJO_RESULT_CANCELLED| - Operation was cancelled, typically by the caller.
// |MOJO_RESULT_UNKNOWN| - Unknown error (e.g., if not enough information is
// available for a more specific error).
// |MOJO_RESULT_INVALID_ARGUMENT| - Caller specified an invalid argument. This
// differs from |MOJO_RESULT_FAILED_PRECONDITION| in that the former
// indicates arguments that are invalid regardless of the state of the
// system.
// |MOJO_RESULT_DEADLINE_EXCEEDED| - Deadline expired before the operation
// could complete.
// |MOJO_RESULT_NOT_FOUND| - Some requested entity was not found (i.e., does
// not exist).
// |MOJO_RESULT_ALREADY_EXISTS| - Some entity or condition that we attempted
// to create already exists.
// |MOJO_RESULT_PERMISSION_DENIED| - The caller does not have permission to
// for the operation (use |MOJO_RESULT_RESOURCE_EXHAUSTED| for rejections
// caused by exhausting some resource instead).
// |MOJO_RESULT_RESOURCE_EXHAUSTED| - Some resource required for the call
// (possibly some quota) has been exhausted.
// |MOJO_RESULT_FAILED_PRECONDITION| - The system is not in a state required
// for the operation (use this if the caller must do something to rectify
// the state before retrying).
// |MOJO_RESULT_ABORTED| - The operation was aborted by the system, possibly
// due to a concurrency issue (use this if the caller may retry at a
// higher level).
// |MOJO_RESULT_OUT_OF_RANGE| - The operation was attempted past the valid
// range. Unlike |MOJO_RESULT_INVALID_ARGUMENT|, this indicates that the
// operation may be/become valid depending on the system state. (This
// error is similar to |MOJO_RESULT_FAILED_PRECONDITION|, but is more
// specific.)
// |MOJO_RESULT_UNIMPLEMENTED| - The operation is not implemented, supported,
// or enabled.
// |MOJO_RESULT_INTERNAL| - Internal error: this should never happen and
// indicates that some invariant expected by the system has been broken.
// |MOJO_RESULT_UNAVAILABLE| - The operation is (temporarily) currently
// unavailable. The caller may simply retry the operation (possibly with a
// backoff).
// |MOJO_RESULT_DATA_LOSS| - Unrecoverable data loss or corruption.
// |MOJO_RESULT_BUSY| - One of the resources involved is currently being used
// (possibly on another thread) in a way that prevents the current
// operation from proceeding, e.g., if the other operation may result in
// the resource being invalidated.
// |MOJO_RESULT_SHOULD_WAIT| - The request cannot currently be completed
// (e.g., if the data requested is not yet available). The caller should
// wait for it to be feasible using |MojoWait()| or |MojoWaitMany()|.
//
// Note that positive values are also available as success codes.
//
// The codes from |MOJO_RESULT_OK| to |MOJO_RESULT_DATA_LOSS| come from
// Google3's canonical error codes.
//
// TODO(vtl): Add a |MOJO_RESULT_UNSATISFIABLE|?
typedef int32_t MojoResult;
#ifdef __cplusplus
const MojoResult MOJO_RESULT_OK = 0;
const MojoResult MOJO_RESULT_CANCELLED = -1;
const MojoResult MOJO_RESULT_UNKNOWN = -2;
const MojoResult MOJO_RESULT_INVALID_ARGUMENT = -3;
const MojoResult MOJO_RESULT_DEADLINE_EXCEEDED = -4;
const MojoResult MOJO_RESULT_NOT_FOUND = -5;
const MojoResult MOJO_RESULT_ALREADY_EXISTS = -6;
const MojoResult MOJO_RESULT_PERMISSION_DENIED = -7;
const MojoResult MOJO_RESULT_RESOURCE_EXHAUSTED = -8;
const MojoResult MOJO_RESULT_FAILED_PRECONDITION = -9;
const MojoResult MOJO_RESULT_ABORTED = -10;
const MojoResult MOJO_RESULT_OUT_OF_RANGE = -11;
const MojoResult MOJO_RESULT_UNIMPLEMENTED = -12;
const MojoResult MOJO_RESULT_INTERNAL = -13;
const MojoResult MOJO_RESULT_UNAVAILABLE = -14;
const MojoResult MOJO_RESULT_DATA_LOSS = -15;
const MojoResult MOJO_RESULT_BUSY = -16;
const MojoResult MOJO_RESULT_SHOULD_WAIT = -17;
#else
#define MOJO_RESULT_OK ((MojoResult) 0)
#define MOJO_RESULT_CANCELLED ((MojoResult) -1)
#define MOJO_RESULT_UNKNOWN ((MojoResult) -2)
#define MOJO_RESULT_INVALID_ARGUMENT ((MojoResult) -3)
#define MOJO_RESULT_DEADLINE_EXCEEDED ((MojoResult) -4)
#define MOJO_RESULT_NOT_FOUND ((MojoResult) -5)
#define MOJO_RESULT_ALREADY_EXISTS ((MojoResult) -6)
#define MOJO_RESULT_PERMISSION_DENIED ((MojoResult) -7)
#define MOJO_RESULT_RESOURCE_EXHAUSTED ((MojoResult) -8)
#define MOJO_RESULT_FAILED_PRECONDITION ((MojoResult) -9)
#define MOJO_RESULT_ABORTED ((MojoResult) -10)
#define MOJO_RESULT_OUT_OF_RANGE ((MojoResult) -11)
#define MOJO_RESULT_UNIMPLEMENTED ((MojoResult) -12)
#define MOJO_RESULT_INTERNAL ((MojoResult) -13)
#define MOJO_RESULT_UNAVAILABLE ((MojoResult) -14)
#define MOJO_RESULT_DATA_LOSS ((MojoResult) -15)
#define MOJO_RESULT_BUSY ((MojoResult) -16)
#define MOJO_RESULT_SHOULD_WAIT ((MojoResult) -17)
#endif
// |MojoDeadline|: Used to specify deadlines (timeouts), in microseconds (except
// for |MOJO_DEADLINE_INDEFINITE|).
// |MOJO_DEADLINE_INDEFINITE| - Used to indicate "forever".
typedef uint64_t MojoDeadline;
#ifdef __cplusplus
const MojoDeadline MOJO_DEADLINE_INDEFINITE = static_cast<MojoDeadline>(-1);
#else
#define MOJO_DEADLINE_INDEFINITE ((MojoDeadline) -1)
#endif
// |MojoWaitFlags|: Used to specify the state of a handle to wait on (e.g., the
// ability to read or write to it).
// |MOJO_WAIT_FLAG_NONE| - No flags. |MojoWait()|, etc. will return
// |MOJO_RESULT_FAILED_PRECONDITION| if you attempt to wait on this.
// |MOJO_WAIT_FLAG_READABLE| - Can read (e.g., a message) from the handle.
// |MOJO_WAIT_FLAG_WRITABLE| - Can write (e.g., a message) to the handle.
// |MOJO_WAIT_FLAG_EVERYTHING| - All flags.
typedef uint32_t MojoWaitFlags;
#ifdef __cplusplus
const MojoWaitFlags MOJO_WAIT_FLAG_NONE = 0;
const MojoWaitFlags MOJO_WAIT_FLAG_READABLE = 1 << 0;
const MojoWaitFlags MOJO_WAIT_FLAG_WRITABLE = 1 << 1;
const MojoWaitFlags MOJO_WAIT_FLAG_EVERYTHING = ~0;
#else
#define MOJO_WAIT_FLAG_NONE ((MojoWaitFlags) 0)
#define MOJO_WAIT_FLAG_READABLE ((MojoWaitFlags) 1 << 0)
#define MOJO_WAIT_FLAG_WRITABLE ((MojoWaitFlags) 1 << 1)
#define MOJO_WAIT_FLAG_EVERYTHING (~((MojoWaitFlags) 0))
#endif
#endif // MOJO_PUBLIC_C_SYSTEM_TYPES_H_
......@@ -16,7 +16,7 @@
#include "base/synchronization/lock.h"
#include "base/threading/thread_checker.h"
#include "mojo/embedder/scoped_platform_handle.h"
#include "mojo/public/c/system/core.h"
#include "mojo/public/c/system/types.h"
#include "mojo/system/message_in_transit.h"
#include "mojo/system/message_pipe.h"
#include "mojo/system/raw_channel.h"
......
......@@ -8,7 +8,6 @@
#include "base/logging.h"
#include "base/time/time.h"
#include "mojo/public/c/system/core.h"
#include "mojo/system/constants.h"
#include "mojo/system/data_pipe.h"
#include "mojo/system/data_pipe_consumer_dispatcher.h"
......
......@@ -9,6 +9,8 @@
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/synchronization/lock.h"
#include "mojo/public/c/system/core.h"
#include "mojo/public/c/system/types.h"
#include "mojo/system/handle_table.h"
#include "mojo/system/mapping_table.h"
#include "mojo/system/system_impl_export.h"
......
......@@ -8,7 +8,7 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/synchronization/lock.h"
#include "mojo/public/c/system/core.h"
#include "mojo/public/c/system/types.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace mojo {
......
......@@ -11,7 +11,7 @@
#include "base/containers/hash_tables.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "mojo/public/c/system/core.h"
#include "mojo/public/c/system/types.h"
#include "mojo/system/system_impl_export.h"
namespace mojo {
......
......@@ -12,7 +12,7 @@
#include "base/containers/hash_tables.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "mojo/public/c/system/core.h"
#include "mojo/public/c/system/types.h"
#include "mojo/system/system_impl_export.h"
namespace mojo {
......
......@@ -8,7 +8,7 @@
#include "base/basictypes.h"
#include "base/synchronization/condition_variable.h"
#include "base/synchronization/lock.h"
#include "mojo/public/c/system/core.h"
#include "mojo/public/c/system/types.h"
#include "mojo/system/system_impl_export.h"
namespace mojo {
......
......@@ -8,7 +8,7 @@
#include <list>
#include "base/basictypes.h"
#include "mojo/public/c/system/core.h"
#include "mojo/public/c/system/types.h"
#include "mojo/system/system_impl_export.h"
namespace mojo {
......
......@@ -9,7 +9,7 @@
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/threading/simple_thread.h"
#include "mojo/public/c/system/core.h"
#include "mojo/public/c/system/types.h"
#include "mojo/system/dispatcher.h"
#include "mojo/system/waiter.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment