/src/3rdparty/webkit/Source/WebCore/platform/network/SocketStreamHandleBase.h

https://bitbucket.org/ultra_iter/qt-vtl · C Header · 72 lines · 29 code · 13 blank · 30 comment · 0 complexity · 9b2f337a99eb3b6b2a911d3058b97c2e MD5 · raw file

  1. /*
  2. * Copyright (C) 2009 Apple Inc. All rights reserved.
  3. * Copyright (C) 2009 Google Inc. All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are
  7. * met:
  8. *
  9. * * Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * * Redistributions in binary form must reproduce the above
  12. * copyright notice, this list of conditions and the following disclaimer
  13. * in the documentation and/or other materials provided with the
  14. * distribution.
  15. * * Neither the name of Google Inc. nor the names of its
  16. * contributors may be used to endorse or promote products derived from
  17. * this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  22. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  23. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  24. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  25. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  26. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  27. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. */
  31. #ifndef SocketStreamHandleBase_h
  32. #define SocketStreamHandleBase_h
  33. #include "KURL.h"
  34. #include <wtf/Vector.h>
  35. namespace WebCore {
  36. class SocketStreamHandle;
  37. class SocketStreamHandleClient;
  38. class SocketStreamHandleBase {
  39. public:
  40. enum SocketStreamState { Connecting, Open, Closed };
  41. virtual ~SocketStreamHandleBase() { }
  42. SocketStreamState state() const;
  43. bool send(const char* data, int length);
  44. void close();
  45. int bufferedAmount() const { return m_buffer.size(); }
  46. SocketStreamHandleClient* client() const { return m_client; }
  47. void setClient(SocketStreamHandleClient*);
  48. protected:
  49. SocketStreamHandleBase(const KURL&, SocketStreamHandleClient*);
  50. bool sendPendingData();
  51. virtual int platformSend(const char* data, int length) = 0;
  52. virtual void platformClose() = 0;
  53. KURL m_url;
  54. SocketStreamHandleClient* m_client;
  55. Vector<char> m_buffer;
  56. SocketStreamState m_state;
  57. };
  58. } // namespace WebCore
  59. #endif // SocketStreamHandleBase_h