Commit Graph

43 Commits

Author SHA1 Message Date
370dd47973 Revert of Remove remains of webrtc/base (patchset #7 id:120001 of https://codereview.webrtc.org/2973183002/ )
Reason for revert:
Breaks lots of downstream projects.

Original issue's description:
> Remove remains of webrtc/base
>
> All downstream code have been updated to the new location.
>
> In PRESUBMIT.py:
> * Remove webrtc/rtc_base from CPP_BLACKLIST
> * Add webrtc/rtc_base to LEGACY_API_DIRS
>
> Fix some duplicated paths in
> webrtc/modules/audio_processing/test/conversational_speech/BUILD.gn
>
> BUG=webrtc:7634
> TBR=kwiberg@webrtc.org
>
> Review-Url: https://codereview.webrtc.org/2973183002
> Cr-Commit-Position: refs/heads/master@{#18948}
> Committed:
9483b49baf

TBR=kwiberg@webrtc.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:7634

Review-Url: https://codereview.webrtc.org/2976633002
Cr-Commit-Position: refs/heads/master@{#18949}
2017-07-10 12:58:42 +00:00
9483b49baf Remove remains of webrtc/base
All downstream code have been updated to the new location.

In PRESUBMIT.py:
* Remove webrtc/rtc_base from CPP_BLACKLIST
* Add webrtc/rtc_base to LEGACY_API_DIRS

Fix some duplicated paths in
webrtc/modules/audio_processing/test/conversational_speech/BUILD.gn

BUG=webrtc:7634
TBR=kwiberg@webrtc.org

Review-Url: https://codereview.webrtc.org/2973183002
Cr-Commit-Position: refs/heads/master@{#18948}
2017-07-10 11:50:54 +00:00
f4efb6fb3d Reland "Move webrtc/{base => rtc_base} (stub headers)
Add the stub headers from https://codereview.webrtc.org/2877023002
as a separate commit. This preserves git blame history of the moved files.

BUG=webrtc:7634
NOTRY=True
TBR=kwiberg@webrtc.org

Change-Id: Ic141abf11801fbfdeea5bcdb23608696ad449013
Reviewed-on: https://chromium-review.googlesource.com/554623
Reviewed-by: Henrik Kjellander <kjellander@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#18822}
2017-06-29 06:21:49 +00:00
c03627683f Reland "Move webrtc/{base => rtc_base}" (https://codereview.webrtc.org/2877023002)
Reland the base->rtc_base without adding stub headers (will be
done in follow-up CL). This preserves git blame history of all files.

BUG=webrtc:7634
NOTRY=True
TBR=kwiberg@webrtc.org

Change-Id: Iea3bb6f3f67b8374c96337b63e8f5aa3e6181012
Reviewed-on: https://chromium-review.googlesource.com/554611
Reviewed-by: Henrik Kjellander <kjellander@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#18821}
2017-06-29 06:04:25 +00:00
ec78f1cebc Revert "Move webrtc/{base => rtc_base}" (https://codereview.webrtc.org/2877023002)
Will reland in two different commits to preserve git blame history.

BUG=webrtc:7634
NOTRY=True
TBR=kwiberg@webrtc.org

Change-Id: I550da8525aeb9c5b8f96338fcf1c9714f3dcdab1
Reviewed-on: https://chromium-review.googlesource.com/554610
Reviewed-by: Henrik Kjellander <kjellander@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#18820}
2017-06-29 05:54:22 +00:00
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
1330166bc0 Add value_type alias to rtc::Buffer
It allows to use rtc::Buffer in templates that expect std container,
e.g. it can now be used as ::testing::ElementsAreArray parameter

Bug: None
Change-Id: I97d7ffb13393d02850ddb213f7a1d01129b10b05
Reviewed-on: https://chromium-review.googlesource.com/539635
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#18809}
2017-06-28 13:59:40 +00:00
1ba21eb063 Add [c]begin() and [c]end() member functions to rtc::Buffer
I can't believe it's been this long before I found out we didn't have
them...

BUG=none

Review-Url: https://codereview.webrtc.org/2804673002
Cr-Commit-Position: refs/heads/master@{#17544}
2017-04-05 14:38:06 +00:00
5377bc77cc Test RTC_DCHECK_IS_ON instead of checking DCHECK_ALWAYS_ON everywhere
The former is always defined (by webrtc/base/checks.h) to either 0 or
1, whereas the latter isn't necessarily defined.

This is a re-land of https://codereview.webrtc.org/2384693002, which
broke Chromium. We re-land without changing this CL at all, because
the thing that needed fixing was in Chromium:
https://codereview.chromium.org/2384263004.

NOTRY=true
TBR=ossu@webrtc.org
BUG=webrtc:6451

Review-Url: https://codereview.webrtc.org/2389943003
Cr-Commit-Position: refs/heads/master@{#14508}
2016-10-04 20:47:02 +00:00
8f9010631c Revert of Test RTC_DCHECK_IS_ON instead of checking DCHECK_ALWAYS_ON everywhere (patchset #2 id:20001 of https://codereview.webrtc.org/2384693002/ )
Reason for revert:
This CL breaks FYI bots with a compile error.

Sample error:
jingle/glue/thread_wrapper.cc -o obj/jingle/jingle_glue/thread_wrapper.o
In file included from ../../jingle/glue/thread_wrapper.cc:5:
In file included from ../../jingle/glue/thread_wrapper.h:16:
In file included from ../../base/message_loop/message_loop.h:17:
In file included from ../../base/memory/ref_counted.h:19:
../../base/logging.h:598:1: error: call to 'MakeCheckOpString' is ambiguous
DEFINE_CHECK_OP_IMPL(EQ, ==)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../base/logging.h:592:17: note: expanded from macro 'DEFINE_CHECK_OP_IMPL'
    else return MakeCheckOpString(v1, v2, names); \
                ^~~~~~~~~~~~~~~~~
../../jingle/glue/thread_wrapper.cc:46:3: note: in instantiation of function template specialization 'logging::CheckEQImpl<rtc::Thread *, jingle_glue::JingleThreadWrapper *>' requested here
  DCHECK_EQ(rtc::Thread::Current(), current());
  ^
../../base/logging.h:748:31: note: expanded from macro 'DCHECK_EQ'
#define DCHECK_EQ(val1, val2) DCHECK_OP(EQ, ==, val1, val2)
                              ^
../../base/logging.h:721:18: note: expanded from macro 'DCHECK_OP'
      ::logging::Check##name##Impl((val1), (val2),                     \
                 ^
<scratch space>:102:1: note: expanded from here
CheckEQImpl
^
../../base/logging.h:555:14: note: candidate function [with t1 = rtc::Thread *, t2 = jingle_glue::JingleThreadWrapper *]
std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) {
             ^
../../third_party/webrtc/base/checks.h:122:14: note: candidate function [with t1 = rtc::Thread *, t2 = jingle_glue::JingleThreadWrapper *]
std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) {
             ^
In file included from ../../jingle/glue/thread_wrapper.cc:5:
In file included from ../../jingle/glue/thread_wrapper.h:16:
In file included from ../../base/message_loop/message_loop.h:17:
In file included from ../../base/memory/ref_counted.h:19:
../../base/logging.h:598:1: error: call to 'MakeCheckOpString' is ambiguous
DEFINE_CHECK_OP_IMPL(EQ, ==)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../base/logging.h:592:17: note: expanded from macro 'DEFINE_CHECK_OP_IMPL'
    else return MakeCheckOpString(v1, v2, names); \
                ^~~~~~~~~~~~~~~~~
../../jingle/glue/thread_wrapper.cc:81:3: note: in instantiation of function template specialization 'logging::CheckEQImpl<jingle_glue::JingleThreadWrapper *, jingle_glue::JingleThreadWrapper *>' requested here
  DCHECK_EQ(this, JingleThreadWrapper::current());
  ^
../../base/logging.h:748:31: note: expanded from macro 'DCHECK_EQ'
#define DCHECK_EQ(val1, val2) DCHECK_OP(EQ, ==, val1, val2)
                              ^
../../base/logging.h:721:18: note: expanded from macro 'DCHECK_OP'
      ::logging::Check##name##Impl((val1), (val2),                     \
                 ^
<scratch space>:5:1: note: expanded from here
CheckEQImpl
^
../../base/logging.h:555:14: note: candidate function [with t1 = jingle_glue::JingleThreadWrapper *, t2 = jingle_glue::JingleThreadWrapper *]
std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) {
             ^
../../third_party/webrtc/base/checks.h:122:14: note: candidate function [with t1 = jingle_glue::JingleThreadWrapper *, t2 = jingle_glue::JingleThreadWrapper *]
std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) {
             ^
In file included from ../../jingle/glue/thread_wrapper.cc:5:
In file included from ../../jingle/glue/thread_wrapper.h:16:
In file included from ../../base/message_loop/message_loop.h:17:
In file included from ../../base/memory/ref_counted.h:19:
../../base/logging.h:598:1: error: call to 'MakeCheckOpString' is ambiguous
DEFINE_CHECK_OP_IMPL(EQ, ==)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../base/logging.h:592:17: note: expanded from macro 'DEFINE_CHECK_OP_IMPL'
    else return MakeCheckOpString(v1, v2, names); \
                ^~~~~~~~~~~~~~~~~
../../jingle/glue/thread_wrapper.cc:82:3: note: in instantiation of function template specialization 'logging::CheckEQImpl<jingle_glue::JingleThreadWrapper *, rtc::Thread *>' requested here
  DCHECK_EQ(this, rtc::Thread::Current());
  ^
../../base/logging.h:748:31: note: expanded from macro 'DCHECK_EQ'
#define DCHECK_EQ(val1, val2) DCHECK_OP(EQ, ==, val1, val2)
                              ^
../../base/logging.h:721:18: note: expanded from macro 'DCHECK_OP'
      ::logging::Check##name##Impl((val1), (val2),                     \
                 ^
<scratch space>:12:1: note: expanded from here
CheckEQImpl
^
../../base/logging.h:555:14: note: candidate function [with t1 = jingle_glue::JingleThreadWrapper *, t2 = rtc::Thread *]
std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) {
             ^
../../third_party/webrtc/base/checks.h:122:14: note: candidate function [with t1 = jingle_glue::JingleThreadWrapper *, t2 = rtc::Thread *]
std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) {
             ^
3 errors generated.

Original issue's description:
> Test RTC_DCHECK_IS_ON instead of checking DCHECK_ALWAYS_ON everywhere
>
> The former is always defined (by webrtc/base/checks.h) to either 0 or
> 1, whereas the latter isn't necessarily defined.
>
> NOTRY=true
> BUG=webrtc:6451
>
> Committed: https://crrev.com/ab0b929321d37669165d5795268fa10a8c97ec5b
> Cr-Commit-Position: refs/heads/master@{#14474}

TBR=ossu@webrtc.org,kwiberg@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:6451

Review-Url: https://codereview.webrtc.org/2384083004
Cr-Commit-Position: refs/heads/master@{#14480}
2016-10-03 15:32:36 +00:00
ab0b929321 Test RTC_DCHECK_IS_ON instead of checking DCHECK_ALWAYS_ON everywhere
The former is always defined (by webrtc/base/checks.h) to either 0 or
1, whereas the latter isn't necessarily defined.

NOTRY=true
BUG=webrtc:6451

Review-Url: https://codereview.webrtc.org/2384693002
Cr-Commit-Position: refs/heads/master@{#14474}
2016-10-03 12:04:25 +00:00
d313403564 rtc::Buffer: Let SetData and AppendData accept anything with .data() and .size()
In addition to setting or appending from another Buffer, which was
already possible, this allows for e.g. std::vector and rtc::ArrayView
arguments.

Review-Url: https://codereview.webrtc.org/2293983002
Cr-Commit-Position: refs/heads/master@{#14073}
2016-09-05 14:46:24 +00:00
5955e24fe8 Added an empty() method to rtc::Buffer
I'll be using it in a separate CL in a bit.

Review-Url: https://codereview.webrtc.org/2290343002
Cr-Commit-Position: refs/heads/master@{#14001}
2016-08-31 15:40:08 +00:00
c853597598 rtc::Buffer: Grow capacity by at least 1.5x to prevent quadratic behavior
BUG=webrtc:6009

Review-Url: https://codereview.webrtc.org/2078873005
Cr-Commit-Position: refs/heads/master@{#13214}
2016-06-20 11:47:46 +00:00
1642620a7d Performance fix for H264 RBSP parsing.
An rtc::Buffer is used to write output of RBSP parsing, usually one byte
at a time. It turns out that container will then expand its capacity one
byte at a time, for each byte reallocating the whole buffer and copying
the contents over, turning this into an O(n^2) operation.

Fix is for now only to preallocate the container storage. Longer term, I
think we should mull over if we really need custom containers...

R=pbos@webrtc.org
TBR=mflodman@webrtc.org
BUG=

Review URL: https://codereview.webrtc.org/2073763002 .

Cr-Commit-Position: refs/heads/master@{#13167}
2016-06-16 13:54:58 +00:00
52033d6ea1 Add H264 bitstream rewriting to limit frame reordering marker in header
The VUI part an SPS may specify max_num_reorder_frames and
max_dec_frame_buffering. These may cause a decoder to buffer a number
of frame prior allowing decode, leading to delays, even if no frames
using such references (ie B-frames) are sent.

Because of this we update any SPS block emitted by the encoder.

Also, a bunch of refactoring of H264-related code to reduce code
duplication.

BUG=

Review-Url: https://codereview.webrtc.org/1979443004
Cr-Commit-Position: refs/heads/master@{#13010}
2016-06-02 09:43:38 +00:00
a4ac4786a8 Define rtc::BufferT, like rtc::Buffer but for any trivial type
And redefine rtc::Buffer as

  using Buffer = BufferT<uint8_t>;

(In the long run, I'd like to remove the type alias and rename the
template to just rtc::Buffer, but that requires all current users of
Buffer to start saying Buffer<uint8_t> instead, and since Buffer is
used in the API, we can't do that in one step.)

The immediate reason for the new template is that we'd like to use
BufferT<int16_t> in the AudioDecoder interface.

BUG=webrtc:5801

Review-Url: https://codereview.webrtc.org/1929903002
Cr-Commit-Position: refs/heads/master@{#12564}
2016-04-29 15:00:28 +00:00
eec21bdae3 Reland Use CopyOnWriteBuffer instead of Buffer to avoid unnecessary copies.
This CL removes copy and assign support from Buffer and changes various
parameters from Buffer to CopyOnWriteBuffer so they can be passed along
and copied without actually copying the underlying data.

With this changed some parameters to be "const" and fixed an issue when
creating a CopyOnWriteBuffer with empty data.

BUG=webrtc:5155

Review URL: https://codereview.webrtc.org/1823503002

Cr-Commit-Position: refs/heads/master@{#12062}
2016-03-20 13:15:48 +00:00
194e3bcc53 Revert of Use CopyOnWriteBuffer instead of Buffer to avoid unnecessary copies. (patchset #4 id:60001 of https://codereview.webrtc.org/1785713005/ )
Reason for revert:
I'm really sorry for having to revert this but it seems this hit an unexpected compile error downstream:

webrtc/media/sctp/sctpdataengine.cc: In function 'void cricket::VerboseLogPacket(const void*, size_t, int)':
webrtc/media/sctp/sctpdataengine.cc:172:37: error: invalid conversion from 'const void*' to 'void*' [-fpermissive]
              data, length, direction)) != NULL) {
                                     ^
In file included from webrtc/media/sctp/sctpdataengine.cc:20:0:
third_party/usrsctp/usrsctplib/usrsctp.h:964:1: error:   initializing argument 1 of 'char* usrsctp_dumppacket(void*, size_t, int)' [-fpermissive]
 usrsctp_dumppacket(void *, size_t, int);
 ^

I'm sure you can fix this easily and just re-land this CL, while I'm going to look into how to add this warning at the public bots (on Monday).

Original issue's description:
> Use CopyOnWriteBuffer instead of Buffer to avoid unnecessary copies.
>
> This CL removes copy and assign support from Buffer and changes various
> parameters from Buffer to CopyOnWriteBuffer so they can be passed along
> and copied without actually copying the underlying data.
>
> With this changed some parameters to be "const" and fixed an issue when
> creating a CopyOnWriteBuffer with empty data.
>
> BUG=webrtc:5155
>
> Committed: https://crrev.com/944c39006f1c52aee20919676002dac7a42b1c05
> Cr-Commit-Position: refs/heads/master@{#12058}

TBR=kwiberg@webrtc.org,tkchin@webrtc.org,tommi@webrtc.org,pthatcher@webrtc.org,jbauch@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:5155

Review URL: https://codereview.webrtc.org/1817753003

Cr-Commit-Position: refs/heads/master@{#12060}
2016-03-19 19:12:58 +00:00
944c39006f Use CopyOnWriteBuffer instead of Buffer to avoid unnecessary copies.
This CL removes copy and assign support from Buffer and changes various
parameters from Buffer to CopyOnWriteBuffer so they can be passed along
and copied without actually copying the underlying data.

With this changed some parameters to be "const" and fixed an issue when
creating a CopyOnWriteBuffer with empty data.

BUG=webrtc:5155

Review URL: https://codereview.webrtc.org/1785713005

Cr-Commit-Position: refs/heads/master@{#12058}
2016-03-19 08:57:40 +00:00
0149e7595e Remove the (previosly deprecated) Pass methods
Everyone should be using std::move instead.

BUG=webrtc:5373

Review URL: https://codereview.webrtc.org/1778243006

Cr-Commit-Position: refs/heads/master@{#11962}
2016-03-11 22:40:59 +00:00
e3d99221c4 rtc::Buffer: Use RTC_DCHECK instead of assert
Review URL: https://codereview.webrtc.org/1749693002

Cr-Commit-Position: refs/heads/master@{#11826}
2016-03-01 09:57:41 +00:00
b9338ac62b Added an operator[] to Buffer, to make reading data easier.
Review URL: https://codereview.webrtc.org/1745033002

Cr-Commit-Position: refs/heads/master@{#11819}
2016-02-29 17:36:44 +00:00
b01c7816a8 Added functional variants of Buffer::SetData and Buffer::AppendData.
They are invoked with the maximum size of the data to be added, and a
callable that generates that data, like this:

buffer.AppendData(10, [] (rtc::ArrayView<uint8_t> av) {
    for (uint8_t i = 0; i != 5; ++i)
      av[i] = i;

    return 5;
  });

The callable returns the number of bytes actually written, and the
final Buffer size will be adjusted accordingly. SetData and AppendData
both return the number of bytes added (i.e. the return value of the
callable).

These versions will be useful when converting AudioEncoder::Encode to use Buffer rather than raw pointers.

Also added a few tests for the new functionality.

Review URL: https://codereview.webrtc.org/1717273002

Cr-Commit-Position: refs/heads/master@{#11733}
2016-02-24 09:06:02 +00:00
728012e49f Changed the semantics of Buffer::Clear to not alter the capacity
Also added a test for Clear to ensure this invariant holds.

With this change, it is easy to empty a Buffer and reuse its storage. Further down the line, code filling data into a Buffer could be written to just append to it, with the caller determining if the Buffer should first be cleared or not.

There is currently only one use of Buffer::Clear (in AudioEncoderCopyRed::Reset()) and it should benefit from the change, by not requiring a reallocation after Reset.

Review URL: https://codereview.webrtc.org/1707693002

Cr-Commit-Position: refs/heads/master@{#11680}
2016-02-19 10:38:37 +00:00
8fb3557052 rtc::Buffer: Replace an internal rtc::scoped_ptr with std::unique_ptr
We'd like to completely replace rtc::scoped_ptr with std::unique_ptr.
This is a first trial CL to see if using unique_ptr causes any
problems.

(As a side effect of removing the scoped_ptr.h include in buffer.h,
I had to fix broken includes in no less than three files.)

BUG=webrtc:5520

Review URL: https://codereview.webrtc.org/1687833006

Cr-Commit-Position: refs/heads/master@{#11588}
2016-02-11 21:36:57 +00:00
36220ae24f Slap deprecation notices on Pass methods
There's no reason not to use std::move instead now that we can use the
C++11 standard library.

BUG=webrtc:5373

Review URL: https://codereview.webrtc.org/1531013003

Cr-Commit-Position: refs/heads/master@{#11225}
2016-01-12 15:24:27 +00:00
cea7c2f783 Replace manual casting to rvalue reference with calls to std::move
Review URL: https://codereview.webrtc.org/1570473002

Cr-Commit-Position: refs/heads/master@{#11163}
2016-01-07 13:52:09 +00:00
0eb15ed7b8 Don't call the Pass methods of rtc::Buffer, rtc::scoped_ptr, and rtc::ScopedVector
We can now use std::move instead!

This CL leaves the Pass methods in place; a follow-up CL will add deprecation annotations to them.

Review URL: https://codereview.webrtc.org/1460043002

Cr-Commit-Position: refs/heads/master@{#11064}
2015-12-17 11:04:24 +00:00
27dfe201a5 Remove final from rtc::Buffer.
With it removed, you can now use it with scoped_refptr by wrapping it in
an rtc::RefCountedObject<rtc::Buffer>.

BUG=

Review URL: https://codereview.webrtc.org/1414053003

Cr-Commit-Position: refs/heads/master@{#10386}
2015-10-23 13:01:14 +00:00
c56ac1ec29 rtc::Buffer: Remove backwards compatibility band-aids
This CL makes two changes to rtc::Buffer that have had to wait for
Chromium's use of it to be modernized:

  1. Change default return type of rtc::Buffer::data() from char* to
     uint8_t*. uint8_t is a more natural type for bytes, and won't
     accidentally convert to a string. (Chromium previously expected
     the default return type to be char, which is why
     rtc::Buffer::data() initially got char as default return type in
     9478437f, but that's been fixed now.)

  2. Stop accepting void* inputs in constructors and methods. While
     this is convenient, it's also dangerous since any pointer type
     will implicitly convert to void*.

(This was previously committed (9e1a6d7c) but had to be reverted
(cbf09274) because Chromium on Android wasn't quite ready for it).

TBR=tommi@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/47109004

Cr-Commit-Position: refs/heads/master@{#9132}
2015-05-04 12:54:56 +00:00
cbf0927473 Revert "rtc::Buffer: Remove backwards compatibility band-aids"
This reverts commit 9e1a6d7c236c9a8a322bef54d4ec2a087e5baa07, because
Chromium for Android still isn't happy with it.

TBR=tommi@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/49869004

Cr-Commit-Position: refs/heads/master@{#9122}
2015-04-30 14:01:01 +00:00
9e1a6d7c23 rtc::Buffer: Remove backwards compatibility band-aids
This CL makes two changes to rtc::Buffer that have had to wait for
Chromium's use of it to be modernized:

  1. Change default return type of rtc::Buffer::data() from char* to
     uint8_t*. uint8_t is a more natural type for bytes, and won't
     accidentally convert to a string. (Chromium previously expected
     the default return type to be char, which is why
     rtc::Buffer::data() initially got char as default return type in
     9478437f, but that's been fixed now.)

  2. Stop accepting void* inputs in constructors and methods. While
     this is convenient, it's also dangerous since any pointer type
     will implicitly convert to void*.

R=tommi@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/44269004

Cr-Commit-Position: refs/heads/master@{#9121}
2015-04-30 12:25:06 +00:00
011c00f708 rtc::Buffer: Accept void* in addition to the byte-sized types
We used to accept void* (until 9478437f), and we'll have to continue
to do so for a little while longer, until Chromium doesn't need it
anymore.

TBR=tommi@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/48179004

Cr-Commit-Position: refs/heads/master@{#9035}
2015-04-20 20:55:41 +00:00
9478437fde rtc::Buffer improvements
1. Constructors, SetData(), and AppendData() now accept uint8_t*,
     int8_t*, and char*. Previously, they accepted void*, meaning that
     any kind of pointer was accepted. I think requiring an explicit
     cast in cases where the input array isn't already of a byte-sized
     type is a better compromise between convenience and safety.

  2. data() can now return a uint8_t* instead of a char*, which seems
     more appropriate for a byte array, and is harder to mix up with
     zero-terminated C strings. data<int8_t>() is also available so
     that callers that want that type instead won't have to cast, as
     is data<char>() (which remains the default until all existing
     callers have been fixed).

  3. Constructors, SetData(), and AppendData() now accept arrays
     natively, not just decayed to pointers. The advantage of this is
     that callers don't have to pass the size separately.

  4. There are new constructors that allow setting size and capacity
     without initializing the array. Previously, this had to be done
     separately after construction.

  5. Instead of TransferTo(), Buffer now supports swap(), and move
     construction and assignment, and has a Pass() method that works
     just like std::move(). (The Pass method is modeled after
     scoped_ptr::Pass().)

R=jmarusic@webrtc.org, tommi@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/42989004

Cr-Commit-Position: refs/heads/master@{#9033}
2015-04-20 12:03:00 +00:00
61c2a6f241 Remove rtc::Buffer::length(), since no one uses it anymore
Chromium now uses size() instead, just like WebRTC.

This CL also fixes a new length() call that had crept in.

R=tommi@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/44119004

Cr-Commit-Position: refs/heads/master@{#9024}
2015-04-16 19:48:52 +00:00
4d14592c67 rtc::Buffer: Restore length method for backwards compatibility
TBR=tommi@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/43939004

Cr-Commit-Position: refs/heads/master@{#8845}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8845 4adac7df-926f-26a2-2b94-8c16560cd09d
2015-03-24 12:52:14 +00:00
eebcab5ce9 rtc::Buffer: Rename length to size, for conformance with the STL
And add a constructor for creating an uninitialized Buffer of a
specified size.

(I intend to follow up with more Buffer changes, but since it's rather
widely used, the rename is quite noisy and works better as a separate
CL.)

R=tommi@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/48579004

Cr-Commit-Position: refs/heads/master@{#8841}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8841 4adac7df-926f-26a2-2b94-8c16560cd09d
2015-03-24 09:20:19 +00:00
67186fe00c Fix clang style warnings in webrtc/base
Mostly this consists of marking functions with override when
applicable, and moving function bodies from .h to .cc files.

Not inlining virtual functions with simple bodies such as

  { return false; }

strikes me as probably losing more in readability than we gain in
binary size and compilation time, but I guess it's just like any other
case where enabling a generally good warning forces us to write
slightly worse code in a couple of places.

BUG=163
R=kjellander@webrtc.org, tommi@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/47429004

Cr-Commit-Position: refs/heads/master@{#8656}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8656 4adac7df-926f-26a2-2b94-8c16560cd09d
2015-03-09 22:24:25 +00:00
11426dc719 Don't rely on webrtc/base/scoped_ptr.h to include stuff for you
webrtc/base/scoped_ptr.h doesn't need to include webrtc/base/common.h
anymore, but a couple of its users were relying on it to pull in other
things for them. Fix that, and remove the now really unnecessary
webrtc/base/common.h include.

R=andrew@webrtc.org, pthatcher@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/37169004

Cr-Commit-Position: refs/heads/master@{#8333}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8333 4adac7df-926f-26a2-2b94-8c16560cd09d
2015-02-11 14:31:19 +00:00
f048872e91 Adds a modified copy of talk/base to webrtc/base. It is the first step in
migrating talk/base to webrtc/base.

BUG=N/A
R=niklas.enbom@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/17479005

git-svn-id: http://webrtc.googlecode.com/svn/trunk@6129 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-05-13 18:00:26 +00:00
e9a604accd Revert 6107 "Adds a modified copy of talk/base to webrtc/base. I..."
This breaks Chromium FYI builds and prevent roll of webrtc/libjingle to Chrome.

http://chromegw.corp.google.com/i/chromium.webrtc.fyi/builders/Win%20Builder/builds/457


> Adds a modified copy of talk/base to webrtc/base. It is the first step in migrating talk/base to webrtc/base.
> 
> BUG=N/A
> R=andrew@webrtc.org, wu@webrtc.org
> 
> Review URL: https://webrtc-codereview.appspot.com/12199004

TBR=henrike@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/14479004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@6116 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-05-13 08:15:48 +00:00
2c7d1b39b9 Adds a modified copy of talk/base to webrtc/base. It is the first step in migrating talk/base to webrtc/base.
BUG=N/A
R=andrew@webrtc.org, wu@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/12199004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@6107 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-05-12 18:03:09 +00:00