OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 17 matching lines...) Expand all Loading... |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef ThreadableLoaderClientWrapper_h | 31 #ifndef ThreadableLoaderClientWrapper_h |
32 #define ThreadableLoaderClientWrapper_h | 32 #define ThreadableLoaderClientWrapper_h |
33 | 33 |
34 #include "core/loader/ThreadableLoaderClient.h" | 34 #include "core/loader/ThreadableLoaderClient.h" |
35 #include "platform/network/ResourceResponse.h" | 35 #include "platform/network/ResourceResponse.h" |
36 #include "platform/network/ResourceTimingInfo.h" | 36 #include "platform/network/ResourceTimingInfo.h" |
37 #include "wtf/Noncopyable.h" | 37 #include "wtf/Noncopyable.h" |
| 38 #include "wtf/PassOwnPtr.h" |
38 #include "wtf/PassRefPtr.h" | 39 #include "wtf/PassRefPtr.h" |
39 #include "wtf/ThreadSafeRefCounted.h" | 40 #include "wtf/ThreadSafeRefCounted.h" |
40 #include "wtf/Threading.h" | 41 #include "wtf/Threading.h" |
41 #include "wtf/Vector.h" | 42 #include "wtf/Vector.h" |
42 #include <memory> | |
43 | 43 |
44 namespace blink { | 44 namespace blink { |
45 | 45 |
46 class ThreadableLoaderClientWrapper : public ThreadSafeRefCounted<ThreadableLoad
erClientWrapper> { | 46 class ThreadableLoaderClientWrapper : public ThreadSafeRefCounted<ThreadableLoad
erClientWrapper> { |
47 public: | 47 public: |
48 class ResourceTimingClient { | 48 class ResourceTimingClient { |
49 public: | 49 public: |
50 virtual void didReceiveResourceTiming(const ResourceTimingInfo&) = 0; | 50 virtual void didReceiveResourceTiming(const ResourceTimingInfo&) = 0; |
51 }; | 51 }; |
52 | 52 |
(...skipping 23 matching lines...) Expand all Loading... |
76 { | 76 { |
77 m_resourceTimingClient = nullptr; | 77 m_resourceTimingClient = nullptr; |
78 } | 78 } |
79 | 79 |
80 void didSendData(unsigned long long bytesSent, unsigned long long totalBytes
ToBeSent) | 80 void didSendData(unsigned long long bytesSent, unsigned long long totalBytes
ToBeSent) |
81 { | 81 { |
82 if (m_client) | 82 if (m_client) |
83 m_client->didSendData(bytesSent, totalBytesToBeSent); | 83 m_client->didSendData(bytesSent, totalBytesToBeSent); |
84 } | 84 } |
85 | 85 |
86 void didReceiveResponse(unsigned long identifier, std::unique_ptr<CrossThrea
dResourceResponseData> responseData, std::unique_ptr<WebDataConsumerHandle> hand
le) | 86 void didReceiveResponse(unsigned long identifier, PassOwnPtr<CrossThreadReso
urceResponseData> responseData, PassOwnPtr<WebDataConsumerHandle> handle) |
87 { | 87 { |
88 ResourceResponse response(responseData.get()); | 88 ResourceResponse response(responseData.get()); |
89 | 89 |
90 if (m_client) | 90 if (m_client) |
91 m_client->didReceiveResponse(identifier, response, std::move(handle)
); | 91 m_client->didReceiveResponse(identifier, response, std::move(handle)
); |
92 } | 92 } |
93 | 93 |
94 void didReceiveData(std::unique_ptr<Vector<char>> data) | 94 void didReceiveData(PassOwnPtr<Vector<char>> data) |
95 { | 95 { |
96 RELEASE_ASSERT(data->size() <= std::numeric_limits<unsigned>::max()); | 96 RELEASE_ASSERT(data->size() <= std::numeric_limits<unsigned>::max()); |
97 | 97 |
98 if (m_client) | 98 if (m_client) |
99 m_client->didReceiveData(data->data(), data->size()); | 99 m_client->didReceiveData(data->data(), data->size()); |
100 } | 100 } |
101 | 101 |
102 void didReceiveCachedMetadata(std::unique_ptr<Vector<char>> data) | 102 void didReceiveCachedMetadata(PassOwnPtr<Vector<char>> data) |
103 { | 103 { |
104 if (m_client) | 104 if (m_client) |
105 m_client->didReceiveCachedMetadata(data->data(), data->size()); | 105 m_client->didReceiveCachedMetadata(data->data(), data->size()); |
106 } | 106 } |
107 | 107 |
108 void didFinishLoading(unsigned long identifier, double finishTime) | 108 void didFinishLoading(unsigned long identifier, double finishTime) |
109 { | 109 { |
110 m_done = true; | 110 m_done = true; |
111 if (m_client) | 111 if (m_client) |
112 m_client->didFinishLoading(identifier, finishTime); | 112 m_client->didFinishLoading(identifier, finishTime); |
(...skipping 19 matching lines...) Expand all Loading... |
132 if (m_client) | 132 if (m_client) |
133 m_client->didFailRedirectCheck(); | 133 m_client->didFailRedirectCheck(); |
134 } | 134 } |
135 | 135 |
136 void didDownloadData(int dataLength) | 136 void didDownloadData(int dataLength) |
137 { | 137 { |
138 if (m_client) | 138 if (m_client) |
139 m_client->didDownloadData(dataLength); | 139 m_client->didDownloadData(dataLength); |
140 } | 140 } |
141 | 141 |
142 void didReceiveResourceTiming(std::unique_ptr<CrossThreadResourceTimingInfoD
ata> timingData) | 142 void didReceiveResourceTiming(PassOwnPtr<CrossThreadResourceTimingInfoData>
timingData) |
143 { | 143 { |
144 std::unique_ptr<ResourceTimingInfo> info(ResourceTimingInfo::adopt(std::
move(timingData))); | 144 OwnPtr<ResourceTimingInfo> info(ResourceTimingInfo::adopt(std::move(timi
ngData))); |
145 | 145 |
146 if (m_resourceTimingClient) | 146 if (m_resourceTimingClient) |
147 m_resourceTimingClient->didReceiveResourceTiming(*info); | 147 m_resourceTimingClient->didReceiveResourceTiming(*info); |
148 } | 148 } |
149 | 149 |
150 protected: | 150 protected: |
151 explicit ThreadableLoaderClientWrapper(ThreadableLoaderClient* client) | 151 explicit ThreadableLoaderClientWrapper(ThreadableLoaderClient* client) |
152 : m_client(client) | 152 : m_client(client) |
153 , m_resourceTimingClient(nullptr) | 153 , m_resourceTimingClient(nullptr) |
154 , m_done(false) | 154 , m_done(false) |
155 { | 155 { |
156 } | 156 } |
157 | 157 |
158 ThreadableLoaderClient* m_client; | 158 ThreadableLoaderClient* m_client; |
159 ResourceTimingClient* m_resourceTimingClient; | 159 ResourceTimingClient* m_resourceTimingClient; |
160 bool m_done; | 160 bool m_done; |
161 }; | 161 }; |
162 | 162 |
163 } // namespace blink | 163 } // namespace blink |
164 | 164 |
165 #endif // ThreadableLoaderClientWrapper_h | 165 #endif // ThreadableLoaderClientWrapper_h |
OLD | NEW |