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

Unified 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: gyp-ify all the tracing stuff. 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 side-by-side diff with in-line comments
Download patch
Index: components/filesystem/main.cc
diff --git a/components/filesystem/main.cc b/components/filesystem/main.cc
index 69be93f59c3367b88662191d8a369916b5aec5c1..27adae9e9c5028a0535f56e8e8b7c81d42b75d85 100644
--- a/components/filesystem/main.cc
+++ b/components/filesystem/main.cc
@@ -2,12 +2,71 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/command_line.h"
+#include "base/files/file_path.h"
+#include "base/files/file_util.h"
#include "base/macros.h"
#include "components/filesystem/file_system_app.h"
#include "mojo/public/c/system/main.h"
#include "mojo/shell/public/cpp/application_runner.h"
+#if defined(OS_WIN)
+#include "base/base_paths_win.h"
+#include "base/path_service.h"
+#include "base/strings/utf_string_conversions.h"
+#elif defined(OS_ANDROID)
+#include "base/base_paths_android.h"
+#include "base/path_service.h"
+#elif defined(OS_LINUX)
+#include "base/environment.h"
+#include "base/nix/xdg_util.h"
+#elif defined(OS_MACOSX)
+#include "base/base_paths_mac.h"
+#include "base/path_service.h"
+#endif
+
+namespace {
+
+const char kUserDataDir[] = "user-data-dir";
+
+base::FilePath GetUserDataDir() {
+ base::FilePath path;
+
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(kUserDataDir)) {
+ path = command_line->GetSwitchValuePath(kUserDataDir);
+ } else {
+#if defined(OS_WIN)
+ CHECK(PathService::Get(base::DIR_LOCAL_APP_DATA, &path));
+ path = path.Append(FILE_PATH_LITERAL("mandoline"));
+#elif defined(OS_LINUX)
+ scoped_ptr<base::Environment> env(base::Environment::Create());
+ base::FilePath config_dir(
+ base::nix::GetXDGDirectory(env.get(),
+ base::nix::kXdgConfigHomeEnvVar,
+ base::nix::kDotConfigDir));
+ path = config_dir.Append("mandoline");
+#elif defined(OS_MACOSX)
+ CHECK(PathService::Get(base::DIR_APP_DATA, &path));
+ path = path.Append("Mandoline Shell");
+#elif defined(OS_ANDROID)
+ CHECK(PathService::Get(base::DIR_ANDROID_APP_DATA, &path));
+ path = path.Append(FILE_PATH_LITERAL("mandoline"));
+#else
+ NOTIMPLEMENTED();
+#endif
+ }
+
+ if (!base::PathExists(path))
+ base::CreateDirectory(path);
+
+ return path;
+}
+
+} // namespace
+
MojoResult MojoMain(MojoHandle request) {
- mojo::ApplicationRunner runner(new filesystem::FileSystemApp());
+ mojo::ApplicationRunner runner(
+ new filesystem::FileSystemApp(GetUserDataDir()));
return runner.Run(request);
}

Powered by Google App Engine
This is Rietveld 408576698