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 "bindings/core/v8/V8DOMActivityLogger.h" | 5 #include "bindings/core/v8/V8DOMActivityLogger.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include "bindings/core/v8/V8Binding.h" | 8 #include "bindings/core/v8/V8Binding.h" |
9 #include "platform/weborigin/KURL.h" | 9 #include "platform/weborigin/KURL.h" |
10 #include "platform/wtf/HashMap.h" | 10 #include "platform/wtf/HashMap.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 return ActivityLogger(world_id, url.Host()); | 76 return ActivityLogger(world_id, url.Host()); |
77 } | 77 } |
78 | 78 |
79 V8DOMActivityLogger* V8DOMActivityLogger::CurrentActivityLogger() { | 79 V8DOMActivityLogger* V8DOMActivityLogger::CurrentActivityLogger() { |
80 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 80 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
81 if (!isolate->InContext()) | 81 if (!isolate->InContext()) |
82 return 0; | 82 return 0; |
83 | 83 |
84 v8::HandleScope handle_scope(isolate); | 84 v8::HandleScope handle_scope(isolate); |
85 v8::Local<v8::Context> context = isolate->GetCurrentContext(); | 85 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
86 if (context.IsEmpty() || !ToLocalDOMWindow(context)) | |
87 return 0; | |
88 | 86 |
89 V8PerContextData* context_data = ScriptState::From(context)->PerContextData(); | 87 V8PerContextData* context_data = ScriptState::From(context)->PerContextData(); |
90 if (!context_data) | 88 if (!context_data) |
91 return 0; | 89 return 0; |
92 | 90 |
93 return context_data->ActivityLogger(); | 91 return context_data->ActivityLogger(); |
94 } | 92 } |
95 | 93 |
96 V8DOMActivityLogger* | 94 V8DOMActivityLogger* |
97 V8DOMActivityLogger::CurrentActivityLoggerIfIsolatedWorld() { | 95 V8DOMActivityLogger::CurrentActivityLoggerIfIsolatedWorld() { |
98 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 96 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
99 if (!isolate->InContext()) | 97 if (!isolate->InContext()) |
100 return 0; | 98 return 0; |
101 | 99 |
102 v8::HandleScope handle_scope(isolate); | 100 v8::HandleScope handle_scope(isolate); |
103 v8::Local<v8::Context> context = isolate->GetCurrentContext(); | 101 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
104 if (context.IsEmpty() || !ToLocalDOMWindow(context)) | |
105 return 0; | |
106 | 102 |
107 ScriptState* script_state = ScriptState::From(context); | 103 ScriptState* script_state = ScriptState::From(context); |
108 if (!script_state->World().IsIsolatedWorld()) | 104 if (!script_state->World().IsIsolatedWorld()) |
109 return 0; | 105 return 0; |
110 | 106 |
111 V8PerContextData* context_data = script_state->PerContextData(); | 107 V8PerContextData* context_data = script_state->PerContextData(); |
112 if (!context_data) | 108 if (!context_data) |
113 return 0; | 109 return 0; |
114 | 110 |
115 return context_data->ActivityLogger(); | 111 return context_data->ActivityLogger(); |
116 } | 112 } |
117 | 113 |
118 } // namespace blink | 114 } // namespace blink |
OLD | NEW |