Chromium Code Reviews| 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 | |
| 36 // chromium code base. When the modifications are done, remove this line. | |
| 37 domActivityLoggersForIsolatedWorld().set(worldId, logger); | |
| 38 return; | |
| 39 | |
| 40 if (worldId) { | 35 if (worldId) { |
| 41 domActivityLoggersForIsolatedWorld().set(worldId, logger); | 36 domActivityLoggersForIsolatedWorld().set(worldId, logger); |
|
jochen (gone - plz use gerrit)
2014/06/06 06:55:33
nit. no { } for single line bodies
| |
| 42 } else { | 37 } else { |
| 43 domActivityLoggersForMainWorld().set(extensionId, logger); | 38 domActivityLoggersForMainWorld().set(extensionId, logger); |
| 44 } | 39 } |
| 45 } | 40 } |
| 46 | 41 |
| 47 V8DOMActivityLogger* V8DOMActivityLogger::activityLogger(int worldId, const Stri ng& extensionId) | 42 V8DOMActivityLogger* V8DOMActivityLogger::activityLogger(int worldId, const Stri ng& extensionId) |
| 48 { | 43 { |
| 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) { | 44 if (worldId) { |
| 58 DOMActivityLoggerMapForIsolatedWorld& loggers = domActivityLoggersForIso latedWorld(); | 45 DOMActivityLoggerMapForIsolatedWorld& loggers = domActivityLoggersForIso latedWorld(); |
| 59 DOMActivityLoggerMapForIsolatedWorld::iterator it = loggers.find(worldId ); | 46 DOMActivityLoggerMapForIsolatedWorld::iterator it = loggers.find(worldId ); |
| 60 return it == loggers.end() ? 0 : it->value.get(); | 47 return it == loggers.end() ? 0 : it->value.get(); |
| 61 } | 48 } |
| 62 | 49 |
| 63 if (extensionId.isEmpty()) | 50 if (extensionId.isEmpty()) |
| 64 return 0; | 51 return 0; |
| 65 | 52 |
| 66 DOMActivityLoggerMapForMainWorld& loggers = domActivityLoggersForMainWorld() ; | 53 DOMActivityLoggerMapForMainWorld& loggers = domActivityLoggersForMainWorld() ; |
| 67 DOMActivityLoggerMapForMainWorld::iterator it = loggers.find(extensionId); | 54 DOMActivityLoggerMapForMainWorld::iterator it = loggers.find(extensionId); |
| 68 return it == loggers.end() ? 0 : it->value.get(); | 55 return it == loggers.end() ? 0 : it->value.get(); |
| 69 } | 56 } |
| 70 | 57 |
| 71 V8DOMActivityLogger* V8DOMActivityLogger::activityLogger(int worldId, const KURL & url) | 58 V8DOMActivityLogger* V8DOMActivityLogger::activityLogger(int worldId, const KURL & url) |
| 72 { | 59 { |
| 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. | 60 // extension ID is ignored for worldId != 0. |
| 78 if (worldId) | 61 if (worldId) |
| 79 return activityLogger(worldId, String()); | 62 return activityLogger(worldId, String()); |
| 80 | 63 |
| 81 // To find an activity logger that corresponds to the main world of an | 64 // 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 | 65 // extension, we need to obtain the extension ID. Extension ID is a hostname |
| 83 // of a background page's URL. | 66 // of a background page's URL. |
| 84 if (!url.protocolIs("chrome-extension")) | 67 if (!url.protocolIs("chrome-extension")) |
| 85 return 0; | 68 return 0; |
| 86 | 69 |
| 87 return activityLogger(worldId, url.host()); | 70 return activityLogger(worldId, url.host()); |
| 88 } | 71 } |
| 89 | 72 |
| 90 } // namespace WebCore | 73 } // namespace WebCore |
| OLD | NEW |