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

Side by Side Diff: extensions/renderer/event_bindings.cc

Issue 2733283002: Require explicit selection of traits for LazyInstance (Closed)
Patch Set: l10n again Created 3 years, 9 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
« no previous file with comments | « extensions/renderer/dispatcher.cc ('k') | extensions/renderer/extension_frame_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/renderer/event_bindings.h" 5 #include "extensions/renderer/event_bindings.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
(...skipping 18 matching lines...) Expand all
29 namespace extensions { 29 namespace extensions {
30 30
31 namespace { 31 namespace {
32 32
33 // A map of event names to the number of contexts listening to that event. 33 // A map of event names to the number of contexts listening to that event.
34 // We notify the browser about event listeners when we transition between 0 34 // We notify the browser about event listeners when we transition between 0
35 // and 1. 35 // and 1.
36 typedef std::map<std::string, int> EventListenerCounts; 36 typedef std::map<std::string, int> EventListenerCounts;
37 37
38 // A map of extension IDs to listener counts for that extension. 38 // A map of extension IDs to listener counts for that extension.
39 base::LazyInstance<std::map<std::string, EventListenerCounts>> 39 base::LazyInstance<std::map<std::string, EventListenerCounts>>::DestructorAtExit
40 g_listener_counts = LAZY_INSTANCE_INITIALIZER; 40 g_listener_counts = LAZY_INSTANCE_INITIALIZER;
41 41
42 // A map of (extension ID, event name) pairs to the filtered listener counts 42 // A map of (extension ID, event name) pairs to the filtered listener counts
43 // for that pair. The map is used to keep track of which filters are in effect 43 // for that pair. The map is used to keep track of which filters are in effect
44 // for which events. We notify the browser about filtered event listeners when 44 // for which events. We notify the browser about filtered event listeners when
45 // we transition between 0 and 1. 45 // we transition between 0 and 1.
46 using FilteredEventListenerKey = std::pair<std::string, std::string>; 46 using FilteredEventListenerKey = std::pair<std::string, std::string>;
47 using FilteredEventListenerCounts = 47 using FilteredEventListenerCounts =
48 std::map<FilteredEventListenerKey, std::unique_ptr<ValueCounter>>; 48 std::map<FilteredEventListenerKey, std::unique_ptr<ValueCounter>>;
49 base::LazyInstance<FilteredEventListenerCounts> g_filtered_listener_counts = 49 base::LazyInstance<FilteredEventListenerCounts>::DestructorAtExit
50 g_filtered_listener_counts = LAZY_INSTANCE_INITIALIZER;
51
52 base::LazyInstance<EventFilter>::DestructorAtExit g_event_filter =
50 LAZY_INSTANCE_INITIALIZER; 53 LAZY_INSTANCE_INITIALIZER;
51 54
52 base::LazyInstance<EventFilter> g_event_filter = LAZY_INSTANCE_INITIALIZER;
53
54 // Gets a unique string key identifier for a ScriptContext. 55 // Gets a unique string key identifier for a ScriptContext.
55 // TODO(kalman): Just use pointer equality...? 56 // TODO(kalman): Just use pointer equality...?
56 std::string GetKeyForScriptContext(ScriptContext* script_context) { 57 std::string GetKeyForScriptContext(ScriptContext* script_context) {
57 const std::string& extension_id = script_context->GetExtensionID(); 58 const std::string& extension_id = script_context->GetExtensionID();
58 CHECK(crx_file::id_util::IdIsValid(extension_id) || 59 CHECK(crx_file::id_util::IdIsValid(extension_id) ||
59 script_context->url().is_valid()); 60 script_context->url().is_valid());
60 return crx_file::id_util::IdIsValid(extension_id) 61 return crx_file::id_util::IdIsValid(extension_id)
61 ? extension_id 62 ? extension_id
62 : script_context->url().spec(); 63 : script_context->url().spec();
63 } 64 }
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 // Same for filtered events. 364 // Same for filtered events.
364 std::set<int> attached_matcher_ids_safe = attached_matcher_ids_; 365 std::set<int> attached_matcher_ids_safe = attached_matcher_ids_;
365 for (int matcher_id : attached_matcher_ids_safe) { 366 for (int matcher_id : attached_matcher_ids_safe) {
366 DetachFilteredEvent(matcher_id, false /* is_manual */); 367 DetachFilteredEvent(matcher_id, false /* is_manual */);
367 } 368 }
368 DCHECK(attached_matcher_ids_.empty()) 369 DCHECK(attached_matcher_ids_.empty())
369 << "Filtered events cannot be attached during invalidation"; 370 << "Filtered events cannot be attached during invalidation";
370 } 371 }
371 372
372 } // namespace extensions 373 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/dispatcher.cc ('k') | extensions/renderer/extension_frame_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698