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

Side by Side Diff: chrome/browser/conflicts/module_database_win.cc

Issue 2613803005: [win] Enable ModuleDatabase behind a flag. (Closed)
Patch Set: Rebase. Created 3 years, 11 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "chrome/browser/conflicts/module_database_win.h" 5 #include "chrome/browser/conflicts/module_database_win.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <tuple> 8 #include <tuple>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 11
12 namespace { 12 namespace {
13 13
14 // Document the assumptions made on the ProcessType enum in order to convert 14 // Document the assumptions made on the ProcessType enum in order to convert
15 // them to bits. 15 // them to bits.
16 static_assert(content::PROCESS_TYPE_UNKNOWN == 1, 16 static_assert(content::PROCESS_TYPE_UNKNOWN == 1,
17 "assumes unknown process type has value 1"); 17 "assumes unknown process type has value 1");
18 static_assert(content::PROCESS_TYPE_BROWSER == 2, 18 static_assert(content::PROCESS_TYPE_BROWSER == 2,
19 "assumes browser process type has value 2"); 19 "assumes browser process type has value 2");
20 constexpr uint32_t kFirstValidProcessType = content::PROCESS_TYPE_BROWSER; 20 constexpr uint32_t kFirstValidProcessType = content::PROCESS_TYPE_BROWSER;
21 21
22 ModuleDatabase* g_instance = nullptr;
23
22 } // namespace 24 } // namespace
23 25
24 ModuleDatabase::ModuleDatabase( 26 ModuleDatabase::ModuleDatabase(
25 scoped_refptr<base::SequencedTaskRunner> task_runner) 27 scoped_refptr<base::SequencedTaskRunner> task_runner)
26 : task_runner_(std::move(task_runner)), weak_ptr_factory_(this) {} 28 : task_runner_(std::move(task_runner)), weak_ptr_factory_(this) {}
27 29
28 ModuleDatabase::~ModuleDatabase() = default; 30 ModuleDatabase::~ModuleDatabase() {
31 if (this == g_instance)
32 g_instance = nullptr;
33 }
34
35 // static
36 ModuleDatabase* ModuleDatabase::GetInstance() {
37 return g_instance;
38 }
39
40 // static
41 void ModuleDatabase::SetInstance(
42 std::unique_ptr<ModuleDatabase> module_database) {
43 DCHECK_EQ(nullptr, g_instance);
44 // This is deliberately leaked. It can be cleaned up by manually deleting the
45 // ModuleDatabase
46 g_instance = module_database.release();
47 }
29 48
30 void ModuleDatabase::OnProcessStarted(uint32_t process_id, 49 void ModuleDatabase::OnProcessStarted(uint32_t process_id,
31 uint64_t creation_time, 50 uint64_t creation_time,
32 content::ProcessType process_type) { 51 content::ProcessType process_type) {
33 DCHECK(task_runner_->RunsTasksOnCurrentThread()); 52 DCHECK(task_runner_->RunsTasksOnCurrentThread());
34 CreateProcessInfo(process_id, creation_time, process_type); 53 CreateProcessInfo(process_id, creation_time, process_type);
35 } 54 }
36 55
37 void ModuleDatabase::OnModuleLoad(uint32_t process_id, 56 void ModuleDatabase::OnModuleLoad(uint32_t process_id,
38 uint64_t creation_time, 57 uint64_t creation_time,
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 } 365 }
347 366
348 // ModuleDatabase::ProcessInfoData --------------------------------------------- 367 // ModuleDatabase::ProcessInfoData ---------------------------------------------
349 368
350 ModuleDatabase::ProcessInfoData::ProcessInfoData() = default; 369 ModuleDatabase::ProcessInfoData::ProcessInfoData() = default;
351 370
352 ModuleDatabase::ProcessInfoData::ProcessInfoData(const ProcessInfoData& other) = 371 ModuleDatabase::ProcessInfoData::ProcessInfoData(const ProcessInfoData& other) =
353 default; 372 default;
354 373
355 ModuleDatabase::ProcessInfoData::~ProcessInfoData() = default; 374 ModuleDatabase::ProcessInfoData::~ProcessInfoData() = default;
OLDNEW
« no previous file with comments | « chrome/browser/conflicts/module_database_win.h ('k') | chrome/browser/conflicts/module_event_sink_impl_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698