2 * Copyright (C) 2009 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
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
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.
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.
31 #ifndef ThreadableLoaderClientWrapper_h
32 #define ThreadableLoaderClientWrapper_h
34 #include "core/loader/ThreadableLoaderClient.h"
35 #include "wtf/Noncopyable.h"
36 #include "wtf/PassRefPtr.h"
37 #include "wtf/ThreadSafeRefCounted.h"
38 #include "wtf/Threading.h"
42 class ThreadableLoaderClientWrapper : public ThreadSafeRefCounted<ThreadableLoaderClientWrapper> {
44 static PassRefPtr<ThreadableLoaderClientWrapper> create(ThreadableLoaderClient* client)
46 return adoptRef(new ThreadableLoaderClientWrapper(client));
60 void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent)
63 m_client->didSendData(bytesSent, totalBytesToBeSent);
66 void didReceiveResponse(unsigned long identifier, const ResourceResponse& response)
69 m_client->didReceiveResponse(identifier, response);
72 void didReceiveData(const char* data, int dataLength)
75 m_client->didReceiveData(data, dataLength);
78 void didReceiveCachedMetadata(const char* data, int dataLength)
81 m_client->didReceiveCachedMetadata(data, dataLength);
84 void didFinishLoading(unsigned long identifier, double finishTime)
88 m_client->didFinishLoading(identifier, finishTime);
91 void didFail(const ResourceError& error)
95 m_client->didFail(error);
98 void didFailAccessControlCheck(const ResourceError& error)
100 // Let the client first handle the failure by possibly issuing
101 // a didFail() with a cancellation error before marking this
102 // wrapper as 'done'.
104 m_client->didFailAccessControlCheck(error);
108 void didFailRedirectCheck()
111 m_client->didFailRedirectCheck();
115 void didReceiveAuthenticationCancellation(unsigned long identifier, const ResourceResponse& response)
118 m_client->didReceiveResponse(identifier, response);
121 void didDownloadData(int dataLength)
124 m_client->didDownloadData(dataLength);
128 explicit ThreadableLoaderClientWrapper(ThreadableLoaderClient* client)
134 ThreadableLoaderClient* m_client;
140 #endif // ThreadableLoaderClientWrapper_h