summaryrefslogtreecommitdiffstats
path: root/base/platform_file.h
diff options
context:
space:
mode:
authormiket@chromium.org <miket@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-30 02:31:14 +0000
committermiket@chromium.org <miket@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-30 02:31:14 +0000
commit2404a282786943958a5fce4cd111dfa538ae0a33 (patch)
tree76766187f6f5c6d26dde3dd46da3ec36b30f6a6e /base/platform_file.h
parentfcd3a7a671ecf2d5f46ea34787d27507a914d2f5 (diff)
downloadchromium_src-2404a282786943958a5fce4cd111dfa538ae0a33.zip
chromium_src-2404a282786943958a5fce4cd111dfa538ae0a33.tar.gz
chromium_src-2404a282786943958a5fce4cd111dfa538ae0a33.tar.bz2
Implement serial API for Windows.
- Got it working using PlatformFile. - Noticed threading-constraint violations; refactored APIResourceController to allow for its resources to exist on different threads, depending on the resource type. - Wondered why I wasn't using PlatformFile for the POSIX version, which would have caused me to build the POSIX version on the file thread to being with. - Fixed that. - Once things were working, observed that serial was not yet using ArrayBuffer. Fixed that. - Simplified ExtensionService's relationship with APIResourceController. - Hardcode all platforms to set bitrate of 57600. BUG=129391,129483 TEST=Widened scope of existing tests, manually tested with Arduino Review URL: https://chromiumcodereview.appspot.com/10392181 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139463 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/platform_file.h')
-rw-r--r--base/platform_file.h53
1 files changed, 32 insertions, 21 deletions
diff --git a/base/platform_file.h b/base/platform_file.h
index 2bfd181..0d66d28 100644
--- a/base/platform_file.h
+++ b/base/platform_file.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -32,26 +32,29 @@ const PlatformFile kInvalidPlatformFileValue = -1;
// exactly one of the five (possibly combining with other flags) when opening
// or creating a file.
enum PlatformFileFlags {
- PLATFORM_FILE_OPEN = 1, // Opens a file, only if it exists.
- PLATFORM_FILE_CREATE = 2, // Creates a new file, only if it does not
- // already exist.
- PLATFORM_FILE_OPEN_ALWAYS = 4, // May create a new file.
- PLATFORM_FILE_CREATE_ALWAYS = 8, // May overwrite an old file.
- PLATFORM_FILE_OPEN_TRUNCATED = 16, // Opens a file and truncates it, only if
- // it exists.
- PLATFORM_FILE_READ = 32,
- PLATFORM_FILE_WRITE = 64,
- PLATFORM_FILE_EXCLUSIVE_READ = 128, // EXCLUSIVE is opposite of Windows SHARE
- PLATFORM_FILE_EXCLUSIVE_WRITE = 256,
- PLATFORM_FILE_ASYNC = 512,
- PLATFORM_FILE_TEMPORARY = 1024, // Used on Windows only
- PLATFORM_FILE_HIDDEN = 2048, // Used on Windows only
- PLATFORM_FILE_DELETE_ON_CLOSE = 4096,
-
- PLATFORM_FILE_WRITE_ATTRIBUTES = 8192, // Used on Windows only
- PLATFORM_FILE_ENUMERATE = 16384, // May enumerate directory
-
- PLATFORM_FILE_SHARE_DELETE = 32768, // Used on Windows only
+ PLATFORM_FILE_OPEN = 1 << 0, // Opens a file, only if it exists.
+ PLATFORM_FILE_CREATE = 1 << 1, // Creates a new file, only if it
+ // does not already exist.
+ PLATFORM_FILE_OPEN_ALWAYS = 1 << 2, // May create a new file.
+ PLATFORM_FILE_CREATE_ALWAYS = 1 << 3, // May overwrite an old file.
+ PLATFORM_FILE_OPEN_TRUNCATED = 1 << 4, // Opens a file and truncates it,
+ // only if it exists.
+ PLATFORM_FILE_READ = 1 << 5,
+ PLATFORM_FILE_WRITE = 1 << 6,
+ PLATFORM_FILE_EXCLUSIVE_READ = 1 << 7, // EXCLUSIVE is opposite of Windows
+ // SHARE
+ PLATFORM_FILE_EXCLUSIVE_WRITE = 1 << 8,
+ PLATFORM_FILE_ASYNC = 1 << 9,
+ PLATFORM_FILE_TEMPORARY = 1 << 10, // Used on Windows only
+ PLATFORM_FILE_HIDDEN = 1 << 11, // Used on Windows only
+ PLATFORM_FILE_DELETE_ON_CLOSE = 1 << 12,
+
+ PLATFORM_FILE_WRITE_ATTRIBUTES = 1 << 13, // Used on Windows only
+ PLATFORM_FILE_ENUMERATE = 1 << 14, // May enumerate directory
+
+ PLATFORM_FILE_SHARE_DELETE = 1 << 15, // Used on Windows only
+
+ PLATFORM_FILE_TERMINAL_DEVICE = 1 << 16, // Serial port flags
};
// PLATFORM_FILE_ERROR_ACCESS_DENIED is returned when a call fails because of
@@ -124,6 +127,10 @@ BASE_EXPORT bool ClosePlatformFile(PlatformFile file);
BASE_EXPORT int ReadPlatformFile(PlatformFile file, int64 offset,
char* data, int size);
+// Same as above but without seek.
+BASE_EXPORT int ReadPlatformFileAtCurrentPos(PlatformFile file,
+ char* data, int size);
+
// Reads the given number of bytes (or until EOF is reached) starting with the
// given offset, but does not make any effort to read all data on all platforms.
// Returns the number of bytes read, or -1 on error.
@@ -137,6 +144,10 @@ BASE_EXPORT int ReadPlatformFileNoBestEffort(PlatformFile file, int64 offset,
BASE_EXPORT int WritePlatformFile(PlatformFile file, int64 offset,
const char* data, int size);
+// Save as above but without seek.
+BASE_EXPORT int WritePlatformFileAtCurrentPos(PlatformFile file,
+ const char* data, int size);
+
// Truncates the given file to the given length. If |length| is greater than
// the current size of the file, the file is extended with zeros. If the file
// doesn't exist, |false| is returned.