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

Unified Diff: chrome/browser/conflicts/module_database_impl_win.cc

Issue 2576843002: [win] Create ModuleDatabase and ModuleEventSinkImpl. (Closed)
Patch Set: Created 4 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/conflicts/module_database_impl_win.cc
diff --git a/chrome/browser/conflicts/module_database_impl_win.cc b/chrome/browser/conflicts/module_database_impl_win.cc
new file mode 100644
index 0000000000000000000000000000000000000000..459acb47185ccd80645923dde7aa18739d80cf18
--- /dev/null
+++ b/chrome/browser/conflicts/module_database_impl_win.cc
@@ -0,0 +1,50 @@
+// 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.
+
+#include "chrome/browser/conflicts/module_database_impl_win.h"
+
+#include "chrome/browser/conflicts/module_database_win.h"
+#include "content/public/browser/browser_thread.h"
+#include "mojo/public/cpp/bindings/strong_binding.h"
+
+ModuleDatabaseImpl::ModuleDatabaseImpl(::ModuleDatabase* module_database)
+ : module_database_(module_database), process_id_(0) {}
+
+ModuleDatabaseImpl::~ModuleDatabaseImpl() = default;
+
+// static
+void ModuleDatabaseImpl::Create(::ModuleDatabase* module_database,
+ mojom::ModuleDatabaseRequest request) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ std::unique_ptr<ModuleDatabaseImpl> module_database_impl =
+ base::WrapUnique(new ModuleDatabaseImpl(module_database));
grt (UTC plus 2) 2016/12/15 09:07:12 base::MakeUnique<ModuleDatabaseImpl>(module_databa
chrisha 2016/12/19 20:15:36 Done.
+ base::Closure error_handler =
+ base::Bind(&ModuleDatabaseImpl::OnProcessEnded,
grt (UTC plus 2) 2016/12/15 09:07:12 #include "base/bind.h" #include "base/callback.h"
chrisha 2016/12/19 20:15:36 bind.h I get, but why callback.h? I don't make use
+ base::Unretained(module_database_impl.get()));
+ auto binding = mojo::MakeStrongBinding(std::move(module_database_impl),
+ std::move(request));
+ binding->set_connection_error_handler(error_handler);
+}
+
+void ModuleDatabaseImpl::OnProcessStarted(uint32_t process_id,
+ uint32_t process_type) {
+ // This should only be called once, and it should be the first message
+ // received.
+ DCHECK_EQ(0u, process_id_);
sky 2016/12/14 21:58:08 Won't a misbehaving client cause problems here? Wh
chrisha 2016/12/19 20:15:36 The ModuleDatabase itself is robust to misuse, as
+ process_id_ = process_id;
sky 2016/12/14 21:58:08 DCHECK_NE(0u, process_id_);
chrisha 2016/12/19 20:15:36 Done.
+ module_database_->OnProcessStarted(
+ process_id, static_cast<content::ProcessType>(process_type));
sky 2016/12/14 21:58:08 You need to valid process_type.
chrisha 2016/12/19 20:15:36 Done.
+}
+
+void ModuleDatabaseImpl::OnModuleEvent(mojom::ModuleEventPtr module_event) {
+ // This should only be called after OnProcessStarted has been called.
+ DCHECK_NE(0u, process_id_);
+ module_database_->OnModuleEvent(process_id_, *module_event.get());
+}
+
+void ModuleDatabaseImpl::OnProcessEnded() {
+ // This should only be called after OnProcessStarted has been called.
+ DCHECK_NE(0u, process_id_);
+ module_database_->OnProcessEnded(process_id_);
+}

Powered by Google App Engine
This is Rietveld 408576698