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 "components/filesystem/file_system_app.h" | 5 #include "components/filesystem/file_system_app.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
| 12 #include "mojo/public/cpp/bindings/strong_binding.h" |
12 #include "services/shell/public/cpp/connection.h" | 13 #include "services/shell/public/cpp/connection.h" |
13 #include "services/shell/public/cpp/connector.h" | 14 #include "services/shell/public/cpp/connector.h" |
14 | 15 |
15 #if defined(OS_WIN) | 16 #if defined(OS_WIN) |
16 #include "base/base_paths_win.h" | 17 #include "base/base_paths_win.h" |
17 #include "base/path_service.h" | 18 #include "base/path_service.h" |
18 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
19 #elif defined(OS_ANDROID) | 20 #elif defined(OS_ANDROID) |
20 #include "base/base_paths_android.h" | 21 #include "base/base_paths_android.h" |
21 #include "base/path_service.h" | 22 #include "base/path_service.h" |
(...skipping 22 matching lines...) Expand all Loading... |
44 } | 45 } |
45 | 46 |
46 bool FileSystemApp::OnConnect(const shell::Identity& remote_identity, | 47 bool FileSystemApp::OnConnect(const shell::Identity& remote_identity, |
47 shell::InterfaceRegistry* registry) { | 48 shell::InterfaceRegistry* registry) { |
48 registry->AddInterface<mojom::FileSystem>(this); | 49 registry->AddInterface<mojom::FileSystem>(this); |
49 return true; | 50 return true; |
50 } | 51 } |
51 | 52 |
52 // |InterfaceFactory<Files>| implementation: | 53 // |InterfaceFactory<Files>| implementation: |
53 void FileSystemApp::Create(const shell::Identity& remote_identity, | 54 void FileSystemApp::Create(const shell::Identity& remote_identity, |
54 mojo::InterfaceRequest<mojom::FileSystem> request) { | 55 mojom::FileSystemRequest request) { |
55 new FileSystemImpl(remote_identity, std::move(request), GetUserDataDir(), | 56 mojo::MakeStrongBinding(base::MakeUnique<FileSystemImpl>( |
56 lock_table_); | 57 remote_identity, GetUserDataDir(), lock_table_), |
| 58 std::move(request)); |
57 } | 59 } |
58 | 60 |
59 //static | 61 //static |
60 base::FilePath FileSystemApp::GetUserDataDir() { | 62 base::FilePath FileSystemApp::GetUserDataDir() { |
61 base::FilePath path; | 63 base::FilePath path; |
62 | 64 |
63 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 65 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
64 if (command_line->HasSwitch(kUserDataDir)) { | 66 if (command_line->HasSwitch(kUserDataDir)) { |
65 path = command_line->GetSwitchValuePath(kUserDataDir); | 67 path = command_line->GetSwitchValuePath(kUserDataDir); |
66 } else { | 68 } else { |
(...skipping 14 matching lines...) Expand all Loading... |
81 path = path.Append(FILE_PATH_LITERAL("filesystem")); | 83 path = path.Append(FILE_PATH_LITERAL("filesystem")); |
82 } | 84 } |
83 | 85 |
84 if (!base::PathExists(path)) | 86 if (!base::PathExists(path)) |
85 base::CreateDirectory(path); | 87 base::CreateDirectory(path); |
86 | 88 |
87 return path; | 89 return path; |
88 } | 90 } |
89 | 91 |
90 } // namespace filesystem | 92 } // namespace filesystem |
OLD | NEW |