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

Unified Diff: components/filesystem/file_system_impl.cc

Issue 1225673006: Revert of mandoline filesystem: Save cookie data to the mojo:filesystem. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sqlite-fs
Patch Set: Created 5 years, 5 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/file_system_impl.cc
diff --git a/components/filesystem/file_system_impl.cc b/components/filesystem/file_system_impl.cc
index 69d63301ddfb5510cfb633fbb79e9c375656015d..cfd4cace55f22c871bcc1c703aa7118f13f1441e 100644
--- a/components/filesystem/file_system_impl.cc
+++ b/components/filesystem/file_system_impl.cc
@@ -4,41 +4,15 @@
#include "components/filesystem/file_system_impl.h"
-#include "base/command_line.h"
#include "base/files/file_path.h"
-#include "base/files/file_util.h"
#include "base/files/scoped_file.h"
#include "base/files/scoped_temp_dir.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "components/filesystem/directory_impl.h"
#include "mojo/application/public/cpp/application_connection.h"
-#include "url/gurl.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 filesystem {
-
-namespace {
-
-const char kEscapeChar = ',';
-
-const char kUserDataDir[] = "user-data-dir";
-
-} // namespace filesystem
FileSystemImpl::FileSystemImpl(mojo::ApplicationConnection* connection,
mojo::InterfaceRequest<FileSystem> request)
@@ -60,23 +34,8 @@
CHECK(temp_dir->CreateUniqueTempDir());
path = temp_dir->path();
} else if (file_system.get() == std::string("origin")) {
- base::FilePath base_profile_dir = GetSystemProfileDir();
-
- // Sanitize the url for disk access.
- //
- // TODO(erg): While it's currently impossible, we need to deal with http://
- // URLs that have a path. (Or make the decision that these file systems are
- // path bound, not origin bound.)
- std::string sanitized_origin;
- BuildSanitizedOrigin(remote_application_url_, &sanitized_origin);
-
-#if defined(OS_WIN)
- path = base_profile_dir.Append(base::UTF8ToWide(sanitized_origin));
-#else
- path = base_profile_dir.Append(sanitized_origin);
-#endif
- if (!base::PathExists(path))
- base::CreateDirectory(path);
+ // TODO(erg): We should serve a persistent directory based on the
+ // subdirectory |remote_application_url_| of a profile directory.
}
if (!path.empty()) {
@@ -87,67 +46,4 @@
}
}
-base::FilePath FileSystemImpl::GetSystemProfileDir() const {
- 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;
-}
-
-void FileSystemImpl::BuildSanitizedOrigin(
- const std::string& origin,
- std::string* sanitized_origin) {
- // We take the origin string, and encode it in a way safe for filesystem
- // access. This is vaguely based on //net/tools/dump_cache/
- // url_to_filename_encoder.h; that file strips out schemes, and does weird
- // things with subdirectories. We do follow the basic algorithm used there,
- // including using ',' as our escape character.
- for (size_t i = 0; i < origin.length(); ++i) {
- unsigned char ch = origin[i];
- char encoded[3];
- int encoded_len;
- if ((ch == '_') || (ch == '.') || (ch == '=') || (ch == '+') ||
- (ch == '-') || (('0' <= ch) && (ch <= '9')) ||
- (('A' <= ch) && (ch <= 'Z')) || (('a' <= ch) && (ch <= 'z'))) {
- encoded[0] = ch;
- encoded_len = 1;
- } else {
- encoded[0] = kEscapeChar;
- encoded[1] = ch / 16;
- encoded[1] += (encoded[1] >= 10) ? 'A' - 10 : '0';
- encoded[2] = ch % 16;
- encoded[2] += (encoded[2] >= 10) ? 'A' - 10 : '0';
- encoded_len = 3;
- }
- sanitized_origin->append(encoded, encoded_len);
- }
-}
-
} // namespace filesystem
« no previous file with comments | « components/filesystem/file_system_impl.h ('k') | mandoline/services/core_services/core_services_application_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698