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

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

Issue 1708253004: mojo: Get mojo:leveldb and mojo:filesystem compiled into content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Probable fix to the build flake. 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
« no previous file with comments | « components/filesystem/file_system_app.h ('k') | components/filesystem/file_system_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <utility>
8
9 #include "base/bind.h"
10 #include "base/logging.h"
11 #include "mojo/shell/public/cpp/connection.h" 7 #include "mojo/shell/public/cpp/connection.h"
12 #include "mojo/shell/public/cpp/shell.h" 8 #include "mojo/shell/public/cpp/shell.h"
13 9
14 namespace filesystem { 10 namespace filesystem {
15 11
16 FileSystemApp::FileSystemApp() 12 FileSystemApp::FileSystemApp()
17 : shell_(nullptr), lock_table_(new LockTable), in_shutdown_(false) {} 13 : shell_(nullptr), lock_table_(new LockTable) {}
18 14
19 FileSystemApp::~FileSystemApp() {} 15 FileSystemApp::~FileSystemApp() {}
20 16
21 void FileSystemApp::Initialize(mojo::Shell* shell, const std::string& url, 17 void FileSystemApp::Initialize(mojo::Shell* shell, const std::string& url,
22 uint32_t id) { 18 uint32_t id) {
23 shell_ = shell; 19 shell_ = shell;
24 tracing_.Initialize(shell, url); 20 tracing_.Initialize(shell, url);
25 } 21 }
26 22
27 bool FileSystemApp::AcceptConnection(mojo::Connection* connection) { 23 bool FileSystemApp::AcceptConnection(mojo::Connection* connection) {
28 connection->AddInterface<FileSystem>(this); 24 connection->AddInterface<FileSystem>(this);
29 return true; 25 return true;
30 } 26 }
31 27
32 void FileSystemApp::RegisterDirectoryToClient(DirectoryImpl* directory,
33 FileSystemClientPtr client) {
34 directory->set_connection_error_handler(
35 base::Bind(&FileSystemApp::OnDirectoryConnectionError,
36 base::Unretained(this),
37 directory));
38 client_mapping_.emplace_back(directory, std::move(client));
39 }
40
41 bool FileSystemApp::ShellConnectionLost() {
42 if (client_mapping_.empty()) {
43 // If we have no current connections, we can shutdown immediately.
44 return true;
45 }
46
47 in_shutdown_ = true;
48
49 // We have live connections. Send a notification to each one indicating that
50 // they should shutdown.
51 for (std::vector<Client>::iterator it = client_mapping_.begin();
52 it != client_mapping_.end(); ++it) {
53 it->fs_client_->OnFileSystemShutdown();
54 }
55
56 return false;
57 }
58
59 // |InterfaceFactory<Files>| implementation: 28 // |InterfaceFactory<Files>| implementation:
60 void FileSystemApp::Create(mojo::Connection* connection, 29 void FileSystemApp::Create(mojo::Connection* connection,
61 mojo::InterfaceRequest<FileSystem> request) { 30 mojo::InterfaceRequest<FileSystem> request) {
62 new FileSystemImpl(this, connection, std::move(request), lock_table_.get()); 31 new FileSystemImpl(connection, std::move(request), lock_table_.get());
63 }
64
65 void FileSystemApp::OnDirectoryConnectionError(DirectoryImpl* directory) {
66 for (std::vector<Client>::iterator it = client_mapping_.begin();
67 it != client_mapping_.end(); ++it) {
68 if (it->directory_ == directory) {
69 client_mapping_.erase(it);
70
71 if (in_shutdown_ && client_mapping_.empty()) {
72 // We just cleared the last directory after our shell connection went
73 // away. Time to shut ourselves down.
74 shell_->Quit();
75 }
76
77 return;
78 }
79 }
80 }
81
82 FileSystemApp::Client::Client(DirectoryImpl* directory,
83 FileSystemClientPtr fs_client)
84 : directory_(directory), fs_client_(std::move(fs_client)) {}
85
86 FileSystemApp::Client::Client(Client&& rhs)
87 : directory_(rhs.directory_), fs_client_(std::move(rhs.fs_client_)) {}
88
89 FileSystemApp::Client::~Client() {}
90
91 FileSystemApp::Client& FileSystemApp::Client::operator=(
92 FileSystemApp::Client&& rhs) {
93 directory_ = rhs.directory_;
94 fs_client_ = std::move(rhs.fs_client_);
95 return *this;
96 } 32 }
97 33
98 } // namespace filesystem 34 } // namespace filesystem
OLDNEW
« no previous file with comments | « components/filesystem/file_system_app.h ('k') | components/filesystem/file_system_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698