Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/conflicts/module_database_impl_win.h" | |
| 6 | |
| 7 #include "chrome/browser/conflicts/module_database_win.h" | |
| 8 #include "content/public/browser/browser_thread.h" | |
| 9 #include "mojo/public/cpp/bindings/strong_binding.h" | |
| 10 | |
| 11 ModuleDatabaseImpl::ModuleDatabaseImpl(::ModuleDatabase* module_database) | |
| 12 : module_database_(module_database), process_id_(0) {} | |
| 13 | |
| 14 ModuleDatabaseImpl::~ModuleDatabaseImpl() = default; | |
| 15 | |
| 16 // static | |
| 17 void ModuleDatabaseImpl::Create(::ModuleDatabase* module_database, | |
| 18 mojom::ModuleDatabaseRequest request) { | |
| 19 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
| 20 std::unique_ptr<ModuleDatabaseImpl> module_database_impl = | |
| 21 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.
| |
| 22 base::Closure error_handler = | |
| 23 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
| |
| 24 base::Unretained(module_database_impl.get())); | |
| 25 auto binding = mojo::MakeStrongBinding(std::move(module_database_impl), | |
| 26 std::move(request)); | |
| 27 binding->set_connection_error_handler(error_handler); | |
| 28 } | |
| 29 | |
| 30 void ModuleDatabaseImpl::OnProcessStarted(uint32_t process_id, | |
| 31 uint32_t process_type) { | |
| 32 // This should only be called once, and it should be the first message | |
| 33 // received. | |
| 34 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
| |
| 35 process_id_ = process_id; | |
|
sky
2016/12/14 21:58:08
DCHECK_NE(0u, process_id_);
chrisha
2016/12/19 20:15:36
Done.
| |
| 36 module_database_->OnProcessStarted( | |
| 37 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.
| |
| 38 } | |
| 39 | |
| 40 void ModuleDatabaseImpl::OnModuleEvent(mojom::ModuleEventPtr module_event) { | |
| 41 // This should only be called after OnProcessStarted has been called. | |
| 42 DCHECK_NE(0u, process_id_); | |
| 43 module_database_->OnModuleEvent(process_id_, *module_event.get()); | |
| 44 } | |
| 45 | |
| 46 void ModuleDatabaseImpl::OnProcessEnded() { | |
| 47 // This should only be called after OnProcessStarted has been called. | |
| 48 DCHECK_NE(0u, process_id_); | |
| 49 module_database_->OnProcessEnded(process_id_); | |
| 50 } | |
| OLD | NEW |