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

Side by Side Diff: Source/modules/indexeddb/IDBRequestTest.cpp

Issue 318023002: Oilpan: Prepare to make ExecutionContext GarbageCollectedMixin. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 class NullEventQueue FINAL : public EventQueue { 47 class NullEventQueue FINAL : public EventQueue {
48 public: 48 public:
49 NullEventQueue() { } 49 NullEventQueue() { }
50 virtual ~NullEventQueue() { } 50 virtual ~NullEventQueue() { }
51 virtual bool enqueueEvent(PassRefPtrWillBeRawPtr<Event>) OVERRIDE { return t rue; } 51 virtual bool enqueueEvent(PassRefPtrWillBeRawPtr<Event>) OVERRIDE { return t rue; }
52 virtual bool cancelEvent(Event*) OVERRIDE { return true; } 52 virtual bool cancelEvent(Event*) OVERRIDE { return true; }
53 virtual void close() OVERRIDE { } 53 virtual void close() OVERRIDE { }
54 }; 54 };
55 55
56 class NullExecutionContext FINAL : public ExecutionContext, public RefCounted<Nu llExecutionContext> { 56 class NullExecutionContext FINAL : public RefCountedWillBeGarbageCollectedFinali zed<NullExecutionContext>, public ExecutionContext {
57 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(NullExecutionContext);
57 public: 58 public:
59 void trace(Visitor* visitor) { ExecutionContext::trace(visitor); }
60 #if !ENABLE(OILPAN)
58 using RefCounted<NullExecutionContext>::ref; 61 using RefCounted<NullExecutionContext>::ref;
59 using RefCounted<NullExecutionContext>::deref; 62 using RefCounted<NullExecutionContext>::deref;
60 63
61 virtual void refExecutionContext() OVERRIDE { ref(); } 64 virtual void refExecutionContext() OVERRIDE { ref(); }
62 virtual void derefExecutionContext() OVERRIDE { deref(); } 65 virtual void derefExecutionContext() OVERRIDE { deref(); }
66 #endif
63 virtual EventQueue* eventQueue() const OVERRIDE { return m_queue.get(); } 67 virtual EventQueue* eventQueue() const OVERRIDE { return m_queue.get(); }
64 68
65 NullExecutionContext(); 69 NullExecutionContext();
66 private: 70 private:
67 OwnPtr<EventQueue> m_queue; 71 OwnPtr<EventQueue> m_queue;
68 }; 72 };
69 73
70 NullExecutionContext::NullExecutionContext() 74 NullExecutionContext::NullExecutionContext()
71 : m_queue(adoptPtr(new NullEventQueue())) 75 : m_queue(adoptPtr(new NullEventQueue()))
72 { 76 {
73 } 77 }
74 78
75 class IDBRequestTest : public testing::Test { 79 class IDBRequestTest : public testing::Test {
76 public: 80 public:
77 IDBRequestTest() 81 IDBRequestTest()
78 : m_scope(v8::Isolate::GetCurrent()) 82 : m_scope(v8::Isolate::GetCurrent())
79 , m_executionContext(adoptRef(new NullExecutionContext())) 83 , m_executionContext(adoptRefWillBeNoop(new NullExecutionContext()))
80 { 84 {
81 m_scope.scriptState()->setExecutionContext(m_executionContext.get()); 85 m_scope.scriptState()->setExecutionContext(m_executionContext.get());
82 } 86 }
83 87
84 ~IDBRequestTest() 88 ~IDBRequestTest()
85 { 89 {
86 m_scope.scriptState()->setExecutionContext(0); 90 m_scope.scriptState()->setExecutionContext(0);
87 } 91 }
88 92
89 v8::Isolate* isolate() const { return m_scope.isolate(); } 93 v8::Isolate* isolate() const { return m_scope.isolate(); }
90 ScriptState* scriptState() const { return m_scope.scriptState(); } 94 ScriptState* scriptState() const { return m_scope.scriptState(); }
91 ExecutionContext* executionContext() const { return m_scope.scriptState()->e xecutionContext(); } 95 ExecutionContext* executionContext() const { return m_scope.scriptState()->e xecutionContext(); }
92 96
93 private: 97 private:
94 V8TestingScope m_scope; 98 V8TestingScope m_scope;
95 RefPtr<ExecutionContext> m_executionContext; 99 RefPtrWillBePersistent<ExecutionContext> m_executionContext;
96 }; 100 };
97 101
98 TEST_F(IDBRequestTest, EventsAfterStopping) 102 TEST_F(IDBRequestTest, EventsAfterStopping)
99 { 103 {
100 IDBTransaction* transaction = 0; 104 IDBTransaction* transaction = 0;
101 IDBRequest* request = IDBRequest::create(scriptState(), IDBAny::createUndefi ned(), transaction); 105 IDBRequest* request = IDBRequest::create(scriptState(), IDBAny::createUndefi ned(), transaction);
102 EXPECT_EQ(request->readyState(), "pending"); 106 EXPECT_EQ(request->readyState(), "pending");
103 executionContext()->stopActiveDOMObjects(); 107 executionContext()->stopActiveDOMObjects();
104 108
105 // Ensure none of the following raise assertions in stopped state: 109 // Ensure none of the following raise assertions in stopped state:
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); 179 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create();
176 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState(), call backs, transactionId, version); 180 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState(), call backs, transactionId, version);
177 EXPECT_EQ(request->readyState(), "pending"); 181 EXPECT_EQ(request->readyState(), "pending");
178 182
179 executionContext()->stopActiveDOMObjects(); 183 executionContext()->stopActiveDOMObjects();
180 request->onSuccess(backend.release(), metadata); 184 request->onSuccess(backend.release(), metadata);
181 } 185 }
182 } 186 }
183 187
184 } // namespace 188 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698