| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 | 82 |
| 83 void load(ExecutionContext* loadingContext, const KURL& scriptURL, const Clo
sure& callback) | 83 void load(ExecutionContext* loadingContext, const KURL& scriptURL, const Clo
sure& callback) |
| 84 { | 84 { |
| 85 ASSERT(loadingContext); | 85 ASSERT(loadingContext); |
| 86 m_callback = callback; | 86 m_callback = callback; |
| 87 m_scriptLoader->setRequestContext(WebURLRequest::RequestContextServiceWo
rker); | 87 m_scriptLoader->setRequestContext(WebURLRequest::RequestContextServiceWo
rker); |
| 88 m_scriptLoader->loadAsynchronously( | 88 m_scriptLoader->loadAsynchronously( |
| 89 *loadingContext, scriptURL, DenyCrossOriginRequests, this); | 89 *loadingContext, scriptURL, DenyCrossOriginRequests, this); |
| 90 } | 90 } |
| 91 | 91 |
| 92 virtual void notifyFinished() OVERRIDE | 92 virtual void notifyFinished() override |
| 93 { | 93 { |
| 94 m_callback(); | 94 m_callback(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void cancel() | 97 void cancel() |
| 98 { | 98 { |
| 99 m_scriptLoader->cancel(); | 99 m_scriptLoader->cancel(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 bool failed() const { return m_scriptLoader->failed(); } | 102 bool failed() const { return m_scriptLoader->failed(); } |
| 103 const KURL& url() const { return m_scriptLoader->responseURL(); } | 103 const KURL& url() const { return m_scriptLoader->responseURL(); } |
| 104 String script() const { return m_scriptLoader->script(); } | 104 String script() const { return m_scriptLoader->script(); } |
| 105 | 105 |
| 106 private: | 106 private: |
| 107 Loader() : m_scriptLoader(WorkerScriptLoader::create()) | 107 Loader() : m_scriptLoader(WorkerScriptLoader::create()) |
| 108 { | 108 { |
| 109 } | 109 } |
| 110 | 110 |
| 111 RefPtr<WorkerScriptLoader> m_scriptLoader; | 111 RefPtr<WorkerScriptLoader> m_scriptLoader; |
| 112 Closure m_callback; | 112 Closure m_callback; |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 class WebEmbeddedWorkerImpl::LoaderProxy : public WorkerLoaderProxy { | 115 class WebEmbeddedWorkerImpl::LoaderProxy : public WorkerLoaderProxy { |
| 116 public: | 116 public: |
| 117 static PassOwnPtr<LoaderProxy> create(WebEmbeddedWorkerImpl& embeddedWorker) | 117 static PassOwnPtr<LoaderProxy> create(WebEmbeddedWorkerImpl& embeddedWorker) |
| 118 { | 118 { |
| 119 return adoptPtr(new LoaderProxy(embeddedWorker)); | 119 return adoptPtr(new LoaderProxy(embeddedWorker)); |
| 120 } | 120 } |
| 121 | 121 |
| 122 virtual void postTaskToLoader(PassOwnPtr<ExecutionContextTask> task) OVERRID
E | 122 virtual void postTaskToLoader(PassOwnPtr<ExecutionContextTask> task) overrid
e |
| 123 { | 123 { |
| 124 toWebLocalFrameImpl(m_embeddedWorker.m_mainFrame)->frame()->document()->
postTask(task); | 124 toWebLocalFrameImpl(m_embeddedWorker.m_mainFrame)->frame()->document()->
postTask(task); |
| 125 } | 125 } |
| 126 | 126 |
| 127 virtual bool postTaskToWorkerGlobalScope(PassOwnPtr<ExecutionContextTask> ta
sk) OVERRIDE | 127 virtual bool postTaskToWorkerGlobalScope(PassOwnPtr<ExecutionContextTask> ta
sk) override |
| 128 { | 128 { |
| 129 if (m_embeddedWorker.m_askedToTerminate || !m_embeddedWorker.m_workerThr
ead) | 129 if (m_embeddedWorker.m_askedToTerminate || !m_embeddedWorker.m_workerThr
ead) |
| 130 return false; | 130 return false; |
| 131 m_embeddedWorker.m_workerThread->postTask(task); | 131 m_embeddedWorker.m_workerThread->postTask(task); |
| 132 return !m_embeddedWorker.m_workerThread->terminated(); | 132 return !m_embeddedWorker.m_workerThread->terminated(); |
| 133 } | 133 } |
| 134 | 134 |
| 135 private: | 135 private: |
| 136 explicit LoaderProxy(WebEmbeddedWorkerImpl& embeddedWorker) | 136 explicit LoaderProxy(WebEmbeddedWorkerImpl& embeddedWorker) |
| 137 : m_embeddedWorker(embeddedWorker) | 137 : m_embeddedWorker(embeddedWorker) |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 m_mainScriptLoader.clear(); | 425 m_mainScriptLoader.clear(); |
| 426 | 426 |
| 427 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *doc
ument, *m_workerContextClient); | 427 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *doc
ument, *m_workerContextClient); |
| 428 m_loaderProxy = LoaderProxy::create(*this); | 428 m_loaderProxy = LoaderProxy::create(*this); |
| 429 m_workerThread = ServiceWorkerThread::create(*m_loaderProxy, *m_workerGlobal
ScopeProxy, startupData.release()); | 429 m_workerThread = ServiceWorkerThread::create(*m_loaderProxy, *m_workerGlobal
ScopeProxy, startupData.release()); |
| 430 m_workerThread->start(); | 430 m_workerThread->start(); |
| 431 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(),
scriptURL); | 431 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(),
scriptURL); |
| 432 } | 432 } |
| 433 | 433 |
| 434 } // namespace blink | 434 } // namespace blink |
| OLD | NEW |