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

Side by Side Diff: extensions/renderer/gc_callback_unittest.cc

Issue 1293673002: Create thread-safe RendererExtensionRegistry from ExtensionSet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/memory/weak_ptr.h" 6 #include "base/memory/weak_ptr.h"
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "extensions/common/extension.h" 8 #include "extensions/common/extension.h"
9 #include "extensions/common/extension_set.h" 9 #include "extensions/common/extension_set.h"
10 #include "extensions/common/features/feature.h" 10 #include "extensions/common/features/feature.h"
(...skipping 11 matching lines...) Expand all
22 namespace { 22 namespace {
23 23
24 void SetToTrue(bool* value) { 24 void SetToTrue(bool* value) {
25 if (*value) 25 if (*value)
26 ADD_FAILURE() << "Value is already true"; 26 ADD_FAILURE() << "Value is already true";
27 *value = true; 27 *value = true;
28 } 28 }
29 29
30 class GCCallbackTest : public testing::Test { 30 class GCCallbackTest : public testing::Test {
31 public: 31 public:
32 GCCallbackTest() : script_context_set_(&extensions_, &active_extensions_) {} 32 GCCallbackTest() : script_context_set_(&active_extensions_) {}
33 33
34 protected: 34 protected:
35 base::MessageLoop& message_loop() { return message_loop_; } 35 base::MessageLoop& message_loop() { return message_loop_; }
36 36
37 ScriptContextSet& script_context_set() { return script_context_set_; } 37 ScriptContextSet& script_context_set() { return script_context_set_; }
38 38
39 v8::Local<v8::Context> v8_context() { 39 v8::Local<v8::Context> v8_context() {
40 return v8::Local<v8::Context>::New(v8::Isolate::GetCurrent(), v8_context_); 40 return v8::Local<v8::Context>::New(v8::Isolate::GetCurrent(), v8_context_);
41 } 41 }
42 42
(...skipping 22 matching lines...) Expand all
65 } 65 }
66 66
67 void TearDown() override { 67 void TearDown() override {
68 gin_context_holder_.reset(); 68 gin_context_holder_.reset();
69 v8_context_.Reset(); 69 v8_context_.Reset();
70 RequestGarbageCollection(); 70 RequestGarbageCollection();
71 } 71 }
72 72
73 base::MessageLoop message_loop_; 73 base::MessageLoop message_loop_;
74 ScopedWebFrame web_frame_; // (this will construct the v8::Isolate) 74 ScopedWebFrame web_frame_; // (this will construct the v8::Isolate)
75 ExtensionSet extensions_;
76 ExtensionIdSet active_extensions_; 75 ExtensionIdSet active_extensions_;
77 ScriptContextSet script_context_set_; 76 ScriptContextSet script_context_set_;
78 v8::Global<v8::Context> v8_context_; 77 v8::Global<v8::Context> v8_context_;
79 scoped_ptr<gin::ContextHolder> gin_context_holder_; 78 scoped_ptr<gin::ContextHolder> gin_context_holder_;
80 79
81 DISALLOW_COPY_AND_ASSIGN(GCCallbackTest); 80 DISALLOW_COPY_AND_ASSIGN(GCCallbackTest);
82 }; 81 };
83 82
84 TEST_F(GCCallbackTest, GCBeforeContextInvalidated) { 83 TEST_F(GCCallbackTest, GCBeforeContextInvalidated) {
85 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 84 v8::Isolate* isolate = v8::Isolate::GetCurrent();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 // Trigger a GC. The callback should not be invoked because the fallback was 151 // Trigger a GC. The callback should not be invoked because the fallback was
153 // already invoked. 152 // already invoked.
154 RequestGarbageCollection(); 153 RequestGarbageCollection();
155 message_loop().RunUntilIdle(); 154 message_loop().RunUntilIdle();
156 155
157 EXPECT_FALSE(callback_invoked); 156 EXPECT_FALSE(callback_invoked);
158 } 157 }
159 158
160 } // namespace 159 } // namespace
161 } // namespace extensions 160 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/extension_injection_host.cc ('k') | extensions/renderer/renderer_extension_registry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698