OLD | NEW |
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 "platform/weborigin/KURL.h" |
10 #include "wtf/HashMap.h" | 10 #include "wtf/HashMap.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 static DOMActivityLoggerMapForIsolatedWorld& domActivityLoggersForIsolatedWorld(
) | 26 static DOMActivityLoggerMapForIsolatedWorld& domActivityLoggersForIsolatedWorld(
) |
27 { | 27 { |
28 ASSERT(isMainThread()); | 28 ASSERT(isMainThread()); |
29 DEFINE_STATIC_LOCAL(DOMActivityLoggerMapForIsolatedWorld, map, ()); | 29 DEFINE_STATIC_LOCAL(DOMActivityLoggerMapForIsolatedWorld, map, ()); |
30 return map; | 30 return map; |
31 } | 31 } |
32 | 32 |
33 void V8DOMActivityLogger::setActivityLogger(int worldId, const String& extension
Id, PassOwnPtr<V8DOMActivityLogger> logger) | 33 void V8DOMActivityLogger::setActivityLogger(int worldId, const String& extension
Id, PassOwnPtr<V8DOMActivityLogger> logger) |
34 { | 34 { |
35 // FIXME: The following line is a stub to allow appropriate modifications to | 35 if (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); | 36 domActivityLoggersForIsolatedWorld().set(worldId, logger); |
42 } else { | 37 else |
43 domActivityLoggersForMainWorld().set(extensionId, logger); | 38 domActivityLoggersForMainWorld().set(extensionId, logger); |
44 } | |
45 } | 39 } |
46 | 40 |
47 V8DOMActivityLogger* V8DOMActivityLogger::activityLogger(int worldId, const Stri
ng& extensionId) | 41 V8DOMActivityLogger* V8DOMActivityLogger::activityLogger(int worldId, const Stri
ng& extensionId) |
48 { | 42 { |
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) { | 43 if (worldId) { |
58 DOMActivityLoggerMapForIsolatedWorld& loggers = domActivityLoggersForIso
latedWorld(); | 44 DOMActivityLoggerMapForIsolatedWorld& loggers = domActivityLoggersForIso
latedWorld(); |
59 DOMActivityLoggerMapForIsolatedWorld::iterator it = loggers.find(worldId
); | 45 DOMActivityLoggerMapForIsolatedWorld::iterator it = loggers.find(worldId
); |
60 return it == loggers.end() ? 0 : it->value.get(); | 46 return it == loggers.end() ? 0 : it->value.get(); |
61 } | 47 } |
62 | 48 |
63 if (extensionId.isEmpty()) | 49 if (extensionId.isEmpty()) |
64 return 0; | 50 return 0; |
65 | 51 |
66 DOMActivityLoggerMapForMainWorld& loggers = domActivityLoggersForMainWorld()
; | 52 DOMActivityLoggerMapForMainWorld& loggers = domActivityLoggersForMainWorld()
; |
67 DOMActivityLoggerMapForMainWorld::iterator it = loggers.find(extensionId); | 53 DOMActivityLoggerMapForMainWorld::iterator it = loggers.find(extensionId); |
68 return it == loggers.end() ? 0 : it->value.get(); | 54 return it == loggers.end() ? 0 : it->value.get(); |
69 } | 55 } |
70 | 56 |
71 V8DOMActivityLogger* V8DOMActivityLogger::activityLogger(int worldId, const KURL
& url) | 57 V8DOMActivityLogger* V8DOMActivityLogger::activityLogger(int worldId, const KURL
& url) |
72 { | 58 { |
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. | 59 // extension ID is ignored for worldId != 0. |
78 if (worldId) | 60 if (worldId) |
79 return activityLogger(worldId, String()); | 61 return activityLogger(worldId, String()); |
80 | 62 |
81 // To find an activity logger that corresponds to the main world of an | 63 // 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 | 64 // extension, we need to obtain the extension ID. Extension ID is a hostname |
83 // of a background page's URL. | 65 // of a background page's URL. |
84 if (!url.protocolIs("chrome-extension")) | 66 if (!url.protocolIs("chrome-extension")) |
85 return 0; | 67 return 0; |
86 | 68 |
87 return activityLogger(worldId, url.host()); | 69 return activityLogger(worldId, url.host()); |
88 } | 70 } |
89 | 71 |
90 } // namespace WebCore | 72 } // namespace WebCore |
OLD | NEW |