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

Side by Side Diff: components/filesystem/file_system_app.cc

Issue 1737933002: mojo leveldb: Get profile and leveldb connected to DOMStorageContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: gyp-ify all the tracing stuff. Created 4 years, 9 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 "components/filesystem/file_system_app.h" 5 #include "components/filesystem/file_system_app.h"
6 6
7 #include "base/command_line.h" 7 #include "base/logging.h"
8 #include "base/files/file_path.h"
9 #include "base/files/file_util.h"
10 #include "mojo/shell/public/cpp/connection.h" 8 #include "mojo/shell/public/cpp/connection.h"
11 #include "mojo/shell/public/cpp/shell.h" 9 #include "mojo/shell/public/cpp/shell.h"
12 10
13 #if defined(OS_WIN)
14 #include "base/base_paths_win.h"
15 #include "base/path_service.h"
16 #include "base/strings/utf_string_conversions.h"
17 #elif defined(OS_ANDROID)
18 #include "base/base_paths_android.h"
19 #include "base/path_service.h"
20 #elif defined(OS_LINUX)
21 #include "base/environment.h"
22 #include "base/nix/xdg_util.h"
23 #elif defined(OS_MACOSX)
24 #include "base/base_paths_mac.h"
25 #include "base/path_service.h"
26 #endif
27
28 namespace filesystem { 11 namespace filesystem {
29 12
30 namespace { 13 scoped_ptr<mojo::ShellClient> CreateFileSystemApp(
14 const base::FilePath& persistent_dir) {
15 return make_scoped_ptr(new FileSystemApp(persistent_dir));
16 }
31 17
32 const char kUserDataDir[] = "user-data-dir"; 18 FileSystemApp::FileSystemApp(const base::FilePath& persistent_dir)
33 19 : shell_(nullptr),
34 } // namespace filesystem 20 lock_table_(new LockTable),
michaeln 2016/02/26 21:59:24 This only works if there's only one filesystem ven
Elliot Glaysher 2016/03/02 23:06:19 Two points: - The filesystem app was meant to be
35 21 persistent_dir_(persistent_dir) {
36 FileSystemApp::FileSystemApp() 22 }
37 : shell_(nullptr), lock_table_(new LockTable) {}
38 23
39 FileSystemApp::~FileSystemApp() {} 24 FileSystemApp::~FileSystemApp() {}
40 25
41 void FileSystemApp::Initialize(mojo::Shell* shell, const std::string& url, 26 void FileSystemApp::Initialize(mojo::Shell* shell, const std::string& url,
42 uint32_t id, uint32_t user_id) { 27 uint32_t id, uint32_t user_id) {
43 shell_ = shell; 28 shell_ = shell;
44 tracing_.Initialize(shell, url); 29 tracing_.Initialize(shell, url);
45 } 30 }
46 31
47 bool FileSystemApp::AcceptConnection(mojo::Connection* connection) { 32 bool FileSystemApp::AcceptConnection(mojo::Connection* connection) {
48 connection->AddInterface<FileSystem>(this); 33 connection->AddInterface<FileSystem>(this);
49 return true; 34 return true;
50 } 35 }
51 36
52 // |InterfaceFactory<Files>| implementation: 37 // |InterfaceFactory<Files>| implementation:
53 void FileSystemApp::Create(mojo::Connection* connection, 38 void FileSystemApp::Create(mojo::Connection* connection,
54 mojo::InterfaceRequest<FileSystem> request) { 39 mojo::InterfaceRequest<FileSystem> request) {
55 new FileSystemImpl(connection, std::move(request), GetUserDataDir(), 40 new FileSystemImpl(connection, std::move(request), persistent_dir_,
56 lock_table_.get()); 41 lock_table_.get());
57 } 42 }
58 43
59 //static
60 base::FilePath FileSystemApp::GetUserDataDir() {
61 base::FilePath path;
62
63 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
64 if (command_line->HasSwitch(kUserDataDir)) {
65 path = command_line->GetSwitchValuePath(kUserDataDir);
66 } else {
67 #if defined(OS_WIN)
68 CHECK(PathService::Get(base::DIR_LOCAL_APP_DATA, &path));
69 path = path.Append(FILE_PATH_LITERAL("mandoline"));
70 #elif defined(OS_LINUX)
71 scoped_ptr<base::Environment> env(base::Environment::Create());
72 base::FilePath config_dir(
73 base::nix::GetXDGDirectory(env.get(),
74 base::nix::kXdgConfigHomeEnvVar,
75 base::nix::kDotConfigDir));
76 path = config_dir.Append("mandoline");
77 #elif defined(OS_MACOSX)
78 CHECK(PathService::Get(base::DIR_APP_DATA, &path));
79 path = path.Append("Mandoline Shell");
80 #elif defined(OS_ANDROID)
81 CHECK(PathService::Get(base::DIR_ANDROID_APP_DATA, &path));
82 path = path.Append(FILE_PATH_LITERAL("mandoline"));
83 #else
84 NOTIMPLEMENTED();
85 #endif
86 }
87
88 if (!base::PathExists(path))
89 base::CreateDirectory(path);
90
91 return path;
92 }
93
94 } // namespace filesystem 44 } // namespace filesystem
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698