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

Side by Side Diff: ppapi/native_client/src/trusted/plugin/temporary_file.cc

Issue 413493002: Pepper: Simplify TempFile in trusted plugin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « ppapi/native_client/src/trusted/plugin/temporary_file.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ppapi/native_client/src/trusted/plugin/temporary_file.h" 5 #include "ppapi/native_client/src/trusted/plugin/temporary_file.h"
6 6
7 #include "native_client/src/include/portability_io.h" 7 #include "native_client/src/include/portability_io.h"
8 #include "native_client/src/shared/platform/nacl_check.h" 8 #include "native_client/src/shared/platform/nacl_check.h"
9 #include "native_client/src/trusted/service_runtime/include/sys/stat.h" 9 #include "native_client/src/trusted/service_runtime/include/sys/stat.h"
10 10
11 #include "ppapi/cpp/core.h" 11 #include "ppapi/cpp/core.h"
12 #include "ppapi/cpp/instance.h" 12 #include "ppapi/cpp/instance.h"
13 #include "ppapi/cpp/module.h" 13 #include "ppapi/cpp/module.h"
14 #include "ppapi/c/private/pp_file_handle.h" 14 #include "ppapi/c/private/pp_file_handle.h"
15 15
16 #include "ppapi/native_client/src/trusted/plugin/plugin.h" 16 #include "ppapi/native_client/src/trusted/plugin/plugin.h"
17 #include "ppapi/native_client/src/trusted/plugin/utility.h" 17 #include "ppapi/native_client/src/trusted/plugin/utility.h"
18 18
19 namespace plugin { 19 namespace plugin {
20 20
21 TempFile::TempFile(Plugin* plugin) : plugin_(plugin), 21 TempFile::TempFile(Plugin* plugin, PP_FileHandle handle)
22 internal_handle_(PP_kInvalidFileHandle) { 22 : plugin_(plugin), internal_handle_(handle) { }
23 }
24 23
25 TempFile::~TempFile() { } 24 TempFile::~TempFile() { }
26 25
27 int32_t TempFile::Open(bool writeable) { 26 int32_t TempFile::Open(bool writeable) {
28 // TODO(teravest): Clean up this Open() behavior; this is really confusing as
29 // written.
30 if (internal_handle_ == PP_kInvalidFileHandle) {
31 internal_handle_ =
32 plugin_->nacl_interface()->CreateTemporaryFile(plugin_->pp_instance());
33 }
34
35 if (internal_handle_ == PP_kInvalidFileHandle) { 27 if (internal_handle_ == PP_kInvalidFileHandle) {
36 PLUGIN_PRINTF(("TempFile::Open failed w/ PP_kInvalidFileHandle\n")); 28 PLUGIN_PRINTF(("TempFile::Open failed w/ PP_kInvalidFileHandle\n"));
37 return PP_ERROR_FAILED; 29 return PP_ERROR_FAILED;
38 } 30 }
39 31
40 #if NACL_WINDOWS 32 #if NACL_WINDOWS
41 HANDLE handle = internal_handle_; 33 HANDLE handle = internal_handle_;
42 34
43 //////// Now try the posix view. 35 //////// Now try the posix view.
44 int rdwr_flag = writeable ? _O_RDWR : _O_RDONLY; 36 int rdwr_flag = writeable ? _O_RDWR : _O_RDONLY;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 80
89 PP_FileHandle TempFile::TakeFileHandle() { 81 PP_FileHandle TempFile::TakeFileHandle() {
90 PP_FileHandle to_return = internal_handle_; 82 PP_FileHandle to_return = internal_handle_;
91 internal_handle_ = PP_kInvalidFileHandle; 83 internal_handle_ = PP_kInvalidFileHandle;
92 read_wrapper_.release(); 84 read_wrapper_.release();
93 write_wrapper_.release(); 85 write_wrapper_.release();
94 return to_return; 86 return to_return;
95 } 87 }
96 88
97 } // namespace plugin 89 } // namespace plugin
OLDNEW
« no previous file with comments | « ppapi/native_client/src/trusted/plugin/temporary_file.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698