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

Side by Side Diff: Source/WebKit/chromium/src/WorkerAllowMainThreadBridgeBase.cpp

Issue 17648006: Rename WorkerContext to WorkerGlobalScope (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 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) 2010, 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2010, 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 19 matching lines...) Expand all
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "WorkerAllowMainThreadBridgeBase.h" 32 #include "WorkerAllowMainThreadBridgeBase.h"
33 33
34 #include "wtf/MainThread.h" 34 #include "wtf/MainThread.h"
35 35
36 namespace { 36 namespace {
37 37
38 // Observes the worker context and notifies the bridge. This is kept 38 // Observes the worker context and notifies the bridge. This is kept
39 // separate from the bridge so that it's destroyed correctly by ~Observer. 39 // separate from the bridge so that it's destroyed correctly by ~Observer.
40 class WorkerContextObserver : public WebCore::WorkerContext::Observer { 40 class WorkerGlobalScopeObserver : public WebCore::WorkerGlobalScope::Observer {
41 public: 41 public:
42 static PassOwnPtr<WorkerContextObserver> create(WebCore::WorkerContext* cont ext, PassRefPtr<WebKit::WorkerAllowMainThreadBridgeBase> bridge) 42 static PassOwnPtr<WorkerGlobalScopeObserver> create(WebCore::WorkerGlobalSco pe* context, PassRefPtr<WebKit::WorkerAllowMainThreadBridgeBase> bridge)
43 { 43 {
44 return adoptPtr(new WorkerContextObserver(context, bridge)); 44 return adoptPtr(new WorkerGlobalScopeObserver(context, bridge));
45 } 45 }
46 46
47 // WorkerContext::Observer method. 47 // WorkerGlobalScope::Observer method.
48 virtual void notifyStop() 48 virtual void notifyStop()
49 { 49 {
50 if (!m_bridge) 50 if (!m_bridge)
51 return; 51 return;
52 m_bridge->cancel(); 52 m_bridge->cancel();
53 } 53 }
54 54
55 private: 55 private:
56 WorkerContextObserver(WebCore::WorkerContext* context, PassRefPtr<WebKit::Wo rkerAllowMainThreadBridgeBase> bridge) 56 WorkerGlobalScopeObserver(WebCore::WorkerGlobalScope* context, PassRefPtr<We bKit::WorkerAllowMainThreadBridgeBase> bridge)
57 : WebCore::WorkerContext::Observer(context) 57 : WebCore::WorkerGlobalScope::Observer(context)
58 , m_bridge(bridge) 58 , m_bridge(bridge)
59 { 59 {
60 } 60 }
61 61
62 RefPtr<WebKit::WorkerAllowMainThreadBridgeBase> m_bridge; 62 RefPtr<WebKit::WorkerAllowMainThreadBridgeBase> m_bridge;
63 }; 63 };
64 64
65 } 65 }
66 66
67 namespace WebKit { 67 namespace WebKit {
68 68
69 WorkerAllowMainThreadBridgeBase::WorkerAllowMainThreadBridgeBase(WebCore::Worker Context* workerContext, WebWorkerBase* webWorkerBase) 69 WorkerAllowMainThreadBridgeBase::WorkerAllowMainThreadBridgeBase(WebCore::Worker GlobalScope* workerGlobalScope, WebWorkerBase* webWorkerBase)
70 : m_webWorkerBase(webWorkerBase) 70 : m_webWorkerBase(webWorkerBase)
71 , m_workerContextObserver(WorkerContextObserver::create(workerContext, this) .leakPtr()) 71 , m_workerGlobalScopeObserver(WorkerGlobalScopeObserver::create(workerGlobal Scope, this).leakPtr())
72 { 72 {
73 } 73 }
74 74
75 void WorkerAllowMainThreadBridgeBase::postTaskToMainThread(PassOwnPtr<AllowParam s> params) 75 void WorkerAllowMainThreadBridgeBase::postTaskToMainThread(PassOwnPtr<AllowParam s> params)
76 { 76 {
77 WebWorkerBase::dispatchTaskToMainThread( 77 WebWorkerBase::dispatchTaskToMainThread(
78 createCallbackTask(&WorkerAllowMainThreadBridgeBase::allowTask, params, this)); 78 createCallbackTask(&WorkerAllowMainThreadBridgeBase::allowTask, params, this));
79 } 79 }
80 80
81 // static 81 // static
82 void WorkerAllowMainThreadBridgeBase::allowTask(WebCore::ScriptExecutionContext* , PassOwnPtr<AllowParams> params, PassRefPtr<WorkerAllowMainThreadBridgeBase> br idge) 82 void WorkerAllowMainThreadBridgeBase::allowTask(WebCore::ScriptExecutionContext* , PassOwnPtr<AllowParams> params, PassRefPtr<WorkerAllowMainThreadBridgeBase> br idge)
83 { 83 {
84 ASSERT(isMainThread()); 84 ASSERT(isMainThread());
85 if (!bridge) 85 if (!bridge)
86 return; 86 return;
87 MutexLocker locker(bridge->m_mutex); 87 MutexLocker locker(bridge->m_mutex);
88 if (!bridge->m_webWorkerBase) 88 if (!bridge->m_webWorkerBase)
89 return; 89 return;
90 WebCommonWorkerClient* commonClient = bridge->m_webWorkerBase->commonClient( ); 90 WebCommonWorkerClient* commonClient = bridge->m_webWorkerBase->commonClient( );
91 if (!commonClient) 91 if (!commonClient)
92 return; 92 return;
93 bool allow = bridge->allowOnMainThread(commonClient, params.get()); 93 bool allow = bridge->allowOnMainThread(commonClient, params.get());
94 bridge->m_webWorkerBase->workerLoaderProxy()->postTaskForModeToWorkerContext ( 94 bridge->m_webWorkerBase->workerLoaderProxy()->postTaskForModeToWorkerGlobalS cope(
95 createCallbackTask(&didComplete, bridge, allow), params->m_mode.isolated Copy()); 95 createCallbackTask(&didComplete, bridge, allow), params->m_mode.isolated Copy());
96 } 96 }
97 97
98 // static 98 // static
99 void WorkerAllowMainThreadBridgeBase::didComplete(WebCore::ScriptExecutionContex t* context, PassRefPtr<WorkerAllowMainThreadBridgeBase> bridge, bool result) 99 void WorkerAllowMainThreadBridgeBase::didComplete(WebCore::ScriptExecutionContex t* context, PassRefPtr<WorkerAllowMainThreadBridgeBase> bridge, bool result)
100 { 100 {
101 bridge->m_result = result; 101 bridge->m_result = result;
102 } 102 }
103 103
104 } // namespace WebKit 104 } // namespace WebKit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698