OLD | NEW |
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 "services/files/files_impl.h" | 5 #include "services/files/files_impl.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <sys/stat.h> | 10 #include <sys/stat.h> |
11 #include <sys/types.h> | 11 #include <sys/types.h> |
12 #include <unistd.h> | 12 #include <unistd.h> |
13 | 13 |
14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
15 #include "base/files/scoped_file.h" | 15 #include "base/files/scoped_file.h" |
16 #include "base/files/scoped_temp_dir.h" | 16 #include "base/files/scoped_temp_dir.h" |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
19 #include "base/posix/eintr_wrapper.h" | 19 #include "base/posix/eintr_wrapper.h" |
20 #include "base/sha1.h" | 20 #include "base/sha1.h" |
21 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
22 #include "mojo/public/cpp/application/application_connection.h" | 22 #include "mojo/public/cpp/application/connection_context.h" |
23 #include "services/files/directory_impl.h" | 23 #include "services/files/directory_impl.h" |
24 | 24 |
25 namespace mojo { | 25 namespace mojo { |
26 namespace files { | 26 namespace files { |
27 | 27 |
28 namespace { | 28 namespace { |
29 | 29 |
30 base::ScopedFD CreateAndOpenTemporaryDirectory( | 30 base::ScopedFD CreateAndOpenTemporaryDirectory( |
31 scoped_ptr<base::ScopedTempDir>* temp_dir) { | 31 scoped_ptr<base::ScopedTempDir>* temp_dir) { |
32 (*temp_dir).reset(new base::ScopedTempDir()); | 32 (*temp_dir).reset(new base::ScopedTempDir()); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 base::FilePath mojo_debug_dir_name = GetHomeRelativePath("MojoDebug"); | 92 base::FilePath mojo_debug_dir_name = GetHomeRelativePath("MojoDebug"); |
93 if (mojo_debug_dir_name.empty()) | 93 if (mojo_debug_dir_name.empty()) |
94 return base::ScopedFD(); | 94 return base::ScopedFD(); |
95 return base::ScopedFD(HANDLE_EINTR( | 95 return base::ScopedFD(HANDLE_EINTR( |
96 open(mojo_debug_dir_name.value().c_str(), O_RDONLY | O_DIRECTORY, 0))); | 96 open(mojo_debug_dir_name.value().c_str(), O_RDONLY | O_DIRECTORY, 0))); |
97 } | 97 } |
98 #endif | 98 #endif |
99 | 99 |
100 } // namespace | 100 } // namespace |
101 | 101 |
102 FilesImpl::FilesImpl(ApplicationConnection* connection, | 102 FilesImpl::FilesImpl(const ConnectionContext& connection_context, |
103 InterfaceRequest<Files> request) | 103 InterfaceRequest<Files> request) |
104 : client_url_(connection->GetRemoteApplicationURL()), | 104 : client_url_(connection_context.remote_url), |
105 binding_(this, request.Pass()) {} | 105 binding_(this, request.Pass()) {} |
106 | 106 |
107 FilesImpl::~FilesImpl() {} | 107 FilesImpl::~FilesImpl() {} |
108 | 108 |
109 void FilesImpl::OpenFileSystem(const mojo::String& file_system, | 109 void FilesImpl::OpenFileSystem(const mojo::String& file_system, |
110 InterfaceRequest<Directory> directory, | 110 InterfaceRequest<Directory> directory, |
111 const OpenFileSystemCallback& callback) { | 111 const OpenFileSystemCallback& callback) { |
112 base::ScopedFD dir_fd; | 112 base::ScopedFD dir_fd; |
113 // Set only if the |DirectoryImpl| will own a temporary directory. | 113 // Set only if the |DirectoryImpl| will own a temporary directory. |
114 scoped_ptr<base::ScopedTempDir> temp_dir; | 114 scoped_ptr<base::ScopedTempDir> temp_dir; |
(...skipping 27 matching lines...) Expand all Loading... |
142 callback.Run(Error::UNIMPLEMENTED); | 142 callback.Run(Error::UNIMPLEMENTED); |
143 return; | 143 return; |
144 } | 144 } |
145 | 145 |
146 new DirectoryImpl(directory.Pass(), dir_fd.Pass(), temp_dir.Pass()); | 146 new DirectoryImpl(directory.Pass(), dir_fd.Pass(), temp_dir.Pass()); |
147 callback.Run(Error::OK); | 147 callback.Run(Error::OK); |
148 } | 148 } |
149 | 149 |
150 } // namespace files | 150 } // namespace files |
151 } // namespace mojo | 151 } // namespace mojo |
OLD | NEW |