summaryrefslogtreecommitdiffstats
path: root/components/filesystem
diff options
context:
space:
mode:
authorerg <erg@chromium.org>2016-02-22 11:58:34 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-22 19:59:51 +0000
commit2853a31774a299712b767eb75cda5ca95f4be8b5 (patch)
treeed389b9ad0a09a1a02053da41fc1fa1fa6db6cb9 /components/filesystem
parentc49766566d2285ed91e2d10cbafa5d16f5771f2b (diff)
downloadchromium_src-2853a31774a299712b767eb75cda5ca95f4be8b5.zip
chromium_src-2853a31774a299712b767eb75cda5ca95f4be8b5.tar.gz
chromium_src-2853a31774a299712b767eb75cda5ca95f4be8b5.tar.bz2
mojo: Get mojo:leveldb and mojo:filesystem compiled into content.
BUG=585587 Review URL: https://codereview.chromium.org/1708253004 Cr-Commit-Position: refs/heads/master@{#376779}
Diffstat (limited to 'components/filesystem')
-rw-r--r--components/filesystem/BUILD.gn7
-rw-r--r--components/filesystem/file_system_app.cc68
-rw-r--r--components/filesystem/file_system_app.h29
-rw-r--r--components/filesystem/file_system_impl.cc10
-rw-r--r--components/filesystem/file_system_impl.h4
-rw-r--r--components/filesystem/filesystem.gyp68
6 files changed, 78 insertions, 108 deletions
diff --git a/components/filesystem/BUILD.gn b/components/filesystem/BUILD.gn
index fe7bb2d..f9d9d05 100644
--- a/components/filesystem/BUILD.gn
+++ b/components/filesystem/BUILD.gn
@@ -11,8 +11,6 @@ source_set("lib") {
"directory_impl.h",
"file_impl.cc",
"file_impl.h",
- "file_system_app.cc",
- "file_system_app.h",
"file_system_impl.cc",
"file_system_impl.h",
"lock_table.cc",
@@ -27,7 +25,6 @@ source_set("lib") {
"//mojo/common",
"//mojo/common:common_base",
"//mojo/platform_handle",
- "//mojo/services/tracing/public/cpp",
"//mojo/shell/public/cpp",
"//mojo/shell/public/interfaces",
"//url",
@@ -36,6 +33,8 @@ source_set("lib") {
mojo_native_application("filesystem") {
sources = [
+ "file_system_app.cc",
+ "file_system_app.h",
"main.cc",
]
@@ -43,11 +42,13 @@ mojo_native_application("filesystem") {
":lib",
":manifest",
"//base",
+ "//components/filesystem/public/interfaces",
"//mojo/common",
"//mojo/environment:chromium",
"//mojo/platform_handle:for_shared_library",
"//mojo/public/cpp/bindings",
"//mojo/public/cpp/system",
+ "//mojo/services/tracing/public/cpp",
"//mojo/shell/public/cpp",
]
}
diff --git a/components/filesystem/file_system_app.cc b/components/filesystem/file_system_app.cc
index 344a7ca..d5d577a 100644
--- a/components/filesystem/file_system_app.cc
+++ b/components/filesystem/file_system_app.cc
@@ -4,17 +4,13 @@
#include "components/filesystem/file_system_app.h"
-#include <utility>
-
-#include "base/bind.h"
-#include "base/logging.h"
#include "mojo/shell/public/cpp/connection.h"
#include "mojo/shell/public/cpp/shell.h"
namespace filesystem {
FileSystemApp::FileSystemApp()
- : shell_(nullptr), lock_table_(new LockTable), in_shutdown_(false) {}
+ : shell_(nullptr), lock_table_(new LockTable) {}
FileSystemApp::~FileSystemApp() {}
@@ -29,70 +25,10 @@ bool FileSystemApp::AcceptConnection(mojo::Connection* connection) {
return true;
}
-void FileSystemApp::RegisterDirectoryToClient(DirectoryImpl* directory,
- FileSystemClientPtr client) {
- directory->set_connection_error_handler(
- base::Bind(&FileSystemApp::OnDirectoryConnectionError,
- base::Unretained(this),
- directory));
- client_mapping_.emplace_back(directory, std::move(client));
-}
-
-bool FileSystemApp::ShellConnectionLost() {
- if (client_mapping_.empty()) {
- // If we have no current connections, we can shutdown immediately.
- return true;
- }
-
- in_shutdown_ = true;
-
- // We have live connections. Send a notification to each one indicating that
- // they should shutdown.
- for (std::vector<Client>::iterator it = client_mapping_.begin();
- it != client_mapping_.end(); ++it) {
- it->fs_client_->OnFileSystemShutdown();
- }
-
- return false;
-}
-
// |InterfaceFactory<Files>| implementation:
void FileSystemApp::Create(mojo::Connection* connection,
mojo::InterfaceRequest<FileSystem> request) {
- new FileSystemImpl(this, connection, std::move(request), lock_table_.get());
-}
-
-void FileSystemApp::OnDirectoryConnectionError(DirectoryImpl* directory) {
- for (std::vector<Client>::iterator it = client_mapping_.begin();
- it != client_mapping_.end(); ++it) {
- if (it->directory_ == directory) {
- client_mapping_.erase(it);
-
- if (in_shutdown_ && client_mapping_.empty()) {
- // We just cleared the last directory after our shell connection went
- // away. Time to shut ourselves down.
- shell_->Quit();
- }
-
- return;
- }
- }
-}
-
-FileSystemApp::Client::Client(DirectoryImpl* directory,
- FileSystemClientPtr fs_client)
- : directory_(directory), fs_client_(std::move(fs_client)) {}
-
-FileSystemApp::Client::Client(Client&& rhs)
- : directory_(rhs.directory_), fs_client_(std::move(rhs.fs_client_)) {}
-
-FileSystemApp::Client::~Client() {}
-
-FileSystemApp::Client& FileSystemApp::Client::operator=(
- FileSystemApp::Client&& rhs) {
- directory_ = rhs.directory_;
- fs_client_ = std::move(rhs.fs_client_);
- return *this;
+ new FileSystemImpl(connection, std::move(request), lock_table_.get());
}
} // namespace filesystem
diff --git a/components/filesystem/file_system_app.h b/components/filesystem/file_system_app.h
index 402c359..ae62469 100644
--- a/components/filesystem/file_system_app.h
+++ b/components/filesystem/file_system_app.h
@@ -26,50 +26,21 @@ class FileSystemApp : public mojo::ShellClient,
FileSystemApp();
~FileSystemApp() override;
- // Called by individual FileSystem objects to register lifetime events.
- void RegisterDirectoryToClient(DirectoryImpl* directory,
- FileSystemClientPtr client);
-
private:
- // We set the DirectoryImpl's error handler to this function. We do this so
- // that we can QuitNow() once the last DirectoryImpl has closed itself.
- void OnDirectoryConnectionError(DirectoryImpl* directory);
-
// |mojo::ShellClient| override:
void Initialize(mojo::Shell* shell, const std::string& url,
uint32_t id) override;
bool AcceptConnection(mojo::Connection* connection) override;
- bool ShellConnectionLost() override;
// |InterfaceFactory<Files>| implementation:
void Create(mojo::Connection* connection,
mojo::InterfaceRequest<FileSystem> request) override;
- // Use a vector to work around map not letting us use FileSystemClientPtr as
- // a value in a std::map. The move constructors are to allow us to deal with
- // FileSystemClientPtr inside a vector.
- struct Client {
- Client(DirectoryImpl* directory, FileSystemClientPtr fs_client);
- Client(Client&& rhs);
- ~Client();
-
- Client& operator=(Client&& rhs);
-
- DirectoryImpl* directory_;
- FileSystemClientPtr fs_client_;
- };
- std::vector<Client> client_mapping_;
-
mojo::Shell* shell_;
mojo::TracingImpl tracing_;
scoped_ptr<LockTable> lock_table_;
- // Set to true when our shell connection is closed. On connection error, we
- // then broadcast a notification to all FileSystemClients that they should
- // shut down. Once the final one does, then we QuitNow().
- bool in_shutdown_;
-
DISALLOW_COPY_AND_ASSIGN(FileSystemApp);
};
diff --git a/components/filesystem/file_system_impl.cc b/components/filesystem/file_system_impl.cc
index 5a60c5c..cf444b3 100644
--- a/components/filesystem/file_system_impl.cc
+++ b/components/filesystem/file_system_impl.cc
@@ -16,7 +16,6 @@
#include "base/memory/scoped_ptr.h"
#include "build/build_config.h"
#include "components/filesystem/directory_impl.h"
-#include "components/filesystem/file_system_app.h"
#include "mojo/shell/public/cpp/connection.h"
#include "url/gurl.h"
@@ -45,12 +44,10 @@ const char kUserDataDir[] = "user-data-dir";
} // namespace filesystem
-FileSystemImpl::FileSystemImpl(FileSystemApp* app,
- mojo::Connection* connection,
+FileSystemImpl::FileSystemImpl(mojo::Connection* connection,
mojo::InterfaceRequest<FileSystem> request,
LockTable* lock_table)
- : app_(app),
- remote_application_url_(connection->GetRemoteApplicationURL()),
+ : remote_application_url_(connection->GetRemoteApplicationURL()),
binding_(this, std::move(request)),
lock_table_(lock_table) {}
@@ -89,9 +86,8 @@ void FileSystemImpl::OpenFileSystem(const mojo::String& file_system,
}
if (!path.empty()) {
- DirectoryImpl* dir_impl = new DirectoryImpl(
+ new DirectoryImpl(
std::move(directory), path, std::move(temp_dir), lock_table_);
- app_->RegisterDirectoryToClient(dir_impl, std::move(client));
callback.Run(FileError::OK);
} else {
callback.Run(FileError::FAILED);
diff --git a/components/filesystem/file_system_impl.h b/components/filesystem/file_system_impl.h
index 11ac05d..4c18dd5 100644
--- a/components/filesystem/file_system_impl.h
+++ b/components/filesystem/file_system_impl.h
@@ -25,8 +25,7 @@ class LockTable;
class FileSystemImpl : public FileSystem {
public:
- FileSystemImpl(FileSystemApp* app,
- mojo::Connection* connection,
+ FileSystemImpl(mojo::Connection* connection,
mojo::InterfaceRequest<FileSystem> request,
LockTable* lock_table);
~FileSystemImpl() override;
@@ -52,7 +51,6 @@ class FileSystemImpl : public FileSystem {
void BuildSanitizedOrigin(const std::string& origin,
std::string* sanitized_origin);
- FileSystemApp* app_;
const std::string remote_application_url_;
mojo::StrongBinding<FileSystem> binding_;
LockTable* lock_table_;
diff --git a/components/filesystem/filesystem.gyp b/components/filesystem/filesystem.gyp
new file mode 100644
index 0000000..718830d
--- /dev/null
+++ b/components/filesystem/filesystem.gyp
@@ -0,0 +1,68 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+ 'variables': {
+ # This turns on e.g. the filename-based detection of which
+ # platforms to include source files on (e.g. files ending in
+ # _mac.h or _mac.cc are only compiled on MacOSX).
+ 'chromium_code': 1,
+ },
+ 'targets': [
+ {
+ # GN version: //components/filesystem:lib
+ 'target_name': 'filesystem_lib',
+ 'type': 'static_library',
+ 'include_dirs': [
+ '../..',
+ ],
+ 'sources': [
+ 'directory_impl.cc',
+ 'directory_impl.h',
+ 'file_impl.cc',
+ 'file_impl.h',
+ 'file_system_impl.cc',
+ 'file_system_impl.h',
+ 'lock_table.cc',
+ 'lock_table.h',
+ 'util.cc',
+ 'util.h',
+ ],
+ 'dependencies': [
+ 'filesystem_bindings',
+ '../../mojo/mojo_base.gyp:mojo_application_base',
+ '../../mojo/mojo_edk.gyp:mojo_system_impl',
+ '../../mojo/mojo_public.gyp:mojo_cpp_bindings',
+ '../../mojo/mojo_platform_handle.gyp:platform_handle',
+ '../../url/url.gyp:url_lib',
+ ],
+ 'export_dependent_settings': [
+ 'filesystem_bindings',
+ ],
+ },
+ {
+ # GN version: //components/filesystem/public/interfaces
+ 'target_name': 'filesystem_bindings',
+ 'type': 'static_library',
+ 'dependencies': [
+ 'filesystem_bindings_mojom',
+ ],
+ },
+ {
+ 'target_name': 'filesystem_bindings_mojom',
+ 'type': 'none',
+ 'variables': {
+ 'mojom_files': [
+ 'public/interfaces/directory.mojom',
+ 'public/interfaces/file.mojom',
+ 'public/interfaces/file_system.mojom',
+ 'public/interfaces/types.mojom',
+ ],
+ },
+ 'includes': [
+ '../../mojo/mojom_bindings_generator_explicit.gypi',
+ ],
+ }
+ ],
+}