diff --git a/DEPS b/DEPS index 299a692f..ba7cfc62 100644 --- a/DEPS +++ b/DEPS
@@ -275,7 +275,7 @@ 'src/third_party/catapult': Var('chromium_git') + '/external/github.com/catapult-project/catapult.git' + '@' + - '14c9d0ed23d3b45a87811d615a446cae3ea07044', + 'cb78598b63fc3b6b4767a6b81f68ef7d05a27c3d', 'src/third_party/openh264/src': Var('chromium_git') + '/external/github.com/cisco/openh264' + '@' + 'b37cda248234162033e3e11b0335f3131cdfe488',
diff --git a/mash/DEPS b/mash/DEPS index 7110e693..bd666e3 100644 --- a/mash/DEPS +++ b/mash/DEPS
@@ -8,6 +8,7 @@ "+mojo/converters", "+mojo/public", "+mojo/services/network/public", + "+mojo/services/package_manager/public", "+mojo/services/tracing/public", "+third_party/skia/include", "+ui",
diff --git a/mash/task_viewer/BUILD.gn b/mash/task_viewer/BUILD.gn index e28b755..786bd28c 100644 --- a/mash/task_viewer/BUILD.gn +++ b/mash/task_viewer/BUILD.gn
@@ -11,14 +11,15 @@ mojo_native_application("task_viewer") { sources = [ "main.cc", - "task_viewer_application_delegate.cc", - "task_viewer_application_delegate.h", + "task_viewer.cc", + "task_viewer.h", ] deps = [ ":manifest", "//base", "//mojo/public/cpp/bindings", + "//mojo/services/package_manager/public/interfaces", "//mojo/services/tracing/public/cpp", "//mojo/shell/public/cpp", "//mojo/shell/public/cpp:sources",
diff --git a/mash/task_viewer/main.cc b/mash/task_viewer/main.cc index fe2e40d9..f46f999 100644 --- a/mash/task_viewer/main.cc +++ b/mash/task_viewer/main.cc
@@ -2,12 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "mash/task_viewer/task_viewer_application_delegate.h" +#include "mash/task_viewer/task_viewer.h" #include "mojo/public/c/system/main.h" #include "mojo/shell/public/cpp/application_runner.h" MojoResult MojoMain(MojoHandle shell_handle) { - mojo::ApplicationRunner runner( - new mash::task_viewer::TaskViewerApplicationDelegate); + mojo::ApplicationRunner runner(new mash::task_viewer::TaskViewer); return runner.Run(shell_handle); }
diff --git a/mash/task_viewer/task_viewer_application_delegate.cc b/mash/task_viewer/task_viewer.cc similarity index 62% rename from mash/task_viewer/task_viewer_application_delegate.cc rename to mash/task_viewer/task_viewer.cc index beb8174..a099a3d1 100644 --- a/mash/task_viewer/task_viewer_application_delegate.cc +++ b/mash/task_viewer/task_viewer.cc
@@ -2,17 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "mash/task_viewer/task_viewer_application_delegate.h" +#include "mash/task_viewer/task_viewer.h" #include <stddef.h> #include <stdint.h> #include "base/bind.h" #include "base/macros.h" +#include "base/memory/weak_ptr.h" #include "base/process/process.h" #include "base/strings/string_number_conversions.h" #include "base/strings/utf_string_conversions.h" #include "mojo/public/cpp/bindings/binding.h" +#include "mojo/services/package_manager/public/interfaces/catalog.mojom.h" #include "mojo/shell/public/cpp/connection.h" #include "mojo/shell/public/cpp/shell.h" #include "mojo/shell/public/interfaces/application_manager.mojom.h" @@ -33,19 +35,24 @@ mojo::InterfaceRequest<mojo::shell::mojom::ApplicationManagerListener>; using mojo::shell::mojom::ApplicationInfoPtr; -class TaskViewer : public views::WidgetDelegateView, - public ui::TableModel, - public views::ButtonListener, - public mojo::shell::mojom::ApplicationManagerListener { +class TaskViewerContents + : public views::WidgetDelegateView, + public ui::TableModel, + public views::ButtonListener, + public mojo::shell::mojom::ApplicationManagerListener { public: - TaskViewer(ListenerRequest request, scoped_ptr<mojo::AppRefCount> app) + TaskViewerContents(ListenerRequest request, + package_manager::mojom::CatalogPtr catalog, + scoped_ptr<mojo::AppRefCount> app) : binding_(this, std::move(request)), + catalog_(std::move(catalog)), app_(std::move(app)), table_view_(nullptr), table_view_parent_(nullptr), kill_button_( new views::LabelButton(this, base::ASCIIToUTF16("Kill Process"))), - observer_(nullptr) { + observer_(nullptr), + weak_ptr_factory_(this) { // We don't want to show an empty UI on startup, so just block until we // receive the initial set of applications. binding_.WaitForIncomingMethodCall(); @@ -60,24 +67,23 @@ kill_button_->SetStyle(views::Button::STYLE_BUTTON); AddChildView(kill_button_); } - ~TaskViewer() override { + ~TaskViewerContents() override { table_view_->SetModel(nullptr); } private: - struct ApplicationInfo { + struct InstanceInfo { + InstanceInfo(uint32_t id, + const std::string& url, + base::ProcessId pid) + : id(id), url(url), pid(pid) {} uint32_t id; std::string url; uint32_t pid; std::string name; - - ApplicationInfo(uint32_t id, - const std::string& url, - base::ProcessId pid, const - std::string& name) - : id(id), url(url), pid(pid), name(name) {} }; + // Overridden from views::WidgetDelegate: views::View* GetContentsView() override { return this; } base::string16 GetWindowTitle() const override { @@ -101,19 +107,19 @@ // Overridden from ui::TableModel: int RowCount() override { - return static_cast<int>(applications_.size()); + return static_cast<int>(instances_.size()); } base::string16 GetText(int row, int column_id) override { switch(column_id) { case 0: - DCHECK(row < static_cast<int>(applications_.size())); - return base::UTF8ToUTF16(applications_[row]->name); + DCHECK(row < static_cast<int>(instances_.size())); + return base::UTF8ToUTF16(instances_[row]->name); case 1: - DCHECK(row < static_cast<int>(applications_.size())); - return base::UTF8ToUTF16(applications_[row]->url); + DCHECK(row < static_cast<int>(instances_.size())); + return base::UTF8ToUTF16(instances_[row]->url); case 2: - DCHECK(row < static_cast<int>(applications_.size())); - return base::IntToString16(applications_[row]->pid); + DCHECK(row < static_cast<int>(instances_.size())); + return base::IntToString16(instances_[row]->pid); default: NOTREACHED(); break; @@ -129,8 +135,8 @@ DCHECK_EQ(sender, kill_button_); DCHECK_EQ(table_view_->SelectedRowCount(), 1); int row = table_view_->FirstSelectedRow(); - DCHECK(row < static_cast<int>(applications_.size())); - base::Process process = base::Process::Open(applications_[row]->pid); + DCHECK(row < static_cast<int>(instances_.size())); + base::Process process = base::Process::Open(instances_[row]->pid); process.Terminate(9, true); } @@ -138,52 +144,74 @@ void SetRunningApplications( mojo::Array<ApplicationInfoPtr> applications) override { // This callback should only be called with an empty model. - DCHECK(applications_.empty()); + DCHECK(instances_.empty()); + mojo::Array<mojo::String> urls; for (size_t i = 0; i < applications.size(); ++i) { - applications_.push_back( - make_scoped_ptr(new ApplicationInfo(applications[i]->id, - applications[i]->url, - applications[i]->pid, - applications[i]->name))); + InsertInstance(applications[i]->id, applications[i]->url, + applications[i]->pid); + urls.push_back(applications[i]->url); } + catalog_->GetEntries(std::move(urls), + base::Bind(&TaskViewerContents::OnGotCatalogEntries, + weak_ptr_factory_.GetWeakPtr())); } void ApplicationInstanceCreated(ApplicationInfoPtr application) override { DCHECK(!ContainsId(application->id)); - applications_.push_back(make_scoped_ptr( - new ApplicationInfo(application->id, application->url, - application->pid, application->name))); - observer_->OnItemsAdded(static_cast<int>(applications_.size()), 1); + InsertInstance(application->id, application->url, application->pid); + observer_->OnItemsAdded(static_cast<int>(instances_.size()), 1); + mojo::Array<mojo::String> urls; + urls.push_back(application->url); + catalog_->GetEntries(std::move(urls), + base::Bind(&TaskViewerContents::OnGotCatalogEntries, + weak_ptr_factory_.GetWeakPtr())); } void ApplicationInstanceDestroyed(uint32_t id) override { - for (auto it = applications_.begin(); it != applications_.end(); ++it) { + for (auto it = instances_.begin(); it != instances_.end(); ++it) { if ((*it)->id == id) { observer_->OnItemsRemoved( - static_cast<int>(it - applications_.begin()), 1); - applications_.erase(it); + static_cast<int>(it - instances_.begin()), 1); + instances_.erase(it); return; } } NOTREACHED(); } void ApplicationPIDAvailable(uint32_t id, uint32_t pid) override { - for (auto it = applications_.begin(); it != applications_.end(); ++it) { + for (auto it = instances_.begin(); it != instances_.end(); ++it) { if ((*it)->id == id) { (*it)->pid = pid; observer_->OnItemsChanged( - static_cast<int>(it - applications_.begin()), 1); + static_cast<int>(it - instances_.begin()), 1); return; } } } bool ContainsId(uint32_t id) const { - for (auto& it : applications_) { + for (auto& it : instances_) { if (it->id == id) return true; } return false; } + void InsertInstance(uint32_t id, const std::string& url, uint32_t pid) { + instances_.push_back(make_scoped_ptr(new InstanceInfo(id, url, pid))); + } + + void OnGotCatalogEntries( + mojo::Map<mojo::String, + package_manager::mojom::CatalogEntryPtr> entries) { + for (auto it = instances_.begin(); it != instances_.end(); ++it) { + auto entry_it = entries.find((*it)->url); + if (entry_it != entries.end()) { + (*it)->name = entry_it->second->name; + observer_->OnItemsChanged( + static_cast<int>(it - instances_.begin()), 1); + } + } + } + static std::vector<ui::TableColumn> GetColumns() { std::vector<ui::TableColumn> columns; @@ -217,6 +245,7 @@ } mojo::Binding<mojo::shell::mojom::ApplicationManagerListener> binding_; + package_manager::mojom::CatalogPtr catalog_; scoped_ptr<mojo::AppRefCount> app_; views::TableView* table_view_; @@ -224,20 +253,20 @@ views::LabelButton* kill_button_; ui::TableModelObserver* observer_; - std::vector<scoped_ptr<ApplicationInfo>> applications_; + std::vector<scoped_ptr<InstanceInfo>> instances_; - DISALLOW_COPY_AND_ASSIGN(TaskViewer); + base::WeakPtrFactory<TaskViewerContents> weak_ptr_factory_; + + DISALLOW_COPY_AND_ASSIGN(TaskViewerContents); }; } // namespace -TaskViewerApplicationDelegate::TaskViewerApplicationDelegate() {} +TaskViewer::TaskViewer() {} +TaskViewer::~TaskViewer() {} -TaskViewerApplicationDelegate::~TaskViewerApplicationDelegate() {} - -void TaskViewerApplicationDelegate::Initialize(mojo::Shell* shell, - const std::string& url, - uint32_t id) { +void TaskViewer::Initialize(mojo::Shell* shell, const std::string& url, + uint32_t id) { tracing_.Initialize(shell, url); aura_init_.reset(new views::AuraInit(shell, "views_mus_resources.pak")); @@ -250,8 +279,11 @@ ListenerRequest request = GetProxy(&listener); application_manager->AddListener(std::move(listener)); - TaskViewer* task_viewer = new TaskViewer( - std::move(request), shell->CreateAppRefCount()); + package_manager::mojom::CatalogPtr catalog; + shell->ConnectToInterface("mojo:package_manager", &catalog); + + TaskViewerContents* task_viewer = new TaskViewerContents( + std::move(request), std::move(catalog), shell->CreateAppRefCount()); views::Widget* window = views::Widget::CreateWindowWithBounds( task_viewer, gfx::Rect(10, 10, 500, 500)); window->Show();
diff --git a/mash/task_viewer/task_viewer_application_delegate.h b/mash/task_viewer/task_viewer.h similarity index 65% rename from mash/task_viewer/task_viewer_application_delegate.h rename to mash/task_viewer/task_viewer.h index d6d122da..6c737da 100644 --- a/mash/task_viewer/task_viewer_application_delegate.h +++ b/mash/task_viewer/task_viewer.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef MASH_TASK_VIEWER_TASK_VIEWER_APPLICATION_DELEGATE_H_ -#define MASH_TASK_VIEWER_TASK_VIEWER_APPLICATION_DELEGATE_H_ +#ifndef MASH_TASK_VIEWER_TASK_VIEWER_H_ +#define MASH_TASK_VIEWER_TASK_VIEWER_H_ #include <map> @@ -20,10 +20,10 @@ namespace mash { namespace task_viewer { -class TaskViewerApplicationDelegate : public mojo::ShellClient { +class TaskViewer : public mojo::ShellClient { public: - TaskViewerApplicationDelegate(); - ~TaskViewerApplicationDelegate() override; + TaskViewer(); + ~TaskViewer() override; private: // mojo::ShellClient: @@ -33,10 +33,10 @@ mojo::TracingImpl tracing_; scoped_ptr<views::AuraInit> aura_init_; - DISALLOW_COPY_AND_ASSIGN(TaskViewerApplicationDelegate); + DISALLOW_COPY_AND_ASSIGN(TaskViewer); }; } // namespace task_viewer } // namespace mash -#endif // MASH_TASK_VIEWER_TASK_VIEWER_APPLICATION_DELEGATE_H_ +#endif // MASH_TASK_VIEWER_TASK_VIEWER_H_
diff --git a/mojo/mojo_base.gyp b/mojo/mojo_base.gyp index cd4d46c..8f54076 100644 --- a/mojo/mojo_base.gyp +++ b/mojo/mojo_base.gyp
@@ -204,6 +204,7 @@ 'type': 'none', 'variables': { 'mojom_files': [ + 'services/package_manager/public/interfaces/catalog.mojom', 'services/package_manager/public/interfaces/resolver.mojom', 'services/package_manager/public/interfaces/shell_resolver.mojom', 'shell/public/interfaces/application_manager.mojom',
diff --git a/mojo/services/package_manager/package_manager.cc b/mojo/services/package_manager/package_manager.cc index 21f032e..ccc1202 100644 --- a/mojo/services/package_manager/package_manager.cc +++ b/mojo/services/package_manager/package_manager.cc
@@ -99,6 +99,7 @@ uint32_t id) {} bool PackageManager::AcceptConnection(mojo::Connection* connection) { + connection->AddInterface<mojom::Catalog>(this); connection->AddInterface<mojom::Resolver>(this); if (connection->GetRemoteApplicationURL() == "mojo://shell/") connection->AddInterface<mojom::ShellResolver>(this); @@ -115,6 +116,11 @@ shell_resolver_bindings_.AddBinding(this, std::move(request)); } +void PackageManager::Create(mojo::Connection* connection, + mojom::CatalogRequest request) { + catalog_bindings_.AddBinding(this, std::move(request)); +} + void PackageManager::ResolveResponse(mojo::URLResponsePtr response, const ResolveResponseCallback& callback) { // TODO(beng): implement. @@ -150,6 +156,22 @@ EnsureURLInCatalog(resolved_url, qualifier, callback); } +void PackageManager::GetEntries( + mojo::Array<mojo::String> urls, + const GetEntriesCallback& callback) { + mojo::Map<mojo::String, mojom::CatalogEntryPtr> entries; + std::vector<mojo::String> urls_vec = urls.PassStorage(); + for (const auto& url : urls_vec) { + if (catalog_.find(url) == catalog_.end()) + continue; + const ApplicationInfo& info = catalog_[url]; + mojom::CatalogEntryPtr entry(mojom::CatalogEntry::New()); + entry->name = info.name; + entries[info.url] = std::move(entry); + } + callback.Run(std::move(entries)); +} + void PackageManager::CompleteResolveMojoURL( const GURL& resolved_url, const std::string& qualifier, @@ -178,8 +200,8 @@ all_interfaces.push_back("*"); filter->filter.insert("*", std::move(all_interfaces)); - callback.Run(resolved_url.spec(), qualifier, file_url.spec(), - info_iter->second.name, std::move(filter)); + callback.Run(resolved_url.spec(), qualifier, std::move(filter), + file_url.spec()); } bool PackageManager::IsURLInCatalog(const GURL& url) const { @@ -200,7 +222,7 @@ // The URL is of some form that can't be resolved to a manifest (e.g. some // scheme used for tests). Just pass it back to the caller so it can be // loaded with a custom loader. - callback.Run(url.spec(), nullptr, nullptr, nullptr, nullptr); + callback.Run(url.spec(), url.spec(), nullptr, nullptr); return; } @@ -282,7 +304,7 @@ if (!pm) { // The PackageManager was destroyed, we're likely in shutdown. Run the // callback so we don't trigger a DCHECK. - callback.Run(url.spec(), nullptr, nullptr, nullptr, nullptr); + callback.Run(url.spec(), url.spec(), nullptr, nullptr); return; } pm->OnReadManifestImpl(url, qualifier, callback, std::move(manifest));
diff --git a/mojo/services/package_manager/package_manager.h b/mojo/services/package_manager/package_manager.h index e267598..c311ce4 100644 --- a/mojo/services/package_manager/package_manager.h +++ b/mojo/services/package_manager/package_manager.h
@@ -10,6 +10,7 @@ #include "base/path_service.h" #include "base/values.h" #include "mojo/public/cpp/bindings/weak_binding_set.h" +#include "mojo/services/package_manager/public/interfaces/catalog.mojom.h" #include "mojo/services/package_manager/public/interfaces/resolver.mojom.h" #include "mojo/services/package_manager/public/interfaces/shell_resolver.mojom.h" #include "mojo/shell/public/cpp/interface_factory.h" @@ -53,8 +54,10 @@ class PackageManager : public mojo::ShellClient, public mojo::InterfaceFactory<mojom::Resolver>, public mojo::InterfaceFactory<mojom::ShellResolver>, + public mojo::InterfaceFactory<mojom::Catalog>, public mojom::Resolver, - public mojom::ShellResolver { + public mojom::ShellResolver, + public mojom::Catalog { public: // If |register_schemes| is true, mojo: and exe: schemes are registered as // "standard". @@ -78,6 +81,10 @@ void Create(mojo::Connection* connection, mojom::ShellResolverRequest request) override; + // mojo::InterfaceFactory<mojom::Catalog>: + void Create(mojo::Connection* connection, + mojom::CatalogRequest request) override; + // mojom::Resolver: void ResolveResponse( mojo::URLResponsePtr response, @@ -94,6 +101,10 @@ void ResolveMojoURL(const mojo::String& mojo_url, const ResolveMojoURLCallback& callback) override; + // mojom::Catalog: + void GetEntries(mojo::Array<mojo::String> urls, + const GetEntriesCallback& callback) override; + // Completes resolving a Mojo URL from the Shell after the resolved URL has // been added to the catalog and the manifest read. void CompleteResolveMojoURL(const GURL& resolved_url, @@ -137,6 +148,7 @@ mojo::WeakBindingSet<mojom::Resolver> resolver_bindings_; mojo::WeakBindingSet<mojom::ShellResolver> shell_resolver_bindings_; + mojo::WeakBindingSet<mojom::Catalog> catalog_bindings_; ApplicationCatalogStore* catalog_store_; std::map<std::string, ApplicationInfo> catalog_;
diff --git a/mojo/services/package_manager/public/interfaces/BUILD.gn b/mojo/services/package_manager/public/interfaces/BUILD.gn index b39dc33..41b3c1f0 100644 --- a/mojo/services/package_manager/public/interfaces/BUILD.gn +++ b/mojo/services/package_manager/public/interfaces/BUILD.gn
@@ -6,6 +6,7 @@ mojom("interfaces") { sources = [ + "catalog.mojom", "resolver.mojom", "shell_resolver.mojom", ]
diff --git a/mojo/services/package_manager/public/interfaces/catalog.mojom b/mojo/services/package_manager/public/interfaces/catalog.mojom new file mode 100644 index 0000000..db16c04 --- /dev/null +++ b/mojo/services/package_manager/public/interfaces/catalog.mojom
@@ -0,0 +1,13 @@ +// 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. + +module package_manager.mojom; + +struct CatalogEntry { + string name; +}; + +interface Catalog { + GetEntries(array<string> urls) => (map<string, CatalogEntry> entries); +};
diff --git a/mojo/services/package_manager/public/interfaces/shell_resolver.mojom b/mojo/services/package_manager/public/interfaces/shell_resolver.mojom index c4a1b30..27c5cd1 100644 --- a/mojo/services/package_manager/public/interfaces/shell_resolver.mojom +++ b/mojo/services/package_manager/public/interfaces/shell_resolver.mojom
@@ -10,23 +10,30 @@ // and reading static manifest information. interface ShellResolver { // Resolves |mojo_url| to the following metadata: - // |resolved_mojo_url| - another mojo: url of an application implementing - // mojo::ContentHandler that can handle connections to |mojo_url|. - // |mojo_file_url| - a file URL to the application specified in - // |resolved_mojo_url| TODO(beng): what if |resolved_mojo_url| needs to be - // re-resolved?? - // |application_name| - the display name of the application @ |mojo_url|, - // loaded from |resolved_mojo_url|'s manifest. - // |filter| - the base CapabilityFilter within which an instance of - // |resolved_mojo_url| must be run for |mojo_url|. + // + // resolved_mojo_url + // another mojo: url of an application implementing mojo::ShellClientFactory + // that can handle connections to |mojo_url|. + // + // qualifier + // an additional piece of metadata that identifies what instance + // |resolved_mojo_url| should be run in. It's possible that + // |resolved_mojo_url| may provide several services that should be run as + // different instances. + // + // mojo_file_url + // a file URL to the application specified in |resolved_mojo_url| + // TODO(beng): what if |resolved_mojo_url| needs to be re-resolved?? + // + // filter + // the base CapabilityFilter within which an instance of |resolved_mojo_url| + // must be run for |mojo_url|. + // // If |mojo_url| can't be resolved (i.e. not a mojo: or exe: scheme), then - // the callback will be run with null |mojo_file_url|, |application_name| and - // |filter|. - // TODO(beng): return qualifier too! + // the callback will be run with null |mojo_file_url|, and |filter|. ResolveMojoURL(string mojo_url) => (string resolved_mojo_url, - string? qualifier, - string? mojo_file_url, - string? application_name, - mojo.shell.mojom.CapabilityFilter? filter); + string qualifier, + mojo.shell.mojom.CapabilityFilter? filter, + string? mojo_file_url); };
diff --git a/mojo/shell/BUILD.gn b/mojo/shell/BUILD.gn index 8b1882a..b2d3ef6 100644 --- a/mojo/shell/BUILD.gn +++ b/mojo/shell/BUILD.gn
@@ -10,7 +10,6 @@ deps = [ ":shell", "//mojo/shell/background", - "//mojo/shell/background", "//mojo/shell/runner", "//mojo/shell/standalone", "//mojo/shell/tests", @@ -38,22 +37,15 @@ "switches.h", ] - public_deps = [ + deps = [ "//base", + "//base/third_party/dynamic_annotations", "//mojo/common", "//mojo/public/cpp/bindings", - "//mojo/services/package_manager/public/interfaces", - "//mojo/services/updater", - "//mojo/shell/public/interfaces", - "//url", - ] - deps = [ - "//base/third_party/dynamic_annotations", - "//crypto:crypto", - "//mojo/edk/system", - "//mojo/environment:chromium", "//mojo/services/package_manager:lib", + "//mojo/services/package_manager/public/interfaces", "//mojo/shell/public/cpp:sources", + "//mojo/shell/public/interfaces", "//mojo/util:filename_util", "//url", ]
diff --git a/mojo/shell/application_instance.cc b/mojo/shell/application_instance.cc index 41b7cfeff..7923a764 100644 --- a/mojo/shell/application_instance.cc +++ b/mojo/shell/application_instance.cc
@@ -21,8 +21,7 @@ ApplicationInstance::ApplicationInstance( mojom::ShellClientPtr shell_client, ApplicationManager* manager, - const Identity& identity, - const String& application_name) + const Identity& identity) : manager_(manager), id_(GenerateUniqueID()), identity_(identity), @@ -33,7 +32,6 @@ pid_receiver_binding_(this), queue_requests_(false), native_runner_(nullptr), - application_name_(application_name), pid_(base::kNullProcessId) { DCHECK_NE(Shell::kInvalidApplicationID, id_); }
diff --git a/mojo/shell/application_instance.h b/mojo/shell/application_instance.h index 621761a7..afe30e59 100644 --- a/mojo/shell/application_instance.h +++ b/mojo/shell/application_instance.h
@@ -36,8 +36,7 @@ ApplicationInstance( mojom::ShellClientPtr shell_client, ApplicationManager* manager, - const Identity& identity, - const String& application_name); + const Identity& identity); ~ApplicationInstance() override; void InitializeApplication(); @@ -54,7 +53,6 @@ uint32_t id() const { return id_; } base::ProcessId pid() const { return pid_; } void set_pid(base::ProcessId pid) { pid_ = pid; } - const String& application_name() const { return application_name_; } private: // Shell implementation: @@ -91,7 +89,6 @@ bool queue_requests_; std::vector<ConnectParams*> queued_client_requests_; NativeRunner* native_runner_; - const String application_name_; base::ProcessId pid_; DISALLOW_COPY_AND_ASSIGN(ApplicationInstance);
diff --git a/mojo/shell/application_manager.cc b/mojo/shell/application_manager.cc index b2c4a49..1a4cfa0 100644 --- a/mojo/shell/application_manager.cc +++ b/mojo/shell/application_manager.cc
@@ -196,8 +196,7 @@ CapabilityFilter local_filter = filter->filter.To<CapabilityFilter>(); Identity target_id(url.To<GURL>(), std::string(), local_filter); mojom::ShellClientRequest request; - // TODO(beng): do better than url.spec() for application name. - ApplicationInstance* instance = CreateInstance(target_id, url, &request); + ApplicationInstance* instance = CreateInstance(target_id, &request); instance->BindPIDReceiver(std::move(pid_receiver)); scoped_ptr<NativeRunner> runner = native_runner_factory_->Create(base::FilePath()); @@ -225,7 +224,7 @@ mojom::ShellClientRequest request; GURL url("mojo://package_manager/"); - CreateInstance(Identity(url), url.spec(), &request); + CreateInstance(Identity(url), &request); loader->Load(url, std::move(request)); SetLoaderForURL(std::move(loader), url); @@ -244,12 +243,11 @@ ApplicationInstance* ApplicationManager::CreateInstance( const Identity& target_id, - const String& application_name, mojom::ShellClientRequest* request) { mojom::ShellClientPtr shell_client; *request = GetProxy(&shell_client); - ApplicationInstance* instance = new ApplicationInstance( - std::move(shell_client), this, target_id, application_name); + ApplicationInstance* instance = + new ApplicationInstance(std::move(shell_client), this, target_id); DCHECK(identity_to_instance_.find(target_id) == identity_to_instance_.end()); identity_to_instance_[target_id] = instance; @@ -304,9 +302,8 @@ scoped_ptr<ConnectParams> params, const String& resolved_url, const String& qualifier, - const String& file_url, - const String& application_name, - mojom::CapabilityFilterPtr base_filter) { + mojom::CapabilityFilterPtr base_filter, + const String& file_url) { // It's possible that when this manifest request was issued, another one was // already in-progress and completed by the time this one did, and so the // requested application may already be running. @@ -315,15 +312,13 @@ Identity source = params->source(), target = params->target(); mojom::ShellClientRequest request; - ApplicationInstance* instance = - CreateInstance(params->target(), application_name, &request); + ApplicationInstance* instance = CreateInstance(params->target(), &request); instance->ConnectToClient(std::move(params)); if (LoadWithLoader(target, &request)) return; - CHECK(!file_url.is_null() && !application_name.is_null() && - !base_filter.is_null()); + CHECK(!file_url.is_null() && !base_filter.is_null()); GURL resolved_gurl = resolved_url.To<GURL>(); if (target.url().spec() != resolved_url) { @@ -380,7 +375,6 @@ info->id = instance->id(); info->url = instance->identity().url().spec(); info->qualifier = instance->identity().qualifier(); - info->name = instance->application_name(); if (instance->identity().url().spec() == "mojo://shell/") info->pid = base::Process::Current().Pid(); else
diff --git a/mojo/shell/application_manager.h b/mojo/shell/application_manager.h index f09dbe3..9e0f437 100644 --- a/mojo/shell/application_manager.h +++ b/mojo/shell/application_manager.h
@@ -128,10 +128,8 @@ // and this function returns true. bool ConnectToExistingInstance(scoped_ptr<ConnectParams>* params); - ApplicationInstance* CreateInstance( - const Identity& target_id, - const String& application_name, - mojom::ShellClientRequest* request); + ApplicationInstance* CreateInstance(const Identity& target_id, + mojom::ShellClientRequest* request); void CreateShellClient(const Identity& source, const Identity& shell_client_factory, @@ -149,16 +147,13 @@ // |resolved_url| is the mojo: url identifying the physical package // application. // |file_url| is the resolved file:// URL of the physical package. - // |application_name| is the requested application's pretty name, from its - // manifest. // |base_filter| is the CapabilityFilter the requested application should be // run with, from its manifest. void OnGotResolvedURL(scoped_ptr<ConnectParams> params, const String& resolved_url, const String& qualifier, - const String& file_url, - const String& application_name, - mojom::CapabilityFilterPtr base_filter); + mojom::CapabilityFilterPtr base_filter, + const String& file_url); // Tries to load |target| with an ApplicationLoader. Returns true if one was // registered and it was loaded, in which case |request| is taken.
diff --git a/mojo/shell/background/BUILD.gn b/mojo/shell/background/BUILD.gn index be73bd5..b7e5ee3 100644 --- a/mojo/shell/background/BUILD.gn +++ b/mojo/shell/background/BUILD.gn
@@ -20,6 +20,7 @@ "//mojo/message_pump", "//mojo/shell", "//mojo/shell/public/cpp:sources", + "//mojo/shell/runner:init", "//mojo/shell/standalone:lib", ] } @@ -34,6 +35,7 @@ "//mojo/message_pump", "//mojo/shell", "//mojo/shell/public/cpp:sources", + "//mojo/shell/runner:init", "//mojo/shell/runner/common", "//mojo/shell/runner/host:lib", "//mojo/shell/standalone:lib",
diff --git a/mojo/shell/public/cpp/BUILD.gn b/mojo/shell/public/cpp/BUILD.gn index 5e814fb..2ebc220 100644 --- a/mojo/shell/public/cpp/BUILD.gn +++ b/mojo/shell/public/cpp/BUILD.gn
@@ -41,14 +41,12 @@ ] deps = [ + "//base", "//base:i18n", - "//mojo/common", - "//mojo/environment:chromium", "//mojo/message_pump", ] public_deps = [ - "//base", "//mojo/public/cpp/bindings", "//mojo/public/cpp/system", "//mojo/shell/public/interfaces",
diff --git a/mojo/shell/public/interfaces/application_manager.mojom b/mojo/shell/public/interfaces/application_manager.mojom index c365146..d3d926b 100644 --- a/mojo/shell/public/interfaces/application_manager.mojom +++ b/mojo/shell/public/interfaces/application_manager.mojom
@@ -11,7 +11,6 @@ string url; string qualifier; uint32 pid; - string name; }; // Implemented by an application that wishes to be informed when the list of
diff --git a/mojo/shell/runner/child/BUILD.gn b/mojo/shell/runner/child/BUILD.gn index b243df8..5446abe 100644 --- a/mojo/shell/runner/child/BUILD.gn +++ b/mojo/shell/runner/child/BUILD.gn
@@ -55,7 +55,6 @@ deps = [ "//base", "//mojo/edk/system", - "//mojo/gles2", "//mojo/message_pump", "//mojo/shell/public/cpp", "//mojo/shell/runner/child:lib", @@ -87,7 +86,6 @@ ":apptest_interfaces", "//base", "//base/test:test_config", - "//mojo/common:common_base", "//mojo/shell/public/cpp:sources", "//mojo/shell/public/cpp:test_support", ] @@ -111,7 +109,6 @@ ":test_native_main", "//base", "//build/config/sanitizers:deps", - "//mojo/common:common_base", "//mojo/shell/public/cpp", ] }
diff --git a/mojo/shell/runner/host/BUILD.gn b/mojo/shell/runner/host/BUILD.gn index 1f0d194..0522d97 100644 --- a/mojo/shell/runner/host/BUILD.gn +++ b/mojo/shell/runner/host/BUILD.gn
@@ -75,7 +75,6 @@ "//base:base_static", "//base:i18n", "//mojo/edk/system", - "//mojo/gles2", "//mojo/message_pump", "//mojo/platform_handle:platform_handle_impl", "//mojo/shell", @@ -110,9 +109,7 @@ ":lib", "//base", "//base/test:test_support", - "//mojo/common", "//mojo/edk/system", - "//mojo/environment:chromium", "//mojo/message_pump", "//mojo/shell/runner:init", "//mojo/shell/runner/common",
diff --git a/mojo/shell/standalone/BUILD.gn b/mojo/shell/standalone/BUILD.gn index 09a4fa9a..46183b1 100644 --- a/mojo/shell/standalone/BUILD.gn +++ b/mojo/shell/standalone/BUILD.gn
@@ -15,13 +15,6 @@ ":lib", "//base", "//build/config/sanitizers:deps", - "//components/tracing:startup_tracing", - "//mojo/common", - "//mojo/environment:chromium", - "//mojo/message_pump", - "//mojo/shell/runner/common", - "//mojo/shell/runner/host:lib", - "//third_party/icu:icudata", ] } @@ -48,19 +41,10 @@ "//mojo/services/tracing/public/interfaces", "//mojo/shell", "//mojo/shell/public/cpp", - "//mojo/shell/runner:init", - "//mojo/shell/runner/child:interfaces", "//mojo/shell/runner/host:lib", - "//mojo/util:filename_util", - "//ui/gl", "//url", ] - public_deps = [ - "//mojo/shell", - "//mojo/shell/runner:init", - ] - if (!is_component_build) { data_deps = [ "//mojo/services/tracing",
diff --git a/mojo/shell/tests/application_manager_apptest.cc b/mojo/shell/tests/application_manager_apptest.cc index 0c7190d..9a6b1691 100644 --- a/mojo/shell/tests/application_manager_apptest.cc +++ b/mojo/shell/tests/application_manager_apptest.cc
@@ -77,15 +77,12 @@ protected: struct ApplicationInfo { - ApplicationInfo(uint32_t id, - const std::string& url, - const std::string& name) - : id(id), url(url), pid(base::kNullProcessId), name(name) {} + ApplicationInfo(uint32_t id, const std::string& url) + : id(id), url(url), pid(base::kNullProcessId) {} uint32_t id; std::string url; base::ProcessId pid; - std::string name; }; void AddListenerAndWaitForApplications() { @@ -96,13 +93,13 @@ binding_.WaitForIncomingMethodCall(); } - bool ContainsApplicationNamed(const std::string& name) const { + bool ContainsApplicationWithURL(const std::string& url) const { for (const auto& application : initial_applications_) { - if (application.name == name) + if (application.url == url) return true; } for (const auto& application : applications_) { - if (application.name == name) + if (application.url == url) return true; } return false; @@ -131,14 +128,12 @@ Array<mojom::ApplicationInfoPtr> applications) override { for (size_t i = 0; i < applications.size(); ++i) { initial_applications_.push_back(ApplicationInfo(applications[i]->id, - applications[i]->url, - applications[i]->name)); + applications[i]->url)); } } void ApplicationInstanceCreated( mojom::ApplicationInfoPtr application) override { - applications_.push_back(ApplicationInfo(application->id, application->url, - application->name)); + applications_.push_back(ApplicationInfo(application->id, application->url)); } void ApplicationInstanceDestroyed(uint32_t id) override { for (auto it = applications_.begin(); it != applications_.end(); ++it) { @@ -184,9 +179,9 @@ EXPECT_TRUE(connection->GetRemoteApplicationID(&remote_id)); EXPECT_NE(mojom::Shell::kInvalidApplicationID, remote_id); - // 3. Validate that this test suite's pretty name was consumed from its - // manifest. - EXPECT_TRUE(ContainsApplicationNamed("Application Manager Apptests")); + // 3. Validate that this test suite's URL was received from the application + // manager. + EXPECT_TRUE(ContainsApplicationWithURL("mojo://mojo_shell_apptests/")); // 4. Validate that the right applications/processes were created. // Note that the target process will be created even if the tests are
diff --git a/net/url_request/url_fetcher.h b/net/url_request/url_fetcher.h index b864240..3536f0b 100644 --- a/net/url_request/url_fetcher.h +++ b/net/url_request/url_fetcher.h
@@ -39,9 +39,9 @@ // To use this class, create an instance with the desired URL and a pointer to // the object to be notified when the URL has been loaded: // scoped_ptr<URLFetcher> fetcher = -// URLFetcher::Create("http://www.google.com", -// URLFetcher::GET, -// this); +// URLFetcher::Create(GURL("http://www.google.com"), +// URLFetcher::GET, +// this); // // You must also set a request context getter: // @@ -49,7 +49,7 @@ // // Then, optionally set properties on this object, like the request context or // extra headers: -// fetcher->set_extra_request_headers("X-Foo: bar"); +// fetcher->AddExtraRequestHeader("X-Foo: bar"); // // Finally, start the request: // fetcher->Start(); @@ -57,14 +57,13 @@ // You may cancel the request by destroying the URLFetcher: // fetcher.reset(); // -// The object you supply as a delegate must inherit from -// URLFetcherDelegate; when the fetch is completed, -// OnURLFetchComplete() will be called with a pointer to the URLFetcher. From -// that point until the original URLFetcher instance is destroyed, you may use -// accessor methods to see the result of the fetch. You should copy these -// objects if you need them to live longer than the URLFetcher instance. If the -// URLFetcher instance is destroyed before the callback happens, the fetch will -// be canceled and no callback will occur. +// The object you supply as a delegate must inherit from URLFetcherDelegate. +// When the fetch is completed, OnURLFetchComplete() will be called with a +// pointer to the URLFetcher. From that point until the original URLFetcher +// instance is destroyed, you may use accessor methods to see the result of the +// fetch. You should copy these objects if you need them to live longer than +// the URLFetcher instance. If the URLFetcher instance is destroyed before the +// callback happens, the fetch will be canceled and no callback will occur. // // You may create the URLFetcher instance on any thread; OnURLFetchComplete() // will be called back on the same thread you use to create the instance.
diff --git a/tools/clang/blink_gc_plugin/BlinkGCPluginConsumer.cpp b/tools/clang/blink_gc_plugin/BlinkGCPluginConsumer.cpp index c90510e..7c90ddd 100644 --- a/tools/clang/blink_gc_plugin/BlinkGCPluginConsumer.cpp +++ b/tools/clang/blink_gc_plugin/BlinkGCPluginConsumer.cpp
@@ -325,19 +325,11 @@ } } - for (CollectVisitor::RecordVector::iterator it = - visitor.record_decls().begin(); - it != visitor.record_decls().end(); - ++it) { - CheckRecord(cache_.Lookup(*it)); - } + for (const auto& record : visitor.record_decls()) + CheckRecord(cache_.Lookup(record)); - for (CollectVisitor::MethodVector::iterator it = - visitor.trace_decls().begin(); - it != visitor.trace_decls().end(); - ++it) { - CheckTracingMethod(*it); - } + for (const auto& method : visitor.trace_decls()) + CheckTracingMethod(method); if (json_) { json_->CloseList(); @@ -401,12 +393,9 @@ // Check consistency of stack-allocated hierarchies. if (info->IsStackAllocated()) { - for (RecordInfo::Bases::iterator it = info->GetBases().begin(); - it != info->GetBases().end(); - ++it) { - if (!it->second.info()->IsStackAllocated()) - ReportDerivesNonStackAllocated(info, &it->second); - } + for (auto& base : info->GetBases()) + if (!base.second.info()->IsStackAllocated()) + ReportDerivesNonStackAllocated(info, &base.second); } if (CXXMethodDecl* trace = info->GetTraceMethod()) { @@ -427,7 +416,7 @@ { CheckFieldsVisitor visitor(options_); if (visitor.ContainsInvalidFields(info)) - ReportClassContainsInvalidFields(info, &visitor.invalid_fields()); + ReportClassContainsInvalidFields(info, visitor.invalid_fields()); } if (info->IsGCDerived()) { @@ -442,7 +431,7 @@ { CheckGCRootsVisitor visitor; if (visitor.ContainsGCRoots(info)) - ReportClassContainsGCRoots(info, &visitor.gc_roots()); + ReportClassContainsGCRoots(info, visitor.gc_roots()); } if (info->NeedsFinalization()) @@ -645,7 +634,7 @@ visitor.TraverseCXXMethodDecl(dtor); if (!visitor.finalized_fields().empty()) { ReportFinalizerAccessesFinalizedFields( - dtor, &visitor.finalized_fields()); + dtor, visitor.finalized_fields()); } } return; @@ -662,19 +651,13 @@ if (dtor && dtor->isUserProvided()) NoteUserDeclaredDestructor(dtor); - for (RecordInfo::Bases::iterator it = info->GetBases().begin(); - it != info->GetBases().end(); - ++it) { - if (it->second.info()->NeedsFinalization()) - NoteBaseRequiresFinalization(&it->second); - } + for (auto& base : info->GetBases()) + if (base.second.info()->NeedsFinalization()) + NoteBaseRequiresFinalization(&base.second); - for (RecordInfo::Fields::iterator it = info->GetFields().begin(); - it != info->GetFields().end(); - ++it) { - if (it->second.edge()->NeedsFinalization()) - NoteField(&it->second, diag_field_requires_finalization_note_); - } + for (auto& field : info->GetFields()) + if (field.second.edge()->NeedsFinalization()) + NoteField(&field.second, diag_field_requires_finalization_note_); } void BlinkGCPluginConsumer::CheckUnneededFinalization(RecordInfo* info) { @@ -688,18 +671,14 @@ if (!dtor->hasBody() || !EmptyStmtVisitor::isEmpty(dtor->getBody())) return true; } - for (RecordInfo::Bases::iterator it = info->GetBases().begin(); - it != info->GetBases().end(); - ++it) { - if (HasNonEmptyFinalizer(it->second.info())) + for (auto& base : info->GetBases()) + if (HasNonEmptyFinalizer(base.second.info())) return true; - } - for (RecordInfo::Fields::iterator it = info->GetFields().begin(); - it != info->GetFields().end(); - ++it) { - if (it->second.edge()->NeedsFinalization()) + + for (auto& field : info->GetFields()) + if (field.second.edge()->NeedsFinalization()) return true; - } + return false; } @@ -743,13 +722,9 @@ Config::TraceMethodType trace_type) { // A trace method must not override any non-virtual trace methods. if (trace_type == Config::TRACE_METHOD) { - for (RecordInfo::Bases::iterator it = parent->GetBases().begin(); - it != parent->GetBases().end(); - ++it) { - RecordInfo* base = it->second.info(); - if (CXXMethodDecl* other = base->InheritsNonVirtualTrace()) + for (auto& base : parent->GetBases()) + if (CXXMethodDecl* other = base.second.info()->InheritsNonVirtualTrace()) ReportOverriddenNonVirtualTrace(parent, trace, other); - } } CheckTraceVisitor visitor(trace, parent, &cache_); @@ -761,17 +736,12 @@ if (visitor.delegates_to_traceimpl()) return; - for (RecordInfo::Bases::iterator it = parent->GetBases().begin(); - it != parent->GetBases().end(); - ++it) { - if (!it->second.IsProperlyTraced()) - ReportBaseRequiresTracing(parent, trace, it->first); - } + for (auto& base : parent->GetBases()) + if (!base.second.IsProperlyTraced()) + ReportBaseRequiresTracing(parent, trace, base.first); - for (RecordInfo::Fields::iterator it = parent->GetFields().begin(); - it != parent->GetFields().end(); - ++it) { - if (!it->second.IsProperlyTraced()) { + for (auto& field : parent->GetFields()) { + if (!field.second.IsProperlyTraced()) { // Discontinue once an untraced-field error is found. ReportFieldsRequireTracing(parent, trace); break; @@ -851,25 +821,17 @@ DumpEdgeVisitor visitor(json_); - RecordInfo::Bases& bases = info->GetBases(); - for (RecordInfo::Bases::iterator it = bases.begin(); - it != bases.end(); - ++it) { + for (auto& base : info->GetBases()) visitor.DumpEdge(info, - it->second.info(), + base.second.info(), "<super>", Edge::kStrong, - GetLocString(it->second.spec().getLocStart())); - } + GetLocString(base.second.spec().getLocStart())); - RecordInfo::Fields& fields = info->GetFields(); - for (RecordInfo::Fields::iterator it = fields.begin(); - it != fields.end(); - ++it) { + for (auto& field : info->GetFields()) visitor.DumpField(info, - &it->second, - GetLocString(it->second.field()->getLocStart())); - } + &field.second, + GetLocString(field.second.field()->getLocStart())); } DiagnosticsEngine::Level BlinkGCPluginConsumer::getErrorLevel() { @@ -914,9 +876,8 @@ #if defined(LLVM_ON_WIN32) std::replace(filename.begin(), filename.end(), '\\', '/'); #endif - std::vector<std::string>::iterator it = options_.ignored_directories.begin(); - for (; it != options_.ignored_directories.end(); ++it) - if (filename.find(*it) != std::string::npos) + for (const auto& dir : options_.ignored_directories) + if (filename.find(dir) != std::string::npos) return true; return false; } @@ -973,19 +934,13 @@ diag_class_requires_trace_method_) << info->record(); - for (RecordInfo::Bases::iterator it = info->GetBases().begin(); - it != info->GetBases().end(); - ++it) { - if (it->second.NeedsTracing().IsNeeded()) - NoteBaseRequiresTracing(&it->second); - } + for (auto& base : info->GetBases()) + if (base.second.NeedsTracing().IsNeeded()) + NoteBaseRequiresTracing(&base.second); - for (RecordInfo::Fields::iterator it = info->GetFields().begin(); - it != info->GetFields().end(); - ++it) { - if (!it->second.IsProperlyTraced()) - NoteFieldRequiresTracing(info, it->first); - } + for (auto& field : info->GetFields()) + if (!field.second.IsProperlyTraced()) + NoteFieldRequiresTracing(info, field.first); } void BlinkGCPluginConsumer::ReportBaseRequiresTracing( @@ -1001,71 +956,65 @@ CXXMethodDecl* trace) { ReportDiagnostic(trace->getLocStart(), diag_fields_require_tracing_) << info->record(); - for (RecordInfo::Fields::iterator it = info->GetFields().begin(); - it != info->GetFields().end(); - ++it) { - if (!it->second.IsProperlyTraced()) - NoteFieldRequiresTracing(info, it->first); - } + for (auto& field : info->GetFields()) + if (!field.second.IsProperlyTraced()) + NoteFieldRequiresTracing(info, field.first); } void BlinkGCPluginConsumer::ReportClassContainsInvalidFields( RecordInfo* info, - CheckFieldsVisitor::Errors* errors) { + const CheckFieldsVisitor::Errors& errors) { bool only_warnings = options_.warn_raw_ptr; - for (CheckFieldsVisitor::Errors::iterator it = errors->begin(); - only_warnings && it != errors->end(); - ++it) { - if (!CheckFieldsVisitor::IsWarning(it->second)) + for (auto& error : errors) + if (!CheckFieldsVisitor::IsWarning(error.second)) only_warnings = false; - } + ReportDiagnostic(info->record()->getLocStart(), only_warnings ? diag_class_contains_invalid_fields_warning_ : diag_class_contains_invalid_fields_) << info->record(); - for (CheckFieldsVisitor::Errors::iterator it = errors->begin(); - it != errors->end(); - ++it) { - unsigned error; - if (CheckFieldsVisitor::IsRawPtrError(it->second)) { - error = diag_raw_ptr_to_gc_managed_class_note_; - } else if (CheckFieldsVisitor::IsReferencePtrError(it->second)) { - error = diag_reference_ptr_to_gc_managed_class_note_; - } else if (it->second == CheckFieldsVisitor::kRefPtrToGCManaged) { - error = diag_ref_ptr_to_gc_managed_class_note_; - } else if (it->second == CheckFieldsVisitor::kOwnPtrToGCManaged) { - error = diag_own_ptr_to_gc_managed_class_note_; - } else if (it->second == CheckFieldsVisitor::kMemberToGCUnmanaged) { - error = diag_member_to_gc_unmanaged_class_note_; - } else if (it->second == CheckFieldsVisitor::kMemberInUnmanaged) { - error = diag_member_in_unmanaged_class_note_; - } else if (it->second == CheckFieldsVisitor::kPtrFromHeapToStack) { - error = diag_stack_allocated_field_note_; - } else if (it->second == CheckFieldsVisitor::kGCDerivedPartObject) { - error = diag_part_object_to_gc_derived_class_note_; + for (auto& error : errors) { + unsigned note; + if (CheckFieldsVisitor::IsRawPtrError(error.second)) { + note = diag_raw_ptr_to_gc_managed_class_note_; + } else if (CheckFieldsVisitor::IsReferencePtrError(error.second)) { + note = diag_reference_ptr_to_gc_managed_class_note_; + } else if (error.second == CheckFieldsVisitor::kRefPtrToGCManaged) { + note = diag_ref_ptr_to_gc_managed_class_note_; + } else if (error.second == CheckFieldsVisitor::kOwnPtrToGCManaged) { + note = diag_own_ptr_to_gc_managed_class_note_; + } else if (error.second == CheckFieldsVisitor::kMemberToGCUnmanaged) { + note = diag_member_to_gc_unmanaged_class_note_; + } else if (error.second == CheckFieldsVisitor::kMemberInUnmanaged) { + note = diag_member_in_unmanaged_class_note_; + } else if (error.second == CheckFieldsVisitor::kPtrFromHeapToStack) { + note = diag_stack_allocated_field_note_; + } else if (error.second == CheckFieldsVisitor::kGCDerivedPartObject) { + note = diag_part_object_to_gc_derived_class_note_; } else { assert(false && "Unknown field error"); } - NoteField(it->first, error); + NoteField(error.first, note); } } void BlinkGCPluginConsumer::ReportClassContainsGCRoots( RecordInfo* info, - CheckGCRootsVisitor::Errors* errors) { - for (CheckGCRootsVisitor::Errors::iterator it = errors->begin(); - it != errors->end(); - ++it) { - CheckGCRootsVisitor::RootPath::iterator path = it->begin(); - FieldPoint* point = *path; - ReportDiagnostic(info->record()->getLocStart(), - diag_class_contains_gc_root_) - << info->record() << point->field(); - while (++path != it->end()) { + const CheckGCRootsVisitor::Errors& errors) { + for (auto& error : errors) { + FieldPoint* point = nullptr; + for (FieldPoint* path : error) { + if (!point) { + point = path; + ReportDiagnostic(info->record()->getLocStart(), + diag_class_contains_gc_root_) + << info->record() << point->field(); + continue; + } NotePartObjectContainsGCRoot(point); - point = *path; + point = path; } NoteFieldContainsGCRoot(point); } @@ -1073,20 +1022,18 @@ void BlinkGCPluginConsumer::ReportFinalizerAccessesFinalizedFields( CXXMethodDecl* dtor, - CheckFinalizerVisitor::Errors* fields) { - for (CheckFinalizerVisitor::Errors::iterator it = fields->begin(); - it != fields->end(); - ++it) { - bool as_eagerly_finalized = it->as_eagerly_finalized; + const CheckFinalizerVisitor::Errors& errors) { + for (auto& error : errors) { + bool as_eagerly_finalized = error.as_eagerly_finalized; unsigned diag_error = as_eagerly_finalized ? diag_finalizer_eagerly_finalized_field_ : diag_finalizer_accesses_finalized_field_; unsigned diag_note = as_eagerly_finalized ? diag_eagerly_finalized_field_note_ : diag_finalized_field_note_; - ReportDiagnostic(it->member->getLocStart(), diag_error) - << dtor << it->field->field(); - NoteField(it->field, diag_note); + ReportDiagnostic(error.member->getLocStart(), diag_error) + << dtor << error.field->field(); + NoteField(error.field, diag_note); } }
diff --git a/tools/clang/blink_gc_plugin/BlinkGCPluginConsumer.h b/tools/clang/blink_gc_plugin/BlinkGCPluginConsumer.h index b1e35ce..d0b49d8 100644 --- a/tools/clang/blink_gc_plugin/BlinkGCPluginConsumer.h +++ b/tools/clang/blink_gc_plugin/BlinkGCPluginConsumer.h
@@ -96,13 +96,14 @@ clang::CXXRecordDecl* base); void ReportFieldsRequireTracing(RecordInfo* info, clang::CXXMethodDecl* trace); - void ReportClassContainsInvalidFields(RecordInfo* info, - CheckFieldsVisitor::Errors* errors); + void ReportClassContainsInvalidFields( + RecordInfo* info, + const CheckFieldsVisitor::Errors& errors); void ReportClassContainsGCRoots(RecordInfo* info, - CheckGCRootsVisitor::Errors* errors); + const CheckGCRootsVisitor::Errors& errors); void ReportFinalizerAccessesFinalizedFields( clang::CXXMethodDecl* dtor, - CheckFinalizerVisitor::Errors* fields); + const CheckFinalizerVisitor::Errors& errors); void ReportClassRequiresFinalization(RecordInfo* info); void ReportClassDoesNotRequireFinalization(RecordInfo* info); void ReportClassMustDeclareGCMixinTraceMethod(RecordInfo* info);