SHARE
TWEET

patch_staged

akshay1994 Mar 18th, 2014 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff --git a/Source/WebCore/platform/network/haiku/SocketStreamHandleHaiku.cpp b/Source/WebCore/platform/network/haiku/SocketStreamHandleHaiku.cpp
  2. new file mode 100644
  3. index 0000000..8d0d42b
  4. --- /dev/null
  5. +++ b/Source/WebCore/platform/network/haiku/SocketStreamHandleHaiku.cpp
  6. @@ -0,0 +1,181 @@
  7. +/*
  8. + * Copyright (C) 2009 Brent Fulgham.  All rights reserved.
  9. + * Copyright (C) 2009 Google Inc.  All rights reserved.
  10. + *
  11. + * Redistribution and use in source and binary forms, with or without
  12. + * modification, are permitted provided that the following conditions are
  13. + * met:
  14. + *
  15. + *     * Redistributions of source code must retain the above copyright
  16. + * notice, this list of conditions and the following disclaimer.
  17. + *     * Redistributions in binary form must reproduce the above
  18. + * copyright notice, this list of conditions and the following disclaimer
  19. + * in the documentation and/or other materials provided with the
  20. + * distribution.
  21. + *     * Neither the name of Google Inc. nor the names of its
  22. + * contributors may be used to endorse or promote products derived from
  23. + * this software without specific prior written permission.
  24. + *
  25. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  26. + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  27. + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  28. + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  29. + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  30. + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  31. + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  32. + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  33. + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  34. + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  35. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  36. + */
  37. +
  38. +#include "config.h"
  39. +#include "SocketStreamHandle.h"
  40. +#include "SocketStreamError.h"
  41. +
  42. +#include "URL.h"
  43. +#include "Logging.h"
  44. +#include "NotImplemented.h"
  45. +#include "SocketStreamHandleClient.h"
  46. +
  47. +#include <wtf/text/CString.h>
  48. +#include <kernel/OS.h>
  49. +#include<iostream>
  50. +
  51. +namespace WebCore {
  52. +
  53. +int SocketStreamHandle::async_read_push(const char * data,int length)
  54. +{
  55. +       RefPtr<SocketStreamHandle> protect(this);
  56. +       (m_client)->didReceiveSocketStreamData(this,data,length);
  57. +       std::cout<<"\nDATA PUSHED"<<data<<std::endl;
  58. +       return 0;
  59. +}
  60. +long int async_read(void * ptrr)
  61. +{
  62. +       SocketStreamHandle * strm=(SocketStreamHandle *)ptrr;
  63. +       char *array=new char[5025];
  64. +       while(1)
  65. +       {
  66. +               std::cout<<"Entering-Loop with sock:"<<strm->sock<<std::endl;
  67. +       int rd_bytes=(strm->sock)->Read(array,5024);
  68. +       array[rd_bytes]='\0';
  69. +       std::cout<<"Bytes:"<<rd_bytes<<"Read:"<<array<<std::endl;      
  70. +       strm->async_read_push(array,rd_bytes);         
  71. +       }
  72. +       return 0;      
  73. +}
  74. +
  75. +int SocketStreamHandle::async_sendPendingData()
  76. +{
  77. +       sendPendingData();
  78. +       return 0;
  79. +}
  80. +
  81. +long int async_write(void * ptrr)
  82. +{
  83. +       SocketStreamHandle * strm=(SocketStreamHandle *)ptrr;
  84. +       status_t resp=(strm->sock)->WaitForWritable(B_INFINITE_TIMEOUT);
  85. +       std::cout<<resp<<" "<<B_OK<<" "<<B_WOULD_BLOCK<<" "<<B_TIMED_OUT<<std::endl;;
  86. +       if(resp==B_OK)
  87. +               strm->async_sendPendingData();
  88. +       else
  89. +               return resp;
  90. +       return 0;
  91. +}
  92. +
  93. +SocketStreamHandle::SocketStreamHandle(const URL& url, SocketStreamHandleClient* client)
  94. +    : SocketStreamHandleBase(url, client)
  95. +{
  96. +    LOG(Network, "SocketStreamHandle %p new client %p", this, m_client);
  97. +       rd_thread=wr_thread=0;
  98. +    unsigned int port = url.hasPort() ? url.port() : (url.protocolIs("wss") ? 443:80);
  99. +    
  100. +    peer = new BNetworkAddress(url.host().utf8().data(),port);
  101. +    sock= new BSocket((*peer));
  102. +    if(sock->IsConnected()==false)
  103. +    {
  104. +       status_t err=sock->Connect((*peer));
  105. +       if(err!=B_OK)
  106. +       {
  107. +               (m_client)->didFailSocketStream(this,SocketStreamError(err));
  108. +               return;
  109. +       }
  110. +    }
  111. +    rd_thread=spawn_thread(async_read,"async_read",63,(void*)this);
  112. +    resume_thread(rd_thread);
  113. +    std::cout<<"New request:"<<url.host().utf8().data()<<":"<<port<<std::endl<<"Sock:"<<sock<<"Read-thread-id:"<<rd_thread<<std::endl;
  114. +    m_state=Open;
  115. +    m_client->didOpenSocketStream(this);
  116. +    
  117. +    //char *array=new char[1025];
  118. +    //int rd_bytes=sock->Read(array,1024);
  119. +    //m_client->didReceiveSocketStreamData(this,array,rd_bytes);
  120. +}
  121. +
  122. +SocketStreamHandle::~SocketStreamHandle()
  123. +{
  124. +    LOG(Network, "SocketStreamHandle %p delete", this);
  125. +    delete peer;
  126. +    delete sock;
  127. +    setClient(0);
  128. +}
  129. +
  130. +
  131. +
  132. +int SocketStreamHandle::platformSend(const char* buffer, int length)
  133. +{
  134. +       int written=0,flag=0;
  135. +       std::cout<<"To-Write:"<<buffer<<std::endl;
  136. +    LOG(Network, "SocketStreamHandle %p platformSend", this);
  137. +    if(sock->WaitForWritable(0)==B_OK)
  138. +    {
  139. +       written=sock->Write(buffer,length);
  140. +       if(written<length)
  141. +               flag=1;
  142. +       std::cout<<"WRITTEN:"<<written<<std::endl;
  143. +    }
  144. +    else
  145. +    {
  146. +       flag=1;
  147. +    }
  148. +    if(flag==1)
  149. +    {
  150. +       std::cout<<"VOILA"<<std::endl;
  151. +       wr_thread=spawn_thread(async_write,"async_write",63,(void*)this);
  152. +       resume_thread(wr_thread);
  153. +    }
  154. +    return written;
  155. +}
  156. +
  157. +void SocketStreamHandle::platformClose()
  158. +{
  159. +    LOG(Network, "SocketStreamHandle %p platformClose", this);
  160. +    kill_thread(rd_thread);
  161. +    if(wr_thread!=0)
  162. +       kill_thread(wr_thread);
  163. +    sock->Disconnect();
  164. +       m_client->didCloseSocketStream(this);
  165. +}
  166. +
  167. +void SocketStreamHandle::didReceiveAuthenticationChallenge(const AuthenticationChallenge&)
  168. +{
  169. +    notImplemented();
  170. +}
  171. +
  172. +void SocketStreamHandle::receivedCredential(const AuthenticationChallenge&, const Credential&)
  173. +{
  174. +    notImplemented();
  175. +}
  176. +
  177. +void SocketStreamHandle::receivedRequestToContinueWithoutCredential(const AuthenticationChallenge&)
  178. +{
  179. +    notImplemented();
  180. +}
  181. +
  182. +void SocketStreamHandle::receivedCancellation(const AuthenticationChallenge&)
  183. +{
  184. +    notImplemented();
  185. +}
  186. +
  187. +}  // namespace WebCore
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top