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/application_connection.h" |
12 #include "mojo/shell/public/cpp/application_impl.h" | 12 #include "mojo/shell/public/cpp/shell.h" |
13 | 13 |
14 namespace filesystem { | 14 namespace filesystem { |
15 | 15 |
16 FileSystemApp::FileSystemApp() : app_(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::ApplicationImpl* app) { | 20 void FileSystemApp::Initialize(mojo::Shell* shell, const std::string& url, |
21 app_ = app; | 21 uint32_t id) { |
22 tracing_.Initialize(app); | 22 shell_ = shell; |
| 23 tracing_.Initialize(shell, url); |
23 } | 24 } |
24 | 25 |
25 bool FileSystemApp::AcceptConnection( | 26 bool FileSystemApp::AcceptConnection( |
26 mojo::ApplicationConnection* connection) { | 27 mojo::ApplicationConnection* connection) { |
27 connection->AddService<FileSystem>(this); | 28 connection->AddService<FileSystem>(this); |
28 return true; | 29 return true; |
29 } | 30 } |
30 | 31 |
31 void FileSystemApp::RegisterDirectoryToClient(DirectoryImpl* directory, | 32 void FileSystemApp::RegisterDirectoryToClient(DirectoryImpl* directory, |
32 FileSystemClientPtr client) { | 33 FileSystemClientPtr client) { |
(...skipping 30 matching lines...) Expand all Loading... |
63 | 64 |
64 void FileSystemApp::OnDirectoryConnectionError(DirectoryImpl* directory) { | 65 void FileSystemApp::OnDirectoryConnectionError(DirectoryImpl* directory) { |
65 for (std::vector<Client>::iterator it = client_mapping_.begin(); | 66 for (std::vector<Client>::iterator it = client_mapping_.begin(); |
66 it != client_mapping_.end(); ++it) { | 67 it != client_mapping_.end(); ++it) { |
67 if (it->directory_ == directory) { | 68 if (it->directory_ == directory) { |
68 client_mapping_.erase(it); | 69 client_mapping_.erase(it); |
69 | 70 |
70 if (in_shutdown_ && client_mapping_.empty()) { | 71 if (in_shutdown_ && client_mapping_.empty()) { |
71 // We just cleared the last directory after our shell connection went | 72 // We just cleared the last directory after our shell connection went |
72 // away. Time to shut ourselves down. | 73 // away. Time to shut ourselves down. |
73 app_->Quit(); | 74 shell_->Quit(); |
74 } | 75 } |
75 | 76 |
76 return; | 77 return; |
77 } | 78 } |
78 } | 79 } |
79 } | 80 } |
80 | 81 |
81 FileSystemApp::Client::Client(DirectoryImpl* directory, | 82 FileSystemApp::Client::Client(DirectoryImpl* directory, |
82 FileSystemClientPtr fs_client) | 83 FileSystemClientPtr fs_client) |
83 : directory_(directory), fs_client_(std::move(fs_client)) {} | 84 : directory_(directory), fs_client_(std::move(fs_client)) {} |
84 | 85 |
85 FileSystemApp::Client::Client(Client&& rhs) | 86 FileSystemApp::Client::Client(Client&& rhs) |
86 : directory_(rhs.directory_), fs_client_(std::move(rhs.fs_client_)) {} | 87 : directory_(rhs.directory_), fs_client_(std::move(rhs.fs_client_)) {} |
87 | 88 |
88 FileSystemApp::Client::~Client() {} | 89 FileSystemApp::Client::~Client() {} |
89 | 90 |
90 FileSystemApp::Client& FileSystemApp::Client::operator=( | 91 FileSystemApp::Client& FileSystemApp::Client::operator=( |
91 FileSystemApp::Client&& rhs) { | 92 FileSystemApp::Client&& rhs) { |
92 directory_ = rhs.directory_; | 93 directory_ = rhs.directory_; |
93 fs_client_ = std::move(rhs.fs_client_); | 94 fs_client_ = std::move(rhs.fs_client_); |
94 return *this; | 95 return *this; |
95 } | 96 } |
96 | 97 |
97 } // namespace filesystem | 98 } // namespace filesystem |
OLD | NEW |