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 "modules/serviceworkers/ServiceWorkerContainer.h" | 6 #include "modules/serviceworkers/ServiceWorkerContainer.h" |
7 | 7 |
8 #include "bindings/core/v8/Dictionary.h" | 8 #include "bindings/core/v8/Dictionary.h" |
9 #include "bindings/core/v8/ScriptFunction.h" | 9 #include "bindings/core/v8/ScriptFunction.h" |
10 #include "bindings/core/v8/ScriptPromise.h" | 10 #include "bindings/core/v8/ScriptPromise.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 | 35 |
36 struct StubScriptFunction { | 36 struct StubScriptFunction { |
37 public: | 37 public: |
38 StubScriptFunction() | 38 StubScriptFunction() |
39 : m_callCount(0) | 39 : m_callCount(0) |
40 { | 40 { |
41 } | 41 } |
42 | 42 |
43 // The returned ScriptFunction can outlive the StubScriptFunction, | 43 // The returned ScriptFunction can outlive the StubScriptFunction, |
44 // but it should not be called after the StubScriptFunction dies. | 44 // but it should not be called after the StubScriptFunction dies. |
45 v8::Handle<v8::Function> function(ScriptState* scriptState) | 45 v8::Local<v8::Function> function(ScriptState* scriptState) |
46 { | 46 { |
47 return ScriptFunctionImpl::createFunction(scriptState, *this); | 47 return ScriptFunctionImpl::createFunction(scriptState, *this); |
48 } | 48 } |
49 | 49 |
50 size_t callCount() { return m_callCount; } | 50 size_t callCount() { return m_callCount; } |
51 ScriptValue arg() { return m_arg; } | 51 ScriptValue arg() { return m_arg; } |
52 | 52 |
53 private: | 53 private: |
54 size_t m_callCount; | 54 size_t m_callCount; |
55 ScriptValue m_arg; | 55 ScriptValue m_arg; |
56 | 56 |
57 class ScriptFunctionImpl : public ScriptFunction { | 57 class ScriptFunctionImpl : public ScriptFunction { |
58 public: | 58 public: |
59 static v8::Handle<v8::Function> createFunction(ScriptState* scriptState,
StubScriptFunction& owner) | 59 static v8::Local<v8::Function> createFunction(ScriptState* scriptState,
StubScriptFunction& owner) |
60 { | 60 { |
61 ScriptFunctionImpl* self = new ScriptFunctionImpl(scriptState, owner
); | 61 ScriptFunctionImpl* self = new ScriptFunctionImpl(scriptState, owner
); |
62 return self->bindToV8Function(); | 62 return self->bindToV8Function(); |
63 } | 63 } |
64 | 64 |
65 private: | 65 private: |
66 ScriptFunctionImpl(ScriptState* scriptState, StubScriptFunction& owner) | 66 ScriptFunctionImpl(ScriptState* scriptState, StubScriptFunction& owner) |
67 : ScriptFunction(scriptState) | 67 : ScriptFunction(scriptState) |
68 , m_owner(owner) | 68 , m_owner(owner) |
69 { | 69 { |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 container->getRegistration(scriptState(), ""); | 346 container->getRegistration(scriptState(), ""); |
347 EXPECT_EQ(1ul, stubProvider.getRegistrationCallCount()); | 347 EXPECT_EQ(1ul, stubProvider.getRegistrationCallCount()); |
348 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/index.html")), stubPro
vider.getRegistrationURL()); | 348 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/index.html")), stubPro
vider.getRegistrationURL()); |
349 } | 349 } |
350 | 350 |
351 container->willBeDetachedFromFrame(); | 351 container->willBeDetachedFromFrame(); |
352 } | 352 } |
353 | 353 |
354 } // namespace | 354 } // namespace |
355 } // namespace blink | 355 } // namespace blink |
OLD | NEW |