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

Side by Side Diff: third_party/WebKit/Source/core/loader/ThreadableLoaderClientWrapper.h

Issue 2181243002: Move ThreadableLoader to Oilpan heap (2/3) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@onheap-bridge-peer-in-worker-threadable-loader
Patch Set: fix Created 4 years, 4 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
(Empty)
1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #ifndef ThreadableLoaderClientWrapper_h
32 #define ThreadableLoaderClientWrapper_h
33
34 #include "core/loader/ThreadableLoaderClient.h"
35 #include "core/timing/WorkerGlobalScopePerformance.h"
36 #include "core/workers/WorkerGlobalScope.h"
37 #include "platform/heap/Handle.h"
38 #include "platform/network/ResourceResponse.h"
39 #include "platform/network/ResourceTimingInfo.h"
40 #include "wtf/Threading.h"
41 #include "wtf/Vector.h"
42 #include <memory>
43
44 namespace blink {
45
46 class ThreadableLoaderClientWrapper final : public GarbageCollected<ThreadableLo aderClientWrapper> {
haraken 2016/07/29 14:52:51 This removal is amazing!
47 public:
48 ThreadableLoaderClientWrapper(WorkerGlobalScope& workerGlobalScope, Threadab leLoaderClient* client)
49 : m_workerGlobalScope(workerGlobalScope)
50 , m_client(client)
51 {
52 }
53
54 void clearClient()
55 {
56 m_done = true;
57 m_client = nullptr;
58 }
59
60 bool done() const { return m_done; }
61
62 void didSendData(unsigned long long bytesSent, unsigned long long totalBytes ToBeSent)
63 {
64 if (m_client)
65 m_client->didSendData(bytesSent, totalBytesToBeSent);
66 }
67
68 void didReceiveResponse(unsigned long identifier, std::unique_ptr<CrossThrea dResourceResponseData> responseData, std::unique_ptr<WebDataConsumerHandle> hand le)
69 {
70 ResourceResponse response(responseData.get());
71
72 if (m_client)
73 m_client->didReceiveResponse(identifier, response, std::move(handle) );
74 }
75
76 void didReceiveData(std::unique_ptr<Vector<char>> data)
77 {
78 RELEASE_ASSERT(data->size() <= std::numeric_limits<unsigned>::max());
79
80 if (m_client)
81 m_client->didReceiveData(data->data(), data->size());
82 }
83
84 void didReceiveCachedMetadata(std::unique_ptr<Vector<char>> data)
85 {
86 if (m_client)
87 m_client->didReceiveCachedMetadata(data->data(), data->size());
88 }
89
90 void didFinishLoading(unsigned long identifier, double finishTime)
91 {
92 m_done = true;
93 if (m_client) {
94 ThreadableLoaderClient* client = m_client;
95 m_client = nullptr;
96 client->didFinishLoading(identifier, finishTime);
97 }
98 }
99
100 void didFail(const ResourceError& error)
101 {
102 m_done = true;
103 if (m_client) {
104 ThreadableLoaderClient* client = m_client;
105 m_client = nullptr;
106 client->didFail(error);
107 }
108 }
109
110 void didFailAccessControlCheck(const ResourceError& error)
111 {
112 m_done = true;
113 if (m_client) {
114 ThreadableLoaderClient* client = m_client;
115 m_client = nullptr;
116 client->didFailAccessControlCheck(error);
117 }
118 }
119
120 void didFailRedirectCheck()
121 {
122 m_done = true;
123 if (m_client) {
124 ThreadableLoaderClient* client = m_client;
125 m_client = nullptr;
126 client->didFailRedirectCheck();
127 }
128 }
129
130 void didDownloadData(int dataLength)
131 {
132 if (m_client)
133 m_client->didDownloadData(dataLength);
134 }
135
136 void didReceiveResourceTiming(std::unique_ptr<CrossThreadResourceTimingInfoD ata> timingData)
137 {
138 std::unique_ptr<ResourceTimingInfo> info(ResourceTimingInfo::adopt(std:: move(timingData)));
139 if (m_client) {
140 WorkerGlobalScopePerformance::performance(*m_workerGlobalScope)->add ResourceTiming(*info);
141 m_client->didReceiveResourceTiming(*info);
142 }
143 }
144
145 DEFINE_INLINE_TRACE()
146 {
147 visitor->trace(m_workerGlobalScope);
148 }
149
150 private:
151 Member<WorkerGlobalScope> m_workerGlobalScope;
152 ThreadableLoaderClient* m_client = nullptr;
153 bool m_done = false;
154 };
155
156 } // namespace blink
157
158 #endif // ThreadableLoaderClientWrapper_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698