Files
platform-external-webrtc/webrtc/rtc_base/transformadapter.h
Henrik Kjellander 6776518bea Move webrtc/{base => rtc_base}
This refactoring takes a careful approach to avoid rushing the change:
* stub headers are left in all the old locations of webrtc/base
* existing GN targets are kept and now just forward to the moved ones
  using public_deps.
The only exception to the above is the base_java target and its .java files,
which were moved to webrtc/rtc_base right away since it's not possible
to use public_deps for android_library.
To avoid breaking builds, a temporary Dummy.java file was added to
the new intermediate target in webrtc/rtc_base:base_java as well to avoid
hitting a GN assert in the android_library template.

The above approach should make the transition smooth without breaking
downstream.

A helper script was created (https://codereview.webrtc.org/2879203002/)
and was run like this:
stub-headers.py -s webrtc/base -d webrtc/rtc_base -i 7634
stub-headers.py -s webrtc/base/numerics -d webrtc/rtc_base/numerics -i 7634

Fixed invalid header guards in the following files:
webrtc/base/base64.h
webrtc/base/cryptstring.h
webrtc/base/event.h
webrtc/base/flags.h
webrtc/base/httpbase.h
webrtc/base/httpcommon-inl.h
webrtc/base/httpcommon.h
webrtc/base/httpserver.h
webrtc/base/logsinks.h
webrtc/base/macutils.h
webrtc/base/nattypes.h
webrtc/base/openssladapter.h
webrtc/base/opensslstreamadapter.h
webrtc/base/pathutils.h
webrtc/base/physicalsocketserver.h
webrtc/base/proxyinfo.h
webrtc/base/sigslot.h
webrtc/base/sigslotrepeater.h
webrtc/base/socket.h
webrtc/base/socketaddresspair.h
webrtc/base/socketfactory.h
webrtc/base/stringutils.h
webrtc/base/testbase64.h
webrtc/base/testutils.h
webrtc/base/transformadapter.h
webrtc/base/win32filesystem.h

Added new header guards to:
sslroots.h
testbase64.h

BUG=webrtc:7634
NOTRY=True
NOPRESUBMIT=True
R=kwiberg@webrtc.org

Review-Url: https://codereview.webrtc.org/2877023002 .
Cr-Commit-Position: refs/heads/master@{#18816}
2017-06-28 18:58:10 +00:00

85 lines
2.8 KiB
C++

/*
* Copyright 2004 The WebRTC Project Authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef WEBRTC_RTC_BASE_TRANSFORMADAPTER_H_
#define WEBRTC_RTC_BASE_TRANSFORMADAPTER_H_
#include "webrtc/base/stream.h"
namespace rtc {
///////////////////////////////////////////////////////////////////////////////
class TransformInterface {
public:
virtual ~TransformInterface() { }
// Transform should convert the in_len bytes of input into the out_len-sized
// output buffer. If flush is true, there will be no more data following
// input.
// After the transformation, in_len contains the number of bytes consumed, and
// out_len contains the number of bytes ready in output.
// Note: Transform should not return SR_BLOCK, as there is no asynchronous
// notification available.
virtual StreamResult Transform(const void * input, size_t * in_len,
void * output, size_t * out_len,
bool flush) = 0;
};
///////////////////////////////////////////////////////////////////////////////
// TransformAdapter causes all data passed through to be transformed by the
// supplied TransformInterface object, which may apply compression, encryption,
// etc.
class TransformAdapter : public StreamAdapterInterface {
public:
// Note that the transformation is unidirectional, in the direction specified
// by the constructor. Operations in the opposite direction result in SR_EOS.
TransformAdapter(StreamInterface * stream,
TransformInterface * transform,
bool direction_read);
~TransformAdapter() override;
StreamResult Read(void* buffer,
size_t buffer_len,
size_t* read,
int* error) override;
StreamResult Write(const void* data,
size_t data_len,
size_t* written,
int* error) override;
void Close() override;
// Apriori, we can't tell what the transformation does to the stream length.
bool GetAvailable(size_t* size) const override;
bool ReserveSize(size_t size) override;
// Transformations might not be restartable
virtual bool Rewind();
private:
enum State { ST_PROCESSING, ST_FLUSHING, ST_COMPLETE, ST_ERROR };
enum { BUFFER_SIZE = 1024 };
TransformInterface * transform_;
bool direction_read_;
State state_;
int error_;
char buffer_[BUFFER_SIZE];
size_t len_;
};
///////////////////////////////////////////////////////////////////////////////
} // namespace rtc
#endif // WEBRTC_RTC_BASE_TRANSFORMADAPTER_H_