OLD | NEW |
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> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "mojo/shell/public/cpp/application_connection.h" | 11 #include "mojo/shell/public/cpp/connection.h" |
12 #include "mojo/shell/public/cpp/shell.h" | 12 #include "mojo/shell/public/cpp/shell.h" |
13 | 13 |
14 namespace filesystem { | 14 namespace filesystem { |
15 | 15 |
16 FileSystemApp::FileSystemApp() : shell_(nullptr), in_shutdown_(false) {} | 16 FileSystemApp::FileSystemApp() : shell_(nullptr), in_shutdown_(false) {} |
17 | 17 |
18 FileSystemApp::~FileSystemApp() {} | 18 FileSystemApp::~FileSystemApp() {} |
19 | 19 |
20 void FileSystemApp::Initialize(mojo::Shell* shell, const std::string& url, | 20 void FileSystemApp::Initialize(mojo::Shell* shell, const std::string& url, |
21 uint32_t id) { | 21 uint32_t id) { |
22 shell_ = shell; | 22 shell_ = shell; |
23 tracing_.Initialize(shell, url); | 23 tracing_.Initialize(shell, url); |
24 } | 24 } |
25 | 25 |
26 bool FileSystemApp::AcceptConnection( | 26 bool FileSystemApp::AcceptConnection(mojo::Connection* connection) { |
27 mojo::ApplicationConnection* connection) { | |
28 connection->AddService<FileSystem>(this); | 27 connection->AddService<FileSystem>(this); |
29 return true; | 28 return true; |
30 } | 29 } |
31 | 30 |
32 void FileSystemApp::RegisterDirectoryToClient(DirectoryImpl* directory, | 31 void FileSystemApp::RegisterDirectoryToClient(DirectoryImpl* directory, |
33 FileSystemClientPtr client) { | 32 FileSystemClientPtr client) { |
34 directory->set_connection_error_handler( | 33 directory->set_connection_error_handler( |
35 base::Bind(&FileSystemApp::OnDirectoryConnectionError, | 34 base::Bind(&FileSystemApp::OnDirectoryConnectionError, |
36 base::Unretained(this), | 35 base::Unretained(this), |
37 directory)); | 36 directory)); |
(...skipping 12 matching lines...) Expand all Loading... |
50 // they should shutdown. | 49 // they should shutdown. |
51 for (std::vector<Client>::iterator it = client_mapping_.begin(); | 50 for (std::vector<Client>::iterator it = client_mapping_.begin(); |
52 it != client_mapping_.end(); ++it) { | 51 it != client_mapping_.end(); ++it) { |
53 it->fs_client_->OnFileSystemShutdown(); | 52 it->fs_client_->OnFileSystemShutdown(); |
54 } | 53 } |
55 | 54 |
56 return false; | 55 return false; |
57 } | 56 } |
58 | 57 |
59 // |InterfaceFactory<Files>| implementation: | 58 // |InterfaceFactory<Files>| implementation: |
60 void FileSystemApp::Create(mojo::ApplicationConnection* connection, | 59 void FileSystemApp::Create(mojo::Connection* connection, |
61 mojo::InterfaceRequest<FileSystem> request) { | 60 mojo::InterfaceRequest<FileSystem> request) { |
62 new FileSystemImpl(this, connection, std::move(request)); | 61 new FileSystemImpl(this, connection, std::move(request)); |
63 } | 62 } |
64 | 63 |
65 void FileSystemApp::OnDirectoryConnectionError(DirectoryImpl* directory) { | 64 void FileSystemApp::OnDirectoryConnectionError(DirectoryImpl* directory) { |
66 for (std::vector<Client>::iterator it = client_mapping_.begin(); | 65 for (std::vector<Client>::iterator it = client_mapping_.begin(); |
67 it != client_mapping_.end(); ++it) { | 66 it != client_mapping_.end(); ++it) { |
68 if (it->directory_ == directory) { | 67 if (it->directory_ == directory) { |
69 client_mapping_.erase(it); | 68 client_mapping_.erase(it); |
70 | 69 |
(...skipping 18 matching lines...) Expand all Loading... |
89 FileSystemApp::Client::~Client() {} | 88 FileSystemApp::Client::~Client() {} |
90 | 89 |
91 FileSystemApp::Client& FileSystemApp::Client::operator=( | 90 FileSystemApp::Client& FileSystemApp::Client::operator=( |
92 FileSystemApp::Client&& rhs) { | 91 FileSystemApp::Client&& rhs) { |
93 directory_ = rhs.directory_; | 92 directory_ = rhs.directory_; |
94 fs_client_ = std::move(rhs.fs_client_); | 93 fs_client_ = std::move(rhs.fs_client_); |
95 return *this; | 94 return *this; |
96 } | 95 } |
97 | 96 |
98 } // namespace filesystem | 97 } // namespace filesystem |
OLD | NEW |