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

Side by Side Diff: third_party/WebKit/Source/core/workers/InProcessWorkerObjectProxy.cpp

Issue 1925583003: Replace AllowCrossThreadAccess() + non-GCed pointers with crossThreadUnretained() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Kuroneko_4
Patch Set: Rebase. Created 4 years, 5 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
OLDNEW
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 namespace blink { 43 namespace blink {
44 44
45 std::unique_ptr<InProcessWorkerObjectProxy> InProcessWorkerObjectProxy::create(I nProcessWorkerMessagingProxy* messagingProxy) 45 std::unique_ptr<InProcessWorkerObjectProxy> InProcessWorkerObjectProxy::create(I nProcessWorkerMessagingProxy* messagingProxy)
46 { 46 {
47 DCHECK(messagingProxy); 47 DCHECK(messagingProxy);
48 return wrapUnique(new InProcessWorkerObjectProxy(messagingProxy)); 48 return wrapUnique(new InProcessWorkerObjectProxy(messagingProxy));
49 } 49 }
50 50
51 void InProcessWorkerObjectProxy::postMessageToWorkerObject(PassRefPtr<Serialized ScriptValue> message, std::unique_ptr<MessagePortChannelArray> channels) 51 void InProcessWorkerObjectProxy::postMessageToWorkerObject(PassRefPtr<Serialized ScriptValue> message, std::unique_ptr<MessagePortChannelArray> channels)
52 { 52 {
53 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr ocessWorkerMessagingProxy::postMessageToWorkerObject, AllowCrossThreadAccess(m_m essagingProxy), message, passed(std::move(channels)))); 53 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr ocessWorkerMessagingProxy::postMessageToWorkerObject, crossThreadUnretained(m_me ssagingProxy), message, passed(std::move(channels))));
54 } 54 }
55 55
56 void InProcessWorkerObjectProxy::postTaskToMainExecutionContext(std::unique_ptr< ExecutionContextTask> task) 56 void InProcessWorkerObjectProxy::postTaskToMainExecutionContext(std::unique_ptr< ExecutionContextTask> task)
57 { 57 {
58 getExecutionContext()->postTask(BLINK_FROM_HERE, std::move(task)); 58 getExecutionContext()->postTask(BLINK_FROM_HERE, std::move(task));
59 } 59 }
60 60
61 void InProcessWorkerObjectProxy::confirmMessageFromWorkerObject(bool hasPendingA ctivity) 61 void InProcessWorkerObjectProxy::confirmMessageFromWorkerObject(bool hasPendingA ctivity)
62 { 62 {
63 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr ocessWorkerMessagingProxy::confirmMessageFromWorkerObject, AllowCrossThreadAcces s(m_messagingProxy), hasPendingActivity)); 63 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr ocessWorkerMessagingProxy::confirmMessageFromWorkerObject, crossThreadUnretained (m_messagingProxy), hasPendingActivity));
64 } 64 }
65 65
66 void InProcessWorkerObjectProxy::reportPendingActivity(bool hasPendingActivity) 66 void InProcessWorkerObjectProxy::reportPendingActivity(bool hasPendingActivity)
67 { 67 {
68 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr ocessWorkerMessagingProxy::reportPendingActivity, AllowCrossThreadAccess(m_messa gingProxy), hasPendingActivity)); 68 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr ocessWorkerMessagingProxy::reportPendingActivity, crossThreadUnretained(m_messag ingProxy), hasPendingActivity));
69 } 69 }
70 70
71 void InProcessWorkerObjectProxy::reportException(const String& errorMessage, std ::unique_ptr<SourceLocation> location) 71 void InProcessWorkerObjectProxy::reportException(const String& errorMessage, std ::unique_ptr<SourceLocation> location)
72 { 72 {
73 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr ocessWorkerMessagingProxy::reportException, AllowCrossThreadAccess(m_messagingPr oxy), errorMessage, passed(std::move(location)))); 73 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr ocessWorkerMessagingProxy::reportException, crossThreadUnretained(m_messagingPro xy), errorMessage, passed(std::move(location))));
74 } 74 }
75 75
76 void InProcessWorkerObjectProxy::reportConsoleMessage(ConsoleMessage* consoleMes sage) 76 void InProcessWorkerObjectProxy::reportConsoleMessage(ConsoleMessage* consoleMes sage)
77 { 77 {
78 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr ocessWorkerMessagingProxy::reportConsoleMessage, AllowCrossThreadAccess(m_messag ingProxy), consoleMessage->source(), consoleMessage->level(), consoleMessage->me ssage(), passed(consoleMessage->location()->clone()))); 78 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr ocessWorkerMessagingProxy::reportConsoleMessage, crossThreadUnretained(m_messagi ngProxy), consoleMessage->source(), consoleMessage->level(), consoleMessage->mes sage(), passed(consoleMessage->location()->clone())));
79 } 79 }
80 80
81 void InProcessWorkerObjectProxy::postMessageToPageInspector(const String& messag e) 81 void InProcessWorkerObjectProxy::postMessageToPageInspector(const String& messag e)
82 { 82 {
83 ExecutionContext* context = getExecutionContext(); 83 ExecutionContext* context = getExecutionContext();
84 if (context->isDocument()) 84 if (context->isDocument())
85 toDocument(context)->postInspectorTask(BLINK_FROM_HERE, createCrossThrea dTask(&InProcessWorkerMessagingProxy::postMessageToPageInspector, AllowCrossThre adAccess(m_messagingProxy), message)); 85 toDocument(context)->postInspectorTask(BLINK_FROM_HERE, createCrossThrea dTask(&InProcessWorkerMessagingProxy::postMessageToPageInspector, crossThreadUnr etained(m_messagingProxy), message));
86 } 86 }
87 87
88 void InProcessWorkerObjectProxy::postWorkerConsoleAgentEnabled() 88 void InProcessWorkerObjectProxy::postWorkerConsoleAgentEnabled()
89 { 89 {
90 ExecutionContext* context = getExecutionContext(); 90 ExecutionContext* context = getExecutionContext();
91 if (context->isDocument()) 91 if (context->isDocument())
92 toDocument(context)->postInspectorTask(BLINK_FROM_HERE, createCrossThrea dTask(&InProcessWorkerMessagingProxy::postWorkerConsoleAgentEnabled, AllowCrossT hreadAccess(m_messagingProxy))); 92 toDocument(context)->postInspectorTask(BLINK_FROM_HERE, createCrossThrea dTask(&InProcessWorkerMessagingProxy::postWorkerConsoleAgentEnabled, crossThread Unretained(m_messagingProxy)));
93 } 93 }
94 94
95 void InProcessWorkerObjectProxy::workerGlobalScopeClosed() 95 void InProcessWorkerObjectProxy::workerGlobalScopeClosed()
96 { 96 {
97 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr ocessWorkerMessagingProxy::terminateWorkerGlobalScope, AllowCrossThreadAccess(m_ messagingProxy))); 97 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr ocessWorkerMessagingProxy::terminateWorkerGlobalScope, crossThreadUnretained(m_m essagingProxy)));
98 } 98 }
99 99
100 void InProcessWorkerObjectProxy::workerThreadTerminated() 100 void InProcessWorkerObjectProxy::workerThreadTerminated()
101 { 101 {
102 // This will terminate the MessagingProxy. 102 // This will terminate the MessagingProxy.
103 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr ocessWorkerMessagingProxy::workerThreadTerminated, AllowCrossThreadAccess(m_mess agingProxy))); 103 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr ocessWorkerMessagingProxy::workerThreadTerminated, crossThreadUnretained(m_messa gingProxy)));
104 } 104 }
105 105
106 InProcessWorkerObjectProxy::InProcessWorkerObjectProxy(InProcessWorkerMessagingP roxy* messagingProxy) 106 InProcessWorkerObjectProxy::InProcessWorkerObjectProxy(InProcessWorkerMessagingP roxy* messagingProxy)
107 : m_messagingProxy(messagingProxy) 107 : m_messagingProxy(messagingProxy)
108 { 108 {
109 } 109 }
110 110
111 ExecutionContext* InProcessWorkerObjectProxy::getExecutionContext() 111 ExecutionContext* InProcessWorkerObjectProxy::getExecutionContext()
112 { 112 {
113 DCHECK(m_messagingProxy); 113 DCHECK(m_messagingProxy);
114 return m_messagingProxy->getExecutionContext(); 114 return m_messagingProxy->getExecutionContext();
115 } 115 }
116 116
117 } // namespace blink 117 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698