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

Side by Side Diff: components/filesystem/main.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: Created 4 years, 10 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 "base/command_line.h"
6 #include "base/files/file_path.h"
7 #include "base/files/file_util.h"
5 #include "base/macros.h" 8 #include "base/macros.h"
6 #include "components/filesystem/file_system_app.h" 9 #include "components/filesystem/file_system_app.h"
7 #include "mojo/public/c/system/main.h" 10 #include "mojo/public/c/system/main.h"
8 #include "mojo/shell/public/cpp/application_runner.h" 11 #include "mojo/shell/public/cpp/application_runner.h"
9 12
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 {
29
30 const char kUserDataDir[] = "user-data-dir";
31
32 base::FilePath GetUserDataDir() {
33 base::FilePath path;
34
35 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
36 if (command_line->HasSwitch(kUserDataDir)) {
37 path = command_line->GetSwitchValuePath(kUserDataDir);
38 } else {
39 #if defined(OS_WIN)
40 CHECK(PathService::Get(base::DIR_LOCAL_APP_DATA, &path));
41 path = path.Append(FILE_PATH_LITERAL("mandoline"));
42 #elif defined(OS_LINUX)
43 scoped_ptr<base::Environment> env(base::Environment::Create());
44 base::FilePath config_dir(
45 base::nix::GetXDGDirectory(env.get(),
46 base::nix::kXdgConfigHomeEnvVar,
47 base::nix::kDotConfigDir));
48 path = config_dir.Append("mandoline");
49 #elif defined(OS_MACOSX)
50 CHECK(PathService::Get(base::DIR_APP_DATA, &path));
51 path = path.Append("Mandoline Shell");
52 #elif defined(OS_ANDROID)
53 CHECK(PathService::Get(base::DIR_ANDROID_APP_DATA, &path));
54 path = path.Append(FILE_PATH_LITERAL("mandoline"));
55 #else
56 NOTIMPLEMENTED();
57 #endif
58 }
59
60 if (!base::PathExists(path))
61 base::CreateDirectory(path);
62
63 return path;
64 }
65
66 } // namespace
67
10 MojoResult MojoMain(MojoHandle request) { 68 MojoResult MojoMain(MojoHandle request) {
11 mojo::ApplicationRunner runner(new filesystem::FileSystemApp()); 69 mojo::ApplicationRunner runner(
70 new filesystem::FileSystemApp(GetUserDataDir()));
12 return runner.Run(request); 71 return runner.Run(request);
13 } 72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698