| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/renderer/extensions/chrome_v8_context_set.h" | 5 #include "chrome/renderer/extensions/chrome_v8_context_set.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/tracked_objects.h" | 9 #include "base/tracked_objects.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 context->Invalidate(); | 53 context->Invalidate(); |
| 54 base::MessageLoop::current()->DeleteSoon(FROM_HERE, context); | 54 base::MessageLoop::current()->DeleteSoon(FROM_HERE, context); |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 | 57 |
| 58 ChromeV8ContextSet::ContextSet ChromeV8ContextSet::GetAll() const { | 58 ChromeV8ContextSet::ContextSet ChromeV8ContextSet::GetAll() const { |
| 59 return contexts_; | 59 return contexts_; |
| 60 } | 60 } |
| 61 | 61 |
| 62 ChromeV8Context* ChromeV8ContextSet::GetCurrent() const { | 62 ChromeV8Context* ChromeV8ContextSet::GetCurrent() const { |
| 63 return v8::Context::InContext() ? | 63 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 64 GetByV8Context(v8::Context::GetCurrent()) : NULL; | 64 return isolate->InContext() ? GetByV8Context(isolate->GetCurrentContext()) |
| 65 : NULL; |
| 65 } | 66 } |
| 66 | 67 |
| 67 ChromeV8Context* ChromeV8ContextSet::GetCalling() const { | 68 ChromeV8Context* ChromeV8ContextSet::GetCalling() const { |
| 68 v8::Local<v8::Context> calling = v8::Context::GetCalling(); | 69 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 70 v8::Local<v8::Context> calling = isolate->GetCallingContext(); |
| 69 return calling.IsEmpty() ? NULL : GetByV8Context(calling); | 71 return calling.IsEmpty() ? NULL : GetByV8Context(calling); |
| 70 } | 72 } |
| 71 | 73 |
| 72 ChromeV8Context* ChromeV8ContextSet::GetByV8Context( | 74 ChromeV8Context* ChromeV8ContextSet::GetByV8Context( |
| 73 v8::Handle<v8::Context> v8_context) const { | 75 v8::Handle<v8::Context> v8_context) const { |
| 74 for (ContextSet::const_iterator iter = contexts_.begin(); | 76 for (ContextSet::const_iterator iter = contexts_.begin(); |
| 75 iter != contexts_.end(); ++iter) { | 77 iter != contexts_.end(); ++iter) { |
| 76 if ((*iter)->v8_context() == v8_context) | 78 if ((*iter)->v8_context() == v8_context) |
| 77 return *iter; | 79 return *iter; |
| 78 } | 80 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 (*it)->DispatchOnUnloadEvent(); | 129 (*it)->DispatchOnUnloadEvent(); |
| 128 removed.insert(*it); | 130 removed.insert(*it); |
| 129 Remove(*it); | 131 Remove(*it); |
| 130 } | 132 } |
| 131 } | 133 } |
| 132 | 134 |
| 133 return removed; | 135 return removed; |
| 134 } | 136 } |
| 135 | 137 |
| 136 } // namespace extensions | 138 } // namespace extensions |
| OLD | NEW |