OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 static PassOwnPtr<Loader> create() | 72 static PassOwnPtr<Loader> create() |
73 { | 73 { |
74 return adoptPtr(new Loader()); | 74 return adoptPtr(new Loader()); |
75 } | 75 } |
76 | 76 |
77 virtual ~Loader() | 77 virtual ~Loader() |
78 { | 78 { |
79 m_scriptLoader->setClient(0); | 79 m_scriptLoader->setClient(0); |
80 } | 80 } |
81 | 81 |
82 void load(ExecutionContext* loadingContext, const KURL& scriptURL, const Clo
sure& callback) | 82 void load(ExecutionContext* loadingContext, const KURL& scriptURL, PassOwnPt
r<Closure> callback) |
83 { | 83 { |
84 ASSERT(loadingContext); | 84 ASSERT(loadingContext); |
85 m_callback = callback; | 85 m_callback = callback; |
86 m_scriptLoader->setRequestContext(WebURLRequest::RequestContextServiceWo
rker); | 86 m_scriptLoader->setRequestContext(WebURLRequest::RequestContextServiceWo
rker); |
87 m_scriptLoader->loadAsynchronously( | 87 m_scriptLoader->loadAsynchronously( |
88 *loadingContext, scriptURL, DenyCrossOriginRequests, this); | 88 *loadingContext, scriptURL, DenyCrossOriginRequests, this); |
89 } | 89 } |
90 | 90 |
91 virtual void notifyFinished() override | 91 virtual void notifyFinished() override |
92 { | 92 { |
93 m_callback(); | 93 (*m_callback)(); |
94 } | 94 } |
95 | 95 |
96 void cancel() | 96 void cancel() |
97 { | 97 { |
98 m_scriptLoader->cancel(); | 98 m_scriptLoader->cancel(); |
99 } | 99 } |
100 | 100 |
101 bool failed() const { return m_scriptLoader->failed(); } | 101 bool failed() const { return m_scriptLoader->failed(); } |
102 const KURL& url() const { return m_scriptLoader->responseURL(); } | 102 const KURL& url() const { return m_scriptLoader->responseURL(); } |
103 String script() const { return m_scriptLoader->script(); } | 103 String script() const { return m_scriptLoader->script(); } |
104 | 104 |
105 private: | 105 private: |
106 Loader() : m_scriptLoader(WorkerScriptLoader::create()) | 106 Loader() : m_scriptLoader(WorkerScriptLoader::create()) |
107 { | 107 { |
108 } | 108 } |
109 | 109 |
110 RefPtr<WorkerScriptLoader> m_scriptLoader; | 110 RefPtr<WorkerScriptLoader> m_scriptLoader; |
111 Closure m_callback; | 111 OwnPtr<Closure> m_callback; |
112 }; | 112 }; |
113 | 113 |
114 class WebEmbeddedWorkerImpl::LoaderProxy : public WorkerLoaderProxy { | 114 class WebEmbeddedWorkerImpl::LoaderProxy : public WorkerLoaderProxy { |
115 public: | 115 public: |
116 static PassOwnPtr<LoaderProxy> create(WebEmbeddedWorkerImpl& embeddedWorker) | 116 static PassOwnPtr<LoaderProxy> create(WebEmbeddedWorkerImpl& embeddedWorker) |
117 { | 117 { |
118 return adoptPtr(new LoaderProxy(embeddedWorker)); | 118 return adoptPtr(new LoaderProxy(embeddedWorker)); |
119 } | 119 } |
120 | 120 |
121 virtual void postTaskToLoader(PassOwnPtr<ExecutionContextTask> task) overrid
e | 121 virtual void postTaskToLoader(PassOwnPtr<ExecutionContextTask> task) overrid
e |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 m_mainScriptLoader.clear(); | 423 m_mainScriptLoader.clear(); |
424 | 424 |
425 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *doc
ument, *m_workerContextClient); | 425 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *doc
ument, *m_workerContextClient); |
426 m_loaderProxy = LoaderProxy::create(*this); | 426 m_loaderProxy = LoaderProxy::create(*this); |
427 m_workerThread = ServiceWorkerThread::create(*m_loaderProxy, *m_workerGlobal
ScopeProxy, startupData.release()); | 427 m_workerThread = ServiceWorkerThread::create(*m_loaderProxy, *m_workerGlobal
ScopeProxy, startupData.release()); |
428 m_workerThread->start(); | 428 m_workerThread->start(); |
429 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(),
scriptURL); | 429 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(),
scriptURL); |
430 } | 430 } |
431 | 431 |
432 } // namespace blink | 432 } // namespace blink |
OLD | NEW |