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

Side by Side Diff: mojo/services/files/public/c/lib/directory_wrapper.cc

Issue 1375313006: For c++, Generate enum classes instead of enum from mojom. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 2 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "files/public/c/lib/directory_wrapper.h" 5 #include "files/public/c/lib/directory_wrapper.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 8
9 #include "files/public/c/lib/errno_impl.h" 9 #include "files/public/c/lib/errno_impl.h"
10 #include "files/public/c/lib/file_fd_impl.h" 10 #include "files/public/c/lib/file_fd_impl.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 mojo_open_flags |= mojo::files::kOpenFlagTruncate; 64 mojo_open_flags |= mojo::files::kOpenFlagTruncate;
65 if ((oflag & MOJIO_O_APPEND)) 65 if ((oflag & MOJIO_O_APPEND))
66 mojo_open_flags |= mojo::files::kOpenFlagAppend; 66 mojo_open_flags |= mojo::files::kOpenFlagAppend;
67 // TODO(vtl): What should we do we open flags we don't support? And invalid 67 // TODO(vtl): What should we do we open flags we don't support? And invalid
68 // flags? 68 // flags?
69 69
70 // TODO(vtl): We currently totally ignore |mode|; maybe we should do something 70 // TODO(vtl): We currently totally ignore |mode|; maybe we should do something
71 // with it? 71 // with it?
72 72
73 mojo::files::FilePtr file; 73 mojo::files::FilePtr file;
74 mojo::files::Error error = mojo::files::ERROR_INTERNAL; 74 mojo::files::Error error = mojo::files::Error::INTERNAL;
75 directory_->OpenFile(path, mojo::GetProxy(&file), mojo_open_flags, 75 directory_->OpenFile(path, mojo::GetProxy(&file), mojo_open_flags,
76 Capture(&error)); 76 Capture(&error));
77 if (!directory_.WaitForIncomingResponse()) { 77 if (!directory_.WaitForIncomingResponse()) {
78 // This may be somewhat surprising. The implication is that the CWD is 78 // This may be somewhat surprising. The implication is that the CWD is
79 // stale, which may be a little strange. 79 // stale, which may be a little strange.
80 errno_setter.Set(ESTALE); 80 errno_setter.Set(ESTALE);
81 return nullptr; 81 return nullptr;
82 } 82 }
83 if (!errno_setter.Set(ErrorToErrno(error))) 83 if (!errno_setter.Set(ErrorToErrno(error)))
84 return nullptr; 84 return nullptr;
85 // C++11, why don't you have make_unique? 85 // C++11, why don't you have make_unique?
86 return std::unique_ptr<FDImpl>(new FileFDImpl(errno_impl_, file.Pass())); 86 return std::unique_ptr<FDImpl>(new FileFDImpl(errno_impl_, file.Pass()));
87 } 87 }
88 88
89 bool DirectoryWrapper::Chdir(const char* path) { 89 bool DirectoryWrapper::Chdir(const char* path) {
90 ErrnoImpl::Setter errno_setter(errno_impl_); 90 ErrnoImpl::Setter errno_setter(errno_impl_);
91 91
92 if (!path) 92 if (!path)
93 return errno_setter.Set(EFAULT); 93 return errno_setter.Set(EFAULT);
94 94
95 mojo::files::DirectoryPtr new_directory; 95 mojo::files::DirectoryPtr new_directory;
96 mojo::files::Error error = mojo::files::ERROR_INTERNAL; 96 mojo::files::Error error = mojo::files::Error::INTERNAL;
97 directory_->OpenDirectory( 97 directory_->OpenDirectory(
98 path, mojo::GetProxy(&new_directory), 98 path, mojo::GetProxy(&new_directory),
99 mojo::files::kOpenFlagRead | mojo::files::kOpenFlagWrite, 99 mojo::files::kOpenFlagRead | mojo::files::kOpenFlagWrite,
100 Capture(&error)); 100 Capture(&error));
101 if (!directory_.WaitForIncomingResponse()) { 101 if (!directory_.WaitForIncomingResponse()) {
102 // This may be somewhat surprising. The implication is that the CWD is 102 // This may be somewhat surprising. The implication is that the CWD is
103 // stale, which may be a little strange. 103 // stale, which may be a little strange.
104 return errno_setter.Set(ESTALE); 104 return errno_setter.Set(ESTALE);
105 } 105 }
106 if (!errno_setter.Set(ErrorToErrno(error))) 106 if (!errno_setter.Set(ErrorToErrno(error)))
107 return false; 107 return false;
108 directory_ = new_directory.Pass(); 108 directory_ = new_directory.Pass();
109 return true; 109 return true;
110 } 110 }
111 111
112 } // namespace mojio 112 } // namespace mojio
OLDNEW
« no previous file with comments | « mojo/public/tools/bindings/generators/mojom_cpp_generator.py ('k') | mojo/services/files/public/c/lib/file_fd_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698