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

Side by Side Diff: Source/bindings/v8/V8DOMActivityLogger.cpp

Issue 257803006: Fixing wrong extension ID in Activity Log entries. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: bug fix Created 6 years, 6 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 | « Source/bindings/v8/V8DOMActivityLogger.h ('k') | Source/bindings/v8/V8PerContextData.h » ('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 "config.h" 5 #include "config.h"
6 #include "bindings/v8/V8DOMActivityLogger.h" 6 #include "bindings/v8/V8DOMActivityLogger.h"
7 7
8 #include "bindings/v8/V8Binding.h" 8 #include "bindings/v8/V8Binding.h"
9 #include "platform/weborigin/KURL.h"
9 #include "wtf/HashMap.h" 10 #include "wtf/HashMap.h"
11 #include "wtf/MainThread.h"
12 #include "wtf/text/StringHash.h"
10 13
11 namespace WebCore { 14 namespace WebCore {
12 15
13 typedef HashMap<int, OwnPtr<V8DOMActivityLogger>, WTF::IntHash<int>, WTF::Unsign edWithZeroKeyHashTraits<int> > DOMActivityLoggerMap; 16 typedef HashMap<String, OwnPtr<V8DOMActivityLogger> > DOMActivityLoggerMapForMai nWorld;
17 typedef HashMap<int, OwnPtr<V8DOMActivityLogger>, WTF::IntHash<int>, WTF::Unsign edWithZeroKeyHashTraits<int> > DOMActivityLoggerMapForIsolatedWorld;
14 18
15 static DOMActivityLoggerMap& domActivityLoggers() 19 static DOMActivityLoggerMapForMainWorld& domActivityLoggersForMainWorld()
16 { 20 {
17 ASSERT(isMainThread()); 21 ASSERT(isMainThread());
18 DEFINE_STATIC_LOCAL(DOMActivityLoggerMap, map, ()); 22 DEFINE_STATIC_LOCAL(DOMActivityLoggerMapForMainWorld, map, ());
19 return map; 23 return map;
20 } 24 }
21 25
22 void V8DOMActivityLogger::setActivityLogger(int worldId, PassOwnPtr<V8DOMActivit yLogger> logger) 26 static DOMActivityLoggerMapForIsolatedWorld& domActivityLoggersForIsolatedWorld( )
23 { 27 {
24 domActivityLoggers().set(worldId, logger); 28 ASSERT(isMainThread());
29 DEFINE_STATIC_LOCAL(DOMActivityLoggerMapForIsolatedWorld, map, ());
30 return map;
25 } 31 }
26 32
27 V8DOMActivityLogger* V8DOMActivityLogger::activityLogger(int worldId) 33 void V8DOMActivityLogger::setActivityLogger(int worldId, const String& extension Id, PassOwnPtr<V8DOMActivityLogger> logger)
28 { 34 {
29 DOMActivityLoggerMap& loggers = domActivityLoggers(); 35 // FIXME: The following line is a stub to allow appropriate modifications to
30 DOMActivityLoggerMap::iterator it = loggers.find(worldId); 36 // chromium code base. When the modifications are done, remove this line.
37 domActivityLoggersForIsolatedWorld().set(worldId, logger);
38 return;
39
40 if (worldId) {
41 domActivityLoggersForIsolatedWorld().set(worldId, logger);
42 } else {
43 domActivityLoggersForMainWorld().set(extensionId, logger);
44 }
45 }
46
47 V8DOMActivityLogger* V8DOMActivityLogger::activityLogger(int worldId, const Stri ng& extensionId)
48 {
49 {
50 // FIXME: The following lines are a stub to allow appropriate modificati ons to
51 // chromium code base. When the modifications are done, remove these lin es.
52 DOMActivityLoggerMapForIsolatedWorld& loggers = domActivityLoggersForIso latedWorld();
53 DOMActivityLoggerMapForIsolatedWorld::iterator it = loggers.find(worldId );
54 return it == loggers.end() ? 0 : it->value.get();
55 }
56
57 if (worldId) {
58 DOMActivityLoggerMapForIsolatedWorld& loggers = domActivityLoggersForIso latedWorld();
59 DOMActivityLoggerMapForIsolatedWorld::iterator it = loggers.find(worldId );
60 return it == loggers.end() ? 0 : it->value.get();
61 }
62
63 if (extensionId.isEmpty())
64 return 0;
65
66 DOMActivityLoggerMapForMainWorld& loggers = domActivityLoggersForMainWorld() ;
67 DOMActivityLoggerMapForMainWorld::iterator it = loggers.find(extensionId);
31 return it == loggers.end() ? 0 : it->value.get(); 68 return it == loggers.end() ? 0 : it->value.get();
32 } 69 }
33 70
71 V8DOMActivityLogger* V8DOMActivityLogger::activityLogger(int worldId, const KURL & url)
72 {
73 // FIXME: The following line is a stub to allow appropriate modifications to
74 // chromium code base. When the modifications are done, remove this line.
75 return activityLogger(worldId, String());
76
77 // extension ID is ignored for worldId != 0.
78 if (worldId)
79 return activityLogger(worldId, String());
80
81 // To find an activity logger that corresponds to the main world of an
82 // extension, we need to obtain the extension ID. Extension ID is a hostname
83 // of a background page's URL.
84 if (!url.protocolIs("chrome-extension"))
85 return 0;
86
87 return activityLogger(worldId, url.host());
88 }
89
34 } // namespace WebCore 90 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/V8DOMActivityLogger.h ('k') | Source/bindings/v8/V8PerContextData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698