зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1198458: Webrtc updated to branch 43; pull made 2015-09-29 09:00AM PDT rs=jesup
https://chromium.googlesource.com/external/webrtc git checkout -b my_branch refs/remotes/branch-heads/43 commit 6979b024d7cebfdcd1e8f66da59ea157bbc9e47e (I believe) --HG-- rename : media/webrtc/trunk/webrtc/build/tsan_suppressions_webrtc.cc => media/webrtc/trunk/webrtc/build/sanitizers/tsan_suppressions_webrtc.cc rename : media/webrtc/trunk/webrtc/modules/audio_processing/utility/fft4g.c => media/webrtc/trunk/webrtc/common_audio/fft4g.c rename : media/webrtc/trunk/webrtc/modules/audio_processing/utility/ring_buffer.c => media/webrtc/trunk/webrtc/common_audio/ring_buffer.c rename : media/webrtc/trunk/webrtc/modules/audio_processing/utility/ring_buffer.h => media/webrtc/trunk/webrtc/common_audio/ring_buffer.h rename : media/webrtc/trunk/webrtc/modules/audio_processing/utility/ring_buffer_unittest.cc => media/webrtc/trunk/webrtc/common_audio/ring_buffer_unittest.cc rename : media/webrtc/trunk/webrtc/modules/audio_coding/codecs/tools/audio_codec_speed_tests.isolate => media/webrtc/trunk/webrtc/modules/audio_coding/audio_codec_speed_tests.isolate rename : media/webrtc/trunk/webrtc/modules/audio_coding/neteq/test/neteq_opus_fec_quality_test.cc => media/webrtc/trunk/webrtc/modules/audio_coding/neteq/test/neteq_opus_quality_test.cc rename : media/webrtc/trunk/webrtc/modules/audio_processing/agc/analog_agc.c => media/webrtc/trunk/webrtc/modules/audio_processing/agc/legacy/analog_agc.c rename : media/webrtc/trunk/webrtc/modules/audio_processing/agc/analog_agc.h => media/webrtc/trunk/webrtc/modules/audio_processing/agc/legacy/analog_agc.h rename : media/webrtc/trunk/webrtc/modules/audio_processing/agc/digital_agc.c => media/webrtc/trunk/webrtc/modules/audio_processing/agc/legacy/digital_agc.c rename : media/webrtc/trunk/webrtc/system_wrappers/source/system_wrappers_unittests.isolate => media/webrtc/trunk/webrtc/system_wrappers/system_wrappers_unittests.isolate
This commit is contained in:
Родитель
edaa76fc23
Коммит
1d652361f7
|
@ -0,0 +1,42 @@
|
|||
# Names should be added to this file like so:
|
||||
# Name or Organization <email address>
|
||||
|
||||
Anil Kumar <an1kumar@gmail.com>
|
||||
Ben Strong <bstrong@gmail.com>
|
||||
Bob Withers <bwit@pobox.com>
|
||||
Bridger Maxwell <bridgeyman@gmail.com>
|
||||
Christophe Dumez <ch.dumez@samsung.com>
|
||||
Colin Plumb
|
||||
Eric Rescorla, RTFM Inc.
|
||||
Giji Gangadharan <giji.g@samsung.com>
|
||||
Graham Yoakum <gyoakum@skobalt.com>
|
||||
Jake Hilton <jakehilton@gmail.com>
|
||||
James H. Brown <jbrown@burgoyne.com>
|
||||
Jie Mao <maojie0924@gmail.com>
|
||||
Luke Weber
|
||||
Manish Jethani <manish.jethani@gmail.com>
|
||||
Martin Storsjo <martin@martin.st>
|
||||
Matthias Liebig <matthias.gcode@gmail.com>
|
||||
Pali Rohar
|
||||
Paul Kapustin <pkapustin@gmail.com>
|
||||
Rafael Lopez Diez <rafalopezdiez@gmail.com>
|
||||
Ralph Giles <giles@ghostscript.com>
|
||||
Robert Nagy
|
||||
Ron Rivest
|
||||
Ryan Yoakum <ryoakum@skobalt.com>
|
||||
Sarah Thompson <sarah@telergy.com>
|
||||
Saul Kravitz <Saul.Kravitz@celera.com>
|
||||
Silviu Caragea <silviu.cpp@gmail.com>
|
||||
Steve Reid <sreid@sea-to-sky.net>
|
||||
Vicken Simonian <vsimon@gmail.com>
|
||||
Victor Costan <costan@gmail.com>
|
||||
|
||||
ARM Holdings
|
||||
Google Inc.
|
||||
Intel Corporation
|
||||
MIPS Technologies
|
||||
Mozilla Foundation
|
||||
Opera Software ASA
|
||||
struktur AG
|
||||
Temasys Communications
|
||||
Vonage Holdings Corp.
|
|
@ -1,315 +1,103 @@
|
|||
use_relative_paths = True
|
||||
# This file contains dependencies for WebRTC that are not shared with Chromium.
|
||||
# If you wish to add a dependency that is present in Chromium's src/DEPS or a
|
||||
# directory from the Chromium checkout, you should add it to setup_links.py
|
||||
# instead.
|
||||
|
||||
vars = {
|
||||
# Override root_dir in your .gclient's custom_vars to specify a custom root
|
||||
# folder name.
|
||||
"root_dir": "trunk",
|
||||
"extra_gyp_flag": "-Dextra_gyp_flag=0",
|
||||
|
||||
# Use this googlecode_url variable only if there is an internal mirror for it.
|
||||
# If you do not know, use the full path while defining your new deps entry.
|
||||
"googlecode_url": "http://%s.googlecode.com/svn",
|
||||
"sourceforge_url": "http://svn.code.sf.net/p/%(repo)s/code",
|
||||
"chromium_trunk" : "http://src.chromium.org/svn/trunk",
|
||||
"chromium_revision": "249215",
|
||||
|
||||
# A small subset of WebKit is needed for the Android Python test framework.
|
||||
"webkit_trunk": "http://src.chromium.org/blink/trunk",
|
||||
'extra_gyp_flag': '-Dextra_gyp_flag=0',
|
||||
'chromium_git': 'https://chromium.googlesource.com',
|
||||
'chromium_revision': '719b83983be9613eb80e99a0bc645776d59b76b3',
|
||||
}
|
||||
|
||||
# NOTE: Prefer revision numbers to tags for svn deps. Use http rather than
|
||||
# https; the latter can cause problems for users behind proxies.
|
||||
deps = {
|
||||
"../chromium_deps":
|
||||
File(Var("chromium_trunk") + "/src/DEPS@" + Var("chromium_revision")),
|
||||
# When rolling gflags, also update
|
||||
# https://chromium.googlesource.com/chromium/deps/webrtc/webrtc.DEPS
|
||||
'src/third_party/gflags/src':
|
||||
Var('chromium_git') + '/external/gflags/src@e7390f9185c75f8d902c05ed7d20bb94eb914d0c', # from svn revision 82
|
||||
|
||||
"../chromium_gn":
|
||||
File(Var("chromium_trunk") + "/src/.gn@" + Var("chromium_revision")),
|
||||
|
||||
"build":
|
||||
Var("chromium_trunk") + "/src/build@" + Var("chromium_revision"),
|
||||
|
||||
# Needed by common.gypi.
|
||||
"google_apis/build":
|
||||
Var("chromium_trunk") + "/src/google_apis/build@" + Var("chromium_revision"),
|
||||
|
||||
"testing":
|
||||
Var("chromium_trunk") + "/src/testing@" + Var("chromium_revision"),
|
||||
|
||||
"testing/gmock":
|
||||
From("chromium_deps", "src/testing/gmock"),
|
||||
|
||||
"testing/gtest":
|
||||
From("chromium_deps", "src/testing/gtest"),
|
||||
|
||||
"third_party/clang_format":
|
||||
Var("chromium_trunk") + "/src/third_party/clang_format@" + Var("chromium_revision"),
|
||||
|
||||
"third_party/clang_format/script":
|
||||
From("chromium_deps", "src/third_party/clang_format/script"),
|
||||
|
||||
"third_party/expat":
|
||||
Var("chromium_trunk") + "/src/third_party/expat@" + Var("chromium_revision"),
|
||||
|
||||
# When rolling gflags, also update deps/third_party/webrtc/webrtc.DEPS/DEPS
|
||||
# in Chromium's repo.
|
||||
"third_party/gflags/src":
|
||||
(Var("googlecode_url") % "gflags") + "/trunk/src@84",
|
||||
|
||||
"third_party/icu/":
|
||||
From("chromium_deps", "src/third_party/icu"),
|
||||
|
||||
"third_party/jsoncpp/":
|
||||
Var("chromium_trunk") + "/src/third_party/jsoncpp@" + Var("chromium_revision"),
|
||||
|
||||
"third_party/jsoncpp/source":
|
||||
(Var("sourceforge_url") % {"repo": "jsoncpp"}) + "/trunk/jsoncpp@248",
|
||||
|
||||
"third_party/junit/":
|
||||
(Var("googlecode_url") % "webrtc") + "/deps/third_party/junit@3367",
|
||||
|
||||
"third_party/libjpeg":
|
||||
Var("chromium_trunk") + "/src/third_party/libjpeg@" + Var("chromium_revision"),
|
||||
|
||||
"third_party/libjpeg_turbo":
|
||||
From("chromium_deps", "src/third_party/libjpeg_turbo"),
|
||||
|
||||
"third_party/libsrtp/":
|
||||
From("chromium_deps", "src/third_party/libsrtp"),
|
||||
|
||||
"third_party/libvpx":
|
||||
Var("chromium_trunk") + "/deps/third_party/libvpx@248011",
|
||||
|
||||
"third_party/libyuv":
|
||||
(Var("googlecode_url") % "libyuv") + "/trunk@979",
|
||||
|
||||
"third_party/opus":
|
||||
Var("chromium_trunk") + "/src/third_party/opus@245176",
|
||||
|
||||
"third_party/opus/src":
|
||||
Var("chromium_trunk") + "/deps/third_party/opus@239448",
|
||||
|
||||
"third_party/protobuf":
|
||||
Var("chromium_trunk") + "/src/third_party/protobuf@" + Var("chromium_revision"),
|
||||
|
||||
"third_party/sqlite/":
|
||||
Var("chromium_trunk") + "/src/third_party/sqlite@" + Var("chromium_revision"),
|
||||
|
||||
"third_party/yasm":
|
||||
Var("chromium_trunk") + "/src/third_party/yasm@" + Var("chromium_revision"),
|
||||
|
||||
"third_party/yasm/source/patched-yasm":
|
||||
From("chromium_deps", "src/third_party/yasm/source/patched-yasm"),
|
||||
|
||||
"tools/clang":
|
||||
Var("chromium_trunk") + "/src/tools/clang@" + Var("chromium_revision"),
|
||||
|
||||
"tools/gn":
|
||||
Var("chromium_trunk") + "/src/tools/gn@" + Var("chromium_revision"),
|
||||
|
||||
"tools/gyp":
|
||||
From("chromium_deps", "src/tools/gyp"),
|
||||
|
||||
"tools/protoc_wrapper":
|
||||
Var("chromium_trunk") + "/src/tools/protoc_wrapper@" + Var("chromium_revision"),
|
||||
|
||||
"tools/python":
|
||||
Var("chromium_trunk") + "/src/tools/python@" + Var("chromium_revision"),
|
||||
|
||||
"tools/swarming_client":
|
||||
From("chromium_deps", "src/tools/swarming_client"),
|
||||
|
||||
"tools/valgrind":
|
||||
Var("chromium_trunk") + "/src/tools/valgrind@" + Var("chromium_revision"),
|
||||
|
||||
# Needed by build/common.gypi.
|
||||
"tools/win/supalink":
|
||||
Var("chromium_trunk") + "/src/tools/win/supalink@" + Var("chromium_revision"),
|
||||
|
||||
"net/third_party/nss":
|
||||
Var("chromium_trunk") + "/src/net/third_party/nss@" + Var("chromium_revision"),
|
||||
|
||||
"third_party/usrsctp/":
|
||||
Var("chromium_trunk") + "/src/third_party/usrsctp@" + Var("chromium_revision"),
|
||||
|
||||
"third_party/usrsctp/usrsctplib":
|
||||
(Var("googlecode_url") % "sctp-refimpl") + "/trunk/KERN/usrsctp/usrsctplib@8723",
|
||||
'src/third_party/junit':
|
||||
Var('chromium_git') + '/external/webrtc/deps/third_party/junit@f35596b476aa6e62fd3b3857b9942ddcd13ce35e', # from svn revision 3367
|
||||
}
|
||||
|
||||
deps_os = {
|
||||
"win": {
|
||||
"third_party/winsdk_samples/src":
|
||||
(Var("googlecode_url") % "webrtc") + "/deps/third_party/winsdk_samples_v71@3145",
|
||||
|
||||
# Used by libjpeg-turbo.
|
||||
"third_party/yasm/binaries":
|
||||
From("chromium_deps", "src/third_party/yasm/binaries"),
|
||||
|
||||
# NSS, for SSLClientSocketNSS.
|
||||
"third_party/nss":
|
||||
From("chromium_deps", "src/third_party/nss"),
|
||||
|
||||
# SyzyASan to make it possible to run tests under ASan on Windows.
|
||||
"third_party/syzygy/binaries":
|
||||
From("chromium_deps", "src/third_party/syzygy/binaries"),
|
||||
},
|
||||
|
||||
"mac": {
|
||||
# NSS, for SSLClientSocketNSS.
|
||||
"third_party/nss":
|
||||
From("chromium_deps", "src/third_party/nss"),
|
||||
},
|
||||
|
||||
"ios": {
|
||||
# NSS, for SSLClientSocketNSS.
|
||||
"third_party/nss":
|
||||
From("chromium_deps", "src/third_party/nss"),
|
||||
|
||||
# class-dump utility to generate header files for undocumented SDKs.
|
||||
"testing/iossim/third_party/class-dump":
|
||||
From("chromium_deps", "src/testing/iossim/third_party/class-dump"),
|
||||
|
||||
# Helper for running under the simulator.
|
||||
"testing/iossim":
|
||||
Var("chromium_trunk") + "/src/testing/iossim@" + Var("chromium_revision"),
|
||||
},
|
||||
|
||||
"unix": {
|
||||
"third_party/gold":
|
||||
From("chromium_deps", "src/third_party/gold"),
|
||||
},
|
||||
|
||||
"android": {
|
||||
# Precompiled tools needed for Android test execution. Needed since we can't
|
||||
# compile them from source in WebRTC since they depend on Chromium's base.
|
||||
"tools/android":
|
||||
(Var("googlecode_url") % "webrtc") + "/deps/tools/android@4258",
|
||||
|
||||
"third_party/android_tools":
|
||||
From("chromium_deps", "src/third_party/android_tools"),
|
||||
|
||||
"third_party/android_testrunner":
|
||||
Var("chromium_trunk") + "/src/third_party/android_testrunner@" + Var("chromium_revision"),
|
||||
|
||||
"third_party/WebKit/Tools/Scripts":
|
||||
Var("webkit_trunk") + "/Tools/Scripts@151677",
|
||||
|
||||
"third_party/openssl":
|
||||
From("chromium_deps", "src/third_party/openssl"),
|
||||
'win': {
|
||||
'src/third_party/winsdk_samples/src':
|
||||
Var('chromium_git') + '/external/webrtc/deps/third_party/winsdk_samples_v71@c0cbedd854cb610a53226d9817416c4ab9a7d1e9', # from svn revision 7951
|
||||
},
|
||||
}
|
||||
|
||||
# Define rules for which include paths are allowed in our source.
|
||||
include_rules = [
|
||||
# Base is only used to build Android APK tests and may not be referenced by
|
||||
# WebRTC production code.
|
||||
'-base',
|
||||
'-chromium',
|
||||
'+gflags',
|
||||
'+libyuv',
|
||||
'+net',
|
||||
'+talk',
|
||||
'+testing',
|
||||
'+third_party',
|
||||
'+webrtc',
|
||||
]
|
||||
|
||||
# checkdeps.py shouldn't check include paths for files in these dirs:
|
||||
skip_child_includes = [
|
||||
'webrtc/overrides',
|
||||
]
|
||||
|
||||
hooks = [
|
||||
{
|
||||
# Copy .gn from temporary place (../chromium_gn) to root_dir.
|
||||
"name": "copy .gn",
|
||||
"pattern": ".",
|
||||
"action": ["python", Var("root_dir") + "/build/cp.py",
|
||||
Var("root_dir") + "/../chromium_gn/.gn",
|
||||
Var("root_dir")],
|
||||
},
|
||||
# Pull GN binaries. This needs to be before running GYP below.
|
||||
{
|
||||
"name": "gn_win",
|
||||
"pattern": "tools/gn/bin/win/gn.exe.sha1",
|
||||
"action": [ "download_from_google_storage",
|
||||
"--no_resume",
|
||||
"--platform=win32",
|
||||
"--no_auth",
|
||||
"--bucket", "chromium-gn",
|
||||
"-s", Var("root_dir") + "/tools/gn/bin/win/gn.exe.sha1",
|
||||
],
|
||||
# Check for legacy named top-level dir (named 'trunk').
|
||||
'name': 'check_root_dir_name',
|
||||
'pattern': '.',
|
||||
'action': ['python','-c',
|
||||
('import os,sys;'
|
||||
'script = os.path.join("trunk","check_root_dir.py");'
|
||||
'_ = os.system("%s %s" % (sys.executable,script)) '
|
||||
'if os.path.exists(script) else 0')],
|
||||
},
|
||||
{
|
||||
"name": "gn_mac",
|
||||
"pattern": "tools/gn/bin/mac/gn.sha1",
|
||||
"action": [ "download_from_google_storage",
|
||||
"--no_resume",
|
||||
"--platform=darwin",
|
||||
"--no_auth",
|
||||
"--bucket", "chromium-gn",
|
||||
"-s", Var("root_dir") + "/tools/gn/bin/mac/gn.sha1",
|
||||
],
|
||||
# Clone chromium and its deps.
|
||||
'name': 'sync chromium',
|
||||
'pattern': '.',
|
||||
'action': ['python', '-u', 'src/sync_chromium.py',
|
||||
'--target-revision', Var('chromium_revision')],
|
||||
},
|
||||
{
|
||||
"name": "gn_linux",
|
||||
"pattern": "tools/gn/bin/linux/gn.sha1",
|
||||
"action": [ "download_from_google_storage",
|
||||
"--no_resume",
|
||||
"--platform=linux*",
|
||||
"--no_auth",
|
||||
"--bucket", "chromium-gn",
|
||||
"-s", Var("root_dir") + "/tools/gn/bin/linux/gn.sha1",
|
||||
],
|
||||
# Create links to shared dependencies in Chromium.
|
||||
'name': 'setup_links',
|
||||
'pattern': '.',
|
||||
'action': ['python', 'src/setup_links.py'],
|
||||
},
|
||||
{
|
||||
"name": "gn_linux32",
|
||||
"pattern": "tools/gn/bin/linux/gn32.sha1",
|
||||
"action": [ "download_from_google_storage",
|
||||
"--no_resume",
|
||||
"--platform=linux*",
|
||||
"--no_auth",
|
||||
"--bucket", "chromium-gn",
|
||||
"-s", Var("root_dir") + "/tools/gn/bin/linux/gn32.sha1",
|
||||
],
|
||||
},
|
||||
# Pull clang-format binaries using checked-in hashes.
|
||||
{
|
||||
"name": "clang_format_win",
|
||||
"pattern": "third_party/clang_format/bin/win/clang-format.exe.sha1",
|
||||
"action": [ "download_from_google_storage",
|
||||
"--no_resume",
|
||||
"--platform=win32",
|
||||
"--no_auth",
|
||||
"--bucket", "chromium-clang-format",
|
||||
"-s", Var("root_dir") + "/third_party/clang_format/bin/win/clang-format.exe.sha1",
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "clang_format_mac",
|
||||
"pattern": "third_party/clang_format/bin/mac/clang-format.sha1",
|
||||
"action": [ "download_from_google_storage",
|
||||
"--no_resume",
|
||||
"--platform=darwin",
|
||||
"--no_auth",
|
||||
"--bucket", "chromium-clang-format",
|
||||
"-s", Var("root_dir") + "/third_party/clang_format/bin/mac/clang-format.sha1",
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "clang_format_linux",
|
||||
"pattern": "third_party/clang_format/bin/linux/clang-format.sha1",
|
||||
"action": [ "download_from_google_storage",
|
||||
"--no_resume",
|
||||
"--platform=linux*",
|
||||
"--no_auth",
|
||||
"--bucket", "chromium-clang-format",
|
||||
"-s", Var("root_dir") + "/third_party/clang_format/bin/linux/clang-format.sha1",
|
||||
],
|
||||
},
|
||||
{
|
||||
# Pull clang on mac. If nothing changed, or on non-mac platforms, this takes
|
||||
# zero seconds to run. If something changed, it downloads a prebuilt clang.
|
||||
"pattern": ".",
|
||||
"action": ["python", Var("root_dir") + "/tools/clang/scripts/update.py",
|
||||
"--mac-only"],
|
||||
},
|
||||
# Pull sanitizer-instrumented third-party libraries if requested via
|
||||
# GYP_DEFINES. This could be done as part of sync_chromium.py above
|
||||
# but then we would need to run all the Chromium hooks each time,
|
||||
# which will slow things down a lot.
|
||||
'name': 'instrumented_libraries',
|
||||
'pattern': '\\.sha1',
|
||||
'action': ['python', 'src/third_party/instrumented_libraries/scripts/download_binaries.py'],
|
||||
},
|
||||
{
|
||||
# Download test resources, i.e. video and audio files from Google Storage.
|
||||
"pattern": "\\.sha1",
|
||||
"action": ["download_from_google_storage",
|
||||
"--directory",
|
||||
"--recursive",
|
||||
"--num_threads=10",
|
||||
"--no_auth",
|
||||
"--bucket", "chromium-webrtc-resources",
|
||||
Var("root_dir") + "/resources"],
|
||||
'pattern': '.',
|
||||
'action': ['download_from_google_storage',
|
||||
'--directory',
|
||||
'--recursive',
|
||||
'--num_threads=10',
|
||||
'--no_auth',
|
||||
'--bucket', 'chromium-webrtc-resources',
|
||||
'src/resources'],
|
||||
},
|
||||
{
|
||||
# A change to a .gyp, .gypi, or to GYP itself should run the generator.
|
||||
"pattern": ".",
|
||||
"action": ["python", Var("root_dir") + "/webrtc/build/gyp_webrtc",
|
||||
Var("extra_gyp_flag")],
|
||||
'name': 'gyp',
|
||||
'pattern': '.',
|
||||
'action': ['python', 'src/webrtc/build/gyp_webrtc',
|
||||
Var('extra_gyp_flag')],
|
||||
},
|
||||
]
|
||||
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
andrew@webrtc.org
|
||||
henrika@webrtc.org
|
||||
mflodman@webrtc.org
|
||||
niklas.enbom@webrtc.org
|
||||
tina.legrand@webrtc.org
|
||||
tommi@webrtc.org
|
||||
per-file *.isolate=kjellander@webrtc.org
|
||||
per-file .gitignore=*
|
||||
per-file AUTHORS=*
|
||||
per-file DEPS=*
|
||||
per-file WATCHLISTS=*
|
||||
per-file webrtc_examples.gyp=*
|
||||
andrew@webrtc.org
|
||||
henrika@webrtc.org
|
||||
mflodman@webrtc.org
|
||||
niklas.enbom@webrtc.org
|
||||
tina.legrand@webrtc.org
|
||||
tommi@webrtc.org
|
||||
per-file .gitignore=*
|
||||
per-file AUTHORS=*
|
||||
per-file BUILD.gn=kjellander@webrtc.org
|
||||
per-file DEPS=*
|
||||
per-file PRESUBMIT.py=kjellander@webrtc.org
|
||||
per-file setup_links.py=*
|
||||
per-file sync_chromium.py=kjellander@webrtc.org
|
||||
per-file WATCHLISTS=*
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
# TODO(kjellander): Rebase this to webrtc/build/common.gypi changes after r6330.
|
||||
|
||||
import("//build/config/arm.gni")
|
||||
import("//build/config/crypto.gni")
|
||||
import("//build/config/linux/pkg_config.gni")
|
||||
import("build/webrtc.gni")
|
||||
|
@ -84,10 +83,6 @@ config("common_config") {
|
|||
all_dependent_configs = [ "dbus-glib" ]
|
||||
}
|
||||
|
||||
if (rtc_enable_video) {
|
||||
defines += [ "WEBRTC_MODULE_UTILITY_VIDEO" ]
|
||||
}
|
||||
|
||||
if (build_with_chromium) {
|
||||
defines += [ "LOGGING_INSIDE_WEBRTC" ]
|
||||
} else {
|
||||
|
@ -98,7 +93,7 @@ config("common_config") {
|
|||
# expression" warning in android_tools/ndk_experimental"s version
|
||||
# of stlport.
|
||||
# See: https://code.google.com/p/chromium/issues/detail?id=379699
|
||||
if (cpu_arch != "arm64" || !is_android) {
|
||||
if (current_cpu != "arm64" || !is_android) {
|
||||
cflags = [
|
||||
"-Wextra",
|
||||
# We need to repeat some flags from Chromium"s common.gypi
|
||||
|
@ -120,46 +115,43 @@ config("common_config") {
|
|||
}
|
||||
}
|
||||
|
||||
if (cpu_arch == "arm64") {
|
||||
if (current_cpu == "arm64") {
|
||||
defines += [ "WEBRTC_ARCH_ARM" ]
|
||||
# TODO(zhongwei) Defining an unique WEBRTC_NEON and
|
||||
# distinguishing ARMv7 NEON and ARM64 NEON by
|
||||
# WEBRTC_ARCH_ARM_V7 and WEBRTC_ARCH_ARM64 should be better.
|
||||
|
||||
# This macro is used to distinguish ARMv7 NEON and ARM64 NEON
|
||||
defines += [ "WEBRTC_ARCH_ARM64_NEON" ]
|
||||
}
|
||||
|
||||
if (cpu_arch == "arm") {
|
||||
if (current_cpu == "arm") {
|
||||
defines += [ "WEBRTC_ARCH_ARM" ]
|
||||
if (arm_version == 7) {
|
||||
if (arm_version >= 7) {
|
||||
defines += [ "WEBRTC_ARCH_ARM_V7" ]
|
||||
if (arm_use_neon) {
|
||||
defines += [ "WEBRTC_ARCH_ARM_NEON" ]
|
||||
} else {
|
||||
} else if (is_android) {
|
||||
defines += [ "WEBRTC_DETECT_ARM_NEON" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cpu_arch == "mipsel") {
|
||||
if (current_cpu == "mipsel") {
|
||||
defines += [ "MIPS32_LE" ]
|
||||
if (mips_fpu) {
|
||||
if (mips_float_abi == "hard") {
|
||||
defines += [ "MIPS_FPU_LE" ]
|
||||
cflags += [ "-mhard-float" ]
|
||||
} else {
|
||||
cflags += [ "-msoft-float" ]
|
||||
}
|
||||
if (mips_arch_variant == "mips32r2") {
|
||||
if (mips_arch_variant == "r2") {
|
||||
defines += [ "MIPS32_R2_LE" ]
|
||||
cflags += [ "-mips32r2" ]
|
||||
cflags_cc += [ "-mips32r2" ]
|
||||
}
|
||||
if (mips_dsp_rev == 1) {
|
||||
defines += [ "MIPS_DSP_R1_LE" ]
|
||||
cflags += [ "-mdsp" ]
|
||||
cflags_cc += [ "-mdsp" ]
|
||||
} else if (mips_dsp_rev == 2) {
|
||||
defines += [
|
||||
"MIPS_DSP_R1_LE",
|
||||
"MIPS_DSP_R2_LE",
|
||||
]
|
||||
cflags += [ "-mdspr2" ]
|
||||
cflags_cc += [ "-mdspr2" ]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -178,7 +170,7 @@ config("common_config") {
|
|||
}
|
||||
}
|
||||
|
||||
static_library("webrtc") {
|
||||
source_set("webrtc") {
|
||||
sources = [
|
||||
"call.h",
|
||||
"config.h",
|
||||
|
@ -192,7 +184,7 @@ static_library("webrtc") {
|
|||
|
||||
deps = [
|
||||
":webrtc_common",
|
||||
"base:webrtc_base",
|
||||
"base:rtc_base",
|
||||
"common_audio",
|
||||
"common_video",
|
||||
"modules/audio_coding",
|
||||
|
@ -204,16 +196,21 @@ static_library("webrtc") {
|
|||
"modules/media_file",
|
||||
"modules/rtp_rtcp",
|
||||
"modules/utility",
|
||||
"modules/video_capture",
|
||||
"modules/video_coding",
|
||||
"modules/video_processing",
|
||||
"modules/video_render",
|
||||
"system_wrappers",
|
||||
"tools",
|
||||
"video",
|
||||
"video_engine",
|
||||
"voice_engine",
|
||||
]
|
||||
|
||||
if (build_with_chromium) {
|
||||
deps += [
|
||||
"modules/video_capture",
|
||||
"modules/video_render",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
if (!build_with_chromium) {
|
||||
|
@ -230,16 +227,20 @@ if (!build_with_chromium) {
|
|||
|
||||
source_set("webrtc_common") {
|
||||
sources = [
|
||||
"common_types.cc",
|
||||
"common_types.h",
|
||||
"config.h",
|
||||
"config.cc",
|
||||
"engine_configurations.h",
|
||||
"typedefs.h",
|
||||
]
|
||||
|
||||
if (is_clang) {
|
||||
# Suppress warnings from Chrome's Clang plugins.
|
||||
# See http://code.google.com/p/webrtc/issues/detail?id=163 for details.
|
||||
configs -= [ "//build/config/clang:find_bad_constructs" ]
|
||||
}
|
||||
|
||||
configs += [ ":common_config" ]
|
||||
public_configs = [ ":common_inherited_config" ]
|
||||
}
|
||||
|
||||
source_set("gtest_prod") {
|
||||
sources = [
|
||||
"test/testsupport/gtest_prod_util.h",
|
||||
]
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ This source tree contains third party source code which is governed by third
|
|||
party licenses. Paths to the files and associated licenses are collected here.
|
||||
|
||||
Files governed by third party licenses:
|
||||
common_audio/fft4g.c
|
||||
common_audio/signal_processing/spl_sqrt_floor.c
|
||||
common_audio/signal_processing/spl_sqrt_floor_arm.S
|
||||
modules/audio_coding/codecs/g711/main/source/g711.c
|
||||
|
@ -14,8 +15,6 @@ modules/audio_device/mac/portaudio/pa_memorybarrier.h
|
|||
modules/audio_device/mac/portaudio/pa_ringbuffer.c
|
||||
modules/audio_device/mac/portaudio/pa_ringbuffer.h
|
||||
modules/audio_processing/aec/aec_rdft.c
|
||||
modules/audio_processing/utility/fft4g.c
|
||||
system_wrappers/interface/scoped_ptr.h
|
||||
system_wrappers/source/condition_variable_event_win.cc
|
||||
system_wrappers/source/set_thread_name_win.h
|
||||
system_wrappers/source/spreadsortlib/constants.hpp
|
||||
|
@ -231,8 +230,8 @@ License:
|
|||
*/
|
||||
-------------------------------------------------------------------------------
|
||||
Files:
|
||||
common_audio/fft4g.c
|
||||
modules/audio_processing/aec/aec_rdft.c
|
||||
modules/audio_processing/utility/fft4g.c
|
||||
|
||||
License:
|
||||
/*
|
||||
|
@ -245,21 +244,6 @@ License:
|
|||
*/
|
||||
-------------------------------------------------------------------------------
|
||||
Files:
|
||||
system_wrappers/interface/scoped_ptr.h
|
||||
|
||||
License:
|
||||
// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999.
|
||||
// Copyright (c) 2001, 2002 Peter Dimov
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
// See http://www.boost.org/libs/smart_ptr/scoped_ptr.htm for documentation.
|
||||
//
|
||||
-------------------------------------------------------------------------------
|
||||
Files:
|
||||
system_wrappers/source/condition_variable_event_win.cc
|
||||
|
||||
Source:
|
||||
|
|
|
@ -10,7 +10,7 @@ import("//build/config/crypto.gni")
|
|||
import("//build/config/ui.gni")
|
||||
import("../build/webrtc.gni")
|
||||
|
||||
config("webrtc_base_config") {
|
||||
config("rtc_base_config") {
|
||||
include_dirs = [
|
||||
"//third_party/jsoncpp/overrides/include",
|
||||
"//third_party/jsoncpp/source/include",
|
||||
|
@ -19,15 +19,14 @@ config("webrtc_base_config") {
|
|||
defines = [
|
||||
"FEATURE_ENABLE_SSL",
|
||||
"LOGGING=1",
|
||||
"USE_WEBRTC_DEV_BRANCH",
|
||||
]
|
||||
|
||||
# TODO(henrike): issue 3307, make webrtc_base build without disabling
|
||||
# TODO(henrike): issue 3307, make rtc_base build without disabling
|
||||
# these flags.
|
||||
cflags_cc = [ "-Wno-non-virtual-dtor" ]
|
||||
}
|
||||
|
||||
config("webrtc_base_chromium_config") {
|
||||
config("rtc_base_chromium_config") {
|
||||
defines = [
|
||||
"NO_MAIN_THREAD_WRAPPING",
|
||||
]
|
||||
|
@ -49,7 +48,7 @@ config("nss_config") {
|
|||
}
|
||||
|
||||
config("ios_config") {
|
||||
ldflags = [
|
||||
libs = [
|
||||
#"Foundation.framework", # Already included in //build/config:default_libs.
|
||||
"Security.framework",
|
||||
"SystemConfiguration.framework",
|
||||
|
@ -58,7 +57,7 @@ config("ios_config") {
|
|||
}
|
||||
|
||||
config("mac_config") {
|
||||
ldflags = [
|
||||
libs = [
|
||||
"Cocoa.framework",
|
||||
#"Foundation.framework", # Already included in //build/config:default_libs.
|
||||
#"IOKit.framework", # Already included in //build/config:default_libs.
|
||||
|
@ -106,24 +105,36 @@ static_library("rtc_base_approved") {
|
|||
sources = [
|
||||
"checks.cc",
|
||||
"checks.h",
|
||||
"event.cc",
|
||||
"event.h",
|
||||
"event_tracer.cc",
|
||||
"event_tracer.h",
|
||||
"exp_filter.cc",
|
||||
"exp_filter.h",
|
||||
"md5.cc",
|
||||
"md5.h",
|
||||
"md5digest.cc",
|
||||
"md5digest.h",
|
||||
"platform_file.cc",
|
||||
"platform_file.h",
|
||||
"safe_conversions.h",
|
||||
"safe_conversions_impl.h",
|
||||
"stringencode.cc",
|
||||
"stringencode.h",
|
||||
"stringutils.cc",
|
||||
"stringutils.h",
|
||||
"template_util.h",
|
||||
"thread_annotations.h",
|
||||
"thread_checker.h",
|
||||
"thread_checker_impl.cc",
|
||||
"thread_checker_impl.h",
|
||||
"timeutils.cc",
|
||||
"timeutils.h",
|
||||
"trace_event.h",
|
||||
]
|
||||
}
|
||||
|
||||
static_library("webrtc_base") {
|
||||
static_library("rtc_base") {
|
||||
cflags = []
|
||||
cflags_cc = []
|
||||
libs = []
|
||||
|
@ -133,25 +144,28 @@ static_library("webrtc_base") {
|
|||
|
||||
configs += [
|
||||
"..:common_config",
|
||||
":webrtc_base_config",
|
||||
":rtc_base_config",
|
||||
]
|
||||
|
||||
public_configs = [
|
||||
"..:common_inherited_config",
|
||||
":webrtc_base_config",
|
||||
":rtc_base_config",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"LOGGING=1",
|
||||
"USE_WEBRTC_DEV_BRANCH",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"arraysize.h",
|
||||
"asyncfile.cc",
|
||||
"asyncfile.h",
|
||||
"asynchttprequest.cc",
|
||||
"asynchttprequest.h",
|
||||
"asyncpacketsocket.cc",
|
||||
"asyncpacketsocket.h",
|
||||
"asyncresolverinterface.cc",
|
||||
"asyncresolverinterface.h",
|
||||
"asyncsocket.cc",
|
||||
"asyncsocket.h",
|
||||
"asynctcpsocket.cc",
|
||||
|
@ -163,6 +177,8 @@ static_library("webrtc_base") {
|
|||
"base64.cc",
|
||||
"base64.h",
|
||||
"basicdefs.h",
|
||||
"buffer.cc",
|
||||
"buffer.h",
|
||||
"bytebuffer.cc",
|
||||
"bytebuffer.h",
|
||||
"byteorder.h",
|
||||
|
@ -172,18 +188,19 @@ static_library("webrtc_base") {
|
|||
"cpumonitor.h",
|
||||
"crc32.cc",
|
||||
"crc32.h",
|
||||
"criticalsection.cc",
|
||||
"criticalsection.h",
|
||||
"cryptstring.cc",
|
||||
"cryptstring.h",
|
||||
"diskcache.cc",
|
||||
"diskcache.h",
|
||||
"event.cc",
|
||||
"event.h",
|
||||
"fileutils.cc",
|
||||
"fileutils.h",
|
||||
"firewallsocketserver.cc",
|
||||
"firewallsocketserver.h",
|
||||
"flags.cc",
|
||||
"flags.h",
|
||||
"format_macros.h",
|
||||
"gunit_prod.h",
|
||||
"helpers.cc",
|
||||
"helpers.h",
|
||||
|
@ -224,16 +241,16 @@ static_library("webrtc_base") {
|
|||
"ratelimiter.h",
|
||||
"ratetracker.cc",
|
||||
"ratetracker.h",
|
||||
"safe_conversions.h",
|
||||
"safe_conversions_impl.h",
|
||||
"scoped_autorelease_pool.h",
|
||||
"scoped_autorelease_pool.mm",
|
||||
"scoped_ptr.h",
|
||||
"sha1.cc",
|
||||
"sha1.h",
|
||||
"sha1digest.cc",
|
||||
"sha1digest.h",
|
||||
"signalthread.cc",
|
||||
"signalthread.h",
|
||||
"sigslot.cc",
|
||||
"sigslot.h",
|
||||
"sigslotrepeater.h",
|
||||
"socket.h",
|
||||
|
@ -273,9 +290,6 @@ static_library("webrtc_base") {
|
|||
"taskrunner.h",
|
||||
"thread.cc",
|
||||
"thread.h",
|
||||
"thread_checker.h",
|
||||
"thread_checker_impl.cc",
|
||||
"thread_checker_impl.h",
|
||||
"timing.cc",
|
||||
"timing.h",
|
||||
"urlencode.cc",
|
||||
|
@ -299,6 +313,8 @@ static_library("webrtc_base") {
|
|||
"../overrides/webrtc/base/logging.h",
|
||||
]
|
||||
|
||||
deps += [ "..:webrtc_common" ]
|
||||
|
||||
if (is_win) {
|
||||
sources += [ "../overrides/webrtc/base/win32socketinit.cc" ]
|
||||
}
|
||||
|
@ -308,20 +324,18 @@ static_library("webrtc_base") {
|
|||
"../../boringssl/src/include",
|
||||
]
|
||||
|
||||
public_configs += [ ":webrtc_base_chromium_config" ]
|
||||
public_configs += [ ":rtc_base_chromium_config" ]
|
||||
} else {
|
||||
sources += [
|
||||
"asyncinvoker.cc",
|
||||
"asyncinvoker.h",
|
||||
"asyncinvoker-inl.h",
|
||||
"asyncresolverinterface.h",
|
||||
"atomicops.h",
|
||||
"bandwidthsmoother.cc",
|
||||
"bandwidthsmoother.h",
|
||||
"basictypes.h",
|
||||
"bind.h",
|
||||
"bind.h.pump",
|
||||
"buffer.h",
|
||||
"callback.h",
|
||||
"callback.h.pump",
|
||||
"constructormagic.h",
|
||||
|
@ -361,7 +375,6 @@ static_library("webrtc_base") {
|
|||
"sharedexclusivelock.h",
|
||||
"sslconfig.h",
|
||||
"sslroots.h",
|
||||
"stringdigest.h",
|
||||
"testclient.cc",
|
||||
"testclient.h",
|
||||
"transformadapter.cc",
|
||||
|
@ -375,6 +388,8 @@ static_library("webrtc_base") {
|
|||
"windowpicker.h",
|
||||
]
|
||||
|
||||
deps += [ "..:webrtc_common" ]
|
||||
|
||||
if (is_posix) {
|
||||
sources += [
|
||||
"latebindingsymboltable.cc",
|
||||
|
@ -433,18 +448,14 @@ static_library("webrtc_base") {
|
|||
}
|
||||
} # !build_with_chromium
|
||||
|
||||
if (is_clang) {
|
||||
# Suppress warnings from the Chrome Clang plugins.
|
||||
# See http://code.google.com/p/webrtc/issues/detail?id=163 for details.
|
||||
configs -= [ "//build/config/clang:find_bad_constructs" ]
|
||||
}
|
||||
|
||||
# TODO(henrike): issue 3307, make webrtc_base build with the Chromium default
|
||||
# TODO(henrike): issue 3307, make rtc_base build with the Chromium default
|
||||
# compiler settings.
|
||||
configs -= [ "//build/config/compiler:chromium_code" ]
|
||||
configs += [ "//build/config/compiler:no_chromium_code" ]
|
||||
cflags += [ "-Wno-uninitialized" ]
|
||||
cflags_cc += [ "-Wno-non-virtual-dtor" ]
|
||||
if (!is_win) {
|
||||
cflags += [ "-Wno-uninitialized" ]
|
||||
cflags_cc += [ "-Wno-non-virtual-dtor" ]
|
||||
}
|
||||
|
||||
if (use_openssl) {
|
||||
public_configs += [ ":openssl_config" ]
|
||||
|
@ -541,7 +552,7 @@ static_library("webrtc_base") {
|
|||
|
||||
all_dependent_configs = [ ":mac_config" ]
|
||||
|
||||
if (cpu_arch == "x86") {
|
||||
if (current_cpu == "x86") {
|
||||
all_dependent_configs += [ ":mac_x86_config" ]
|
||||
}
|
||||
}
|
||||
|
@ -587,7 +598,7 @@ static_library("webrtc_base") {
|
|||
defines += [ "_DEBUG" ]
|
||||
}
|
||||
|
||||
if (is_ios || (is_mac && cpu_arch != "x86")) {
|
||||
if (is_ios || (is_mac && current_cpu != "x86")) {
|
||||
defines += [ "CARBON_DEPRECATED=YES" ]
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
henrika@webrtc.org
|
||||
henrike@webrtc.org
|
||||
henrikg@webrtc.org
|
||||
hta@webrtc.org
|
||||
jiayl@webrtc.org
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2015 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_BASE_ARRAYSIZE_H_
|
||||
#define WEBRTC_BASE_ARRAYSIZE_H_
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
// This file defines the arraysize() macro and is derived from Chromium's
|
||||
// base/macros.h.
|
||||
|
||||
// The arraysize(arr) macro returns the # of elements in an array arr.
|
||||
// The expression is a compile-time constant, and therefore can be
|
||||
// used in defining new arrays, for example. If you use arraysize on
|
||||
// a pointer by mistake, you will get a compile-time error.
|
||||
|
||||
// This template function declaration is used in defining arraysize.
|
||||
// Note that the function doesn't need an implementation, as we only
|
||||
// use its type.
|
||||
template <typename T, size_t N>
|
||||
char (&ArraySizeHelper(T (&array)[N]))[N];
|
||||
|
||||
// That gcc wants both of these prototypes seems mysterious. VC, for
|
||||
// its part, can't decide which to use (another mystery). Matching of
|
||||
// template overloads: the final frontier.
|
||||
#ifndef _MSC_VER
|
||||
template <typename T, size_t N>
|
||||
char (&ArraySizeHelper(const T (&array)[N]))[N];
|
||||
#endif
|
||||
|
||||
#define arraysize(array) (sizeof(ArraySizeHelper(array)))
|
||||
|
||||
#endif // WEBRTC_BASE_ARRAYSIZE_H_
|
|
@ -91,7 +91,7 @@ void AsyncHttpRequest::DoWork() {
|
|||
// Do nothing while we wait for the request to finish. We only do this so
|
||||
// that we can be a SignalThread; in the future this class should not be
|
||||
// a SignalThread, since it does not need to spawn a new thread.
|
||||
Thread::Current()->ProcessMessages(kForever);
|
||||
Thread::Current()->ProcessMessages(Thread::kForever);
|
||||
}
|
||||
|
||||
void AsyncHttpRequest::LaunchRequest() {
|
||||
|
|
|
@ -31,7 +31,7 @@ class FirewallManager;
|
|||
class AsyncHttpRequest : public SignalThread {
|
||||
public:
|
||||
explicit AsyncHttpRequest(const std::string &user_agent);
|
||||
~AsyncHttpRequest();
|
||||
~AsyncHttpRequest() override;
|
||||
|
||||
// If start_delay is less than or equal to zero, this starts immediately.
|
||||
// Start_delay defaults to zero.
|
||||
|
@ -75,11 +75,11 @@ class AsyncHttpRequest : public SignalThread {
|
|||
|
||||
protected:
|
||||
void set_error(HttpErrorType error) { error_ = error; }
|
||||
virtual void OnWorkStart();
|
||||
virtual void OnWorkStop();
|
||||
void OnWorkStart() override;
|
||||
void OnWorkStop() override;
|
||||
void OnComplete(HttpClient* client, HttpErrorType error);
|
||||
virtual void OnMessage(Message* message);
|
||||
virtual void DoWork();
|
||||
void OnMessage(Message* message) override;
|
||||
void DoWork() override;
|
||||
|
||||
private:
|
||||
void LaunchRequest();
|
||||
|
|
|
@ -29,10 +29,11 @@ class AsyncInvoker;
|
|||
// lifetime can be independent of AsyncInvoker.
|
||||
class AsyncClosure : public RefCountInterface {
|
||||
public:
|
||||
virtual ~AsyncClosure() {}
|
||||
// Runs the asynchronous task, and triggers a callback to the calling
|
||||
// thread if needed. Should be called from the target thread.
|
||||
virtual void Execute() = 0;
|
||||
protected:
|
||||
~AsyncClosure() override {}
|
||||
};
|
||||
|
||||
// Simple closure that doesn't trigger a callback for the calling thread.
|
||||
|
@ -54,7 +55,7 @@ class FireAndForgetAsyncClosure : public AsyncClosure {
|
|||
class NotifyingAsyncClosureBase : public AsyncClosure,
|
||||
public sigslot::has_slots<> {
|
||||
public:
|
||||
virtual ~NotifyingAsyncClosureBase() { disconnect_all(); }
|
||||
~NotifyingAsyncClosureBase() override;
|
||||
|
||||
protected:
|
||||
NotifyingAsyncClosureBase(AsyncInvoker* invoker, Thread* calling_thread);
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
#include "webrtc/base/asyncinvoker.h"
|
||||
|
||||
#include "webrtc/base/logging.h"
|
||||
|
||||
namespace rtc {
|
||||
|
||||
AsyncInvoker::AsyncInvoker() : destroying_(false) {}
|
||||
|
@ -52,12 +54,11 @@ void AsyncInvoker::Flush(Thread* thread, uint32 id /*= MQID_ANY*/) {
|
|||
}
|
||||
}
|
||||
|
||||
void AsyncInvoker::DoInvoke(Thread* thread, AsyncClosure* closure,
|
||||
void AsyncInvoker::DoInvoke(Thread* thread,
|
||||
const scoped_refptr<AsyncClosure>& closure,
|
||||
uint32 id) {
|
||||
if (destroying_) {
|
||||
LOG(LS_WARNING) << "Tried to invoke while destroying the invoker.";
|
||||
// Since this call transwers ownership of |closure|, we clean it up here.
|
||||
delete closure;
|
||||
return;
|
||||
}
|
||||
thread->Post(this, id, new ScopedRefMessageData<AsyncClosure>(closure));
|
||||
|
@ -72,6 +73,10 @@ NotifyingAsyncClosureBase::NotifyingAsyncClosureBase(AsyncInvoker* invoker,
|
|||
this, &NotifyingAsyncClosureBase::CancelCallback);
|
||||
}
|
||||
|
||||
NotifyingAsyncClosureBase::~NotifyingAsyncClosureBase() {
|
||||
disconnect_all();
|
||||
}
|
||||
|
||||
void NotifyingAsyncClosureBase::TriggerCallback() {
|
||||
CritScope cs(&crit_);
|
||||
if (!CallbackCanceled() && !callback_.empty()) {
|
||||
|
|
|
@ -69,7 +69,7 @@ namespace rtc {
|
|||
class AsyncInvoker : public MessageHandler {
|
||||
public:
|
||||
AsyncInvoker();
|
||||
virtual ~AsyncInvoker();
|
||||
~AsyncInvoker() override;
|
||||
|
||||
// Call |functor| asynchronously on |thread|, with no callback upon
|
||||
// completion. Returns immediately.
|
||||
|
@ -77,8 +77,8 @@ class AsyncInvoker : public MessageHandler {
|
|||
void AsyncInvoke(Thread* thread,
|
||||
const FunctorT& functor,
|
||||
uint32 id = 0) {
|
||||
AsyncClosure* closure =
|
||||
new RefCountedObject<FireAndForgetAsyncClosure<FunctorT> >(functor);
|
||||
scoped_refptr<AsyncClosure> closure(
|
||||
new RefCountedObject<FireAndForgetAsyncClosure<FunctorT> >(functor));
|
||||
DoInvoke(thread, closure, id);
|
||||
}
|
||||
|
||||
|
@ -89,9 +89,9 @@ class AsyncInvoker : public MessageHandler {
|
|||
void (HostT::*callback)(ReturnT),
|
||||
HostT* callback_host,
|
||||
uint32 id = 0) {
|
||||
AsyncClosure* closure =
|
||||
scoped_refptr<AsyncClosure> closure(
|
||||
new RefCountedObject<NotifyingAsyncClosure<ReturnT, FunctorT, HostT> >(
|
||||
this, Thread::Current(), functor, callback, callback_host);
|
||||
this, Thread::Current(), functor, callback, callback_host));
|
||||
DoInvoke(thread, closure, id);
|
||||
}
|
||||
|
||||
|
@ -103,9 +103,9 @@ class AsyncInvoker : public MessageHandler {
|
|||
void (HostT::*callback)(),
|
||||
HostT* callback_host,
|
||||
uint32 id = 0) {
|
||||
AsyncClosure* closure =
|
||||
scoped_refptr<AsyncClosure> closure(
|
||||
new RefCountedObject<NotifyingAsyncClosure<void, FunctorT, HostT> >(
|
||||
this, Thread::Current(), functor, callback, callback_host);
|
||||
this, Thread::Current(), functor, callback, callback_host));
|
||||
DoInvoke(thread, closure, id);
|
||||
}
|
||||
|
||||
|
@ -120,8 +120,9 @@ class AsyncInvoker : public MessageHandler {
|
|||
sigslot::signal0<> SignalInvokerDestroyed;
|
||||
|
||||
private:
|
||||
virtual void OnMessage(Message* msg);
|
||||
void DoInvoke(Thread* thread, AsyncClosure* closure, uint32 id);
|
||||
void OnMessage(Message* msg) override;
|
||||
void DoInvoke(Thread* thread, const scoped_refptr<AsyncClosure>& closure,
|
||||
uint32 id);
|
||||
|
||||
bool destroying_;
|
||||
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright 2015 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.
|
||||
*/
|
||||
|
||||
#include "webrtc/base/asyncpacketsocket.h"
|
||||
|
||||
namespace rtc {
|
||||
|
||||
PacketTimeUpdateParams::PacketTimeUpdateParams()
|
||||
: rtp_sendtime_extension_id(-1),
|
||||
srtp_auth_tag_len(-1),
|
||||
srtp_packet_index(-1) {
|
||||
}
|
||||
|
||||
PacketTimeUpdateParams::~PacketTimeUpdateParams() = default;
|
||||
|
||||
AsyncPacketSocket::AsyncPacketSocket() {
|
||||
}
|
||||
|
||||
AsyncPacketSocket::~AsyncPacketSocket() {
|
||||
}
|
||||
|
||||
}; // namespace rtc
|
|
@ -22,10 +22,8 @@ namespace rtc {
|
|||
// extension, including the information needed to update the authentication tag
|
||||
// after changing the value.
|
||||
struct PacketTimeUpdateParams {
|
||||
PacketTimeUpdateParams()
|
||||
: rtp_sendtime_extension_id(-1), srtp_auth_tag_len(-1),
|
||||
srtp_packet_index(-1) {
|
||||
}
|
||||
PacketTimeUpdateParams();
|
||||
~PacketTimeUpdateParams();
|
||||
|
||||
int rtp_sendtime_extension_id; // extension header id present in packet.
|
||||
std::vector<char> srtp_auth_key; // Authentication key.
|
||||
|
@ -75,8 +73,8 @@ class AsyncPacketSocket : public sigslot::has_slots<> {
|
|||
STATE_CONNECTED
|
||||
};
|
||||
|
||||
AsyncPacketSocket() { }
|
||||
virtual ~AsyncPacketSocket() { }
|
||||
AsyncPacketSocket();
|
||||
~AsyncPacketSocket() override;
|
||||
|
||||
// Returns current local address. Address may be set to NULL if the
|
||||
// socket is not bound yet (GetState() returns STATE_BINDING).
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Copyright 2015 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.
|
||||
*/
|
||||
|
||||
#include "webrtc/base/asyncresolverinterface.h"
|
||||
|
||||
namespace rtc {
|
||||
|
||||
AsyncResolverInterface::AsyncResolverInterface() {
|
||||
}
|
||||
|
||||
AsyncResolverInterface::~AsyncResolverInterface() = default;
|
||||
|
||||
}; // namespace rtc
|
|
@ -19,8 +19,8 @@ namespace rtc {
|
|||
// This interface defines the methods to resolve the address asynchronously.
|
||||
class AsyncResolverInterface {
|
||||
public:
|
||||
AsyncResolverInterface() {}
|
||||
virtual ~AsyncResolverInterface() {}
|
||||
AsyncResolverInterface();
|
||||
virtual ~AsyncResolverInterface();
|
||||
|
||||
// Start address resolve process.
|
||||
virtual void Start(const SocketAddress& addr) = 0;
|
||||
|
|
|
@ -31,14 +31,97 @@ void AsyncSocketAdapter::Attach(AsyncSocket* socket) {
|
|||
socket_ = socket;
|
||||
if (socket_) {
|
||||
socket_->SignalConnectEvent.connect(this,
|
||||
&AsyncSocketAdapter::OnConnectEvent);
|
||||
socket_->SignalReadEvent.connect(this,
|
||||
&AsyncSocketAdapter::OnReadEvent);
|
||||
socket_->SignalWriteEvent.connect(this,
|
||||
&AsyncSocketAdapter::OnWriteEvent);
|
||||
socket_->SignalCloseEvent.connect(this,
|
||||
&AsyncSocketAdapter::OnCloseEvent);
|
||||
&AsyncSocketAdapter::OnConnectEvent);
|
||||
socket_->SignalReadEvent.connect(this, &AsyncSocketAdapter::OnReadEvent);
|
||||
socket_->SignalWriteEvent.connect(this, &AsyncSocketAdapter::OnWriteEvent);
|
||||
socket_->SignalCloseEvent.connect(this, &AsyncSocketAdapter::OnCloseEvent);
|
||||
}
|
||||
}
|
||||
|
||||
SocketAddress AsyncSocketAdapter::GetLocalAddress() const {
|
||||
return socket_->GetLocalAddress();
|
||||
}
|
||||
|
||||
SocketAddress AsyncSocketAdapter::GetRemoteAddress() const {
|
||||
return socket_->GetRemoteAddress();
|
||||
}
|
||||
|
||||
int AsyncSocketAdapter::Bind(const SocketAddress& addr) {
|
||||
return socket_->Bind(addr);
|
||||
}
|
||||
|
||||
int AsyncSocketAdapter::Connect(const SocketAddress& addr) {
|
||||
return socket_->Connect(addr);
|
||||
}
|
||||
|
||||
int AsyncSocketAdapter::Send(const void* pv, size_t cb) {
|
||||
return socket_->Send(pv, cb);
|
||||
}
|
||||
|
||||
int AsyncSocketAdapter::SendTo(const void* pv,
|
||||
size_t cb,
|
||||
const SocketAddress& addr) {
|
||||
return socket_->SendTo(pv, cb, addr);
|
||||
}
|
||||
|
||||
int AsyncSocketAdapter::Recv(void* pv, size_t cb) {
|
||||
return socket_->Recv(pv, cb);
|
||||
}
|
||||
|
||||
int AsyncSocketAdapter::RecvFrom(void* pv, size_t cb, SocketAddress* paddr) {
|
||||
return socket_->RecvFrom(pv, cb, paddr);
|
||||
}
|
||||
|
||||
int AsyncSocketAdapter::Listen(int backlog) {
|
||||
return socket_->Listen(backlog);
|
||||
}
|
||||
|
||||
AsyncSocket* AsyncSocketAdapter::Accept(SocketAddress* paddr) {
|
||||
return socket_->Accept(paddr);
|
||||
}
|
||||
|
||||
int AsyncSocketAdapter::Close() {
|
||||
return socket_->Close();
|
||||
}
|
||||
|
||||
int AsyncSocketAdapter::GetError() const {
|
||||
return socket_->GetError();
|
||||
}
|
||||
|
||||
void AsyncSocketAdapter::SetError(int error) {
|
||||
return socket_->SetError(error);
|
||||
}
|
||||
|
||||
AsyncSocket::ConnState AsyncSocketAdapter::GetState() const {
|
||||
return socket_->GetState();
|
||||
}
|
||||
|
||||
int AsyncSocketAdapter::EstimateMTU(uint16* mtu) {
|
||||
return socket_->EstimateMTU(mtu);
|
||||
}
|
||||
|
||||
int AsyncSocketAdapter::GetOption(Option opt, int* value) {
|
||||
return socket_->GetOption(opt, value);
|
||||
}
|
||||
|
||||
int AsyncSocketAdapter::SetOption(Option opt, int value) {
|
||||
return socket_->SetOption(opt, value);
|
||||
}
|
||||
|
||||
void AsyncSocketAdapter::OnConnectEvent(AsyncSocket* socket) {
|
||||
SignalConnectEvent(this);
|
||||
}
|
||||
|
||||
void AsyncSocketAdapter::OnReadEvent(AsyncSocket* socket) {
|
||||
SignalReadEvent(this);
|
||||
}
|
||||
|
||||
void AsyncSocketAdapter::OnWriteEvent(AsyncSocket* socket) {
|
||||
SignalWriteEvent(this);
|
||||
}
|
||||
|
||||
void AsyncSocketAdapter::OnCloseEvent(AsyncSocket* socket, int err) {
|
||||
SignalCloseEvent(this, err);
|
||||
}
|
||||
|
||||
} // namespace rtc
|
||||
|
|
|
@ -23,9 +23,9 @@ namespace rtc {
|
|||
class AsyncSocket : public Socket {
|
||||
public:
|
||||
AsyncSocket();
|
||||
virtual ~AsyncSocket();
|
||||
~AsyncSocket() override;
|
||||
|
||||
virtual AsyncSocket* Accept(SocketAddress* paddr) = 0;
|
||||
AsyncSocket* Accept(SocketAddress* paddr) override = 0;
|
||||
|
||||
// SignalReadEvent and SignalWriteEvent use multi_threaded_local to allow
|
||||
// access concurrently from different thread.
|
||||
|
@ -48,73 +48,31 @@ class AsyncSocketAdapter : public AsyncSocket, public sigslot::has_slots<> {
|
|||
// that will be called during the detached period (usually GetState()), to
|
||||
// avoid dereferencing a null pointer.
|
||||
explicit AsyncSocketAdapter(AsyncSocket* socket);
|
||||
virtual ~AsyncSocketAdapter();
|
||||
~AsyncSocketAdapter() override;
|
||||
void Attach(AsyncSocket* socket);
|
||||
virtual SocketAddress GetLocalAddress() const {
|
||||
return socket_->GetLocalAddress();
|
||||
}
|
||||
virtual SocketAddress GetRemoteAddress() const {
|
||||
return socket_->GetRemoteAddress();
|
||||
}
|
||||
virtual int Bind(const SocketAddress& addr) {
|
||||
return socket_->Bind(addr);
|
||||
}
|
||||
virtual int Connect(const SocketAddress& addr) {
|
||||
return socket_->Connect(addr);
|
||||
}
|
||||
virtual int Send(const void* pv, size_t cb) {
|
||||
return socket_->Send(pv, cb);
|
||||
}
|
||||
virtual int SendTo(const void* pv, size_t cb, const SocketAddress& addr) {
|
||||
return socket_->SendTo(pv, cb, addr);
|
||||
}
|
||||
virtual int Recv(void* pv, size_t cb) {
|
||||
return socket_->Recv(pv, cb);
|
||||
}
|
||||
virtual int RecvFrom(void* pv, size_t cb, SocketAddress* paddr) {
|
||||
return socket_->RecvFrom(pv, cb, paddr);
|
||||
}
|
||||
virtual int Listen(int backlog) {
|
||||
return socket_->Listen(backlog);
|
||||
}
|
||||
virtual AsyncSocket* Accept(SocketAddress* paddr) {
|
||||
return socket_->Accept(paddr);
|
||||
}
|
||||
virtual int Close() {
|
||||
return socket_->Close();
|
||||
}
|
||||
virtual int GetError() const {
|
||||
return socket_->GetError();
|
||||
}
|
||||
virtual void SetError(int error) {
|
||||
return socket_->SetError(error);
|
||||
}
|
||||
virtual ConnState GetState() const {
|
||||
return socket_->GetState();
|
||||
}
|
||||
virtual int EstimateMTU(uint16* mtu) {
|
||||
return socket_->EstimateMTU(mtu);
|
||||
}
|
||||
virtual int GetOption(Option opt, int* value) {
|
||||
return socket_->GetOption(opt, value);
|
||||
}
|
||||
virtual int SetOption(Option opt, int value) {
|
||||
return socket_->SetOption(opt, value);
|
||||
}
|
||||
SocketAddress GetLocalAddress() const override;
|
||||
SocketAddress GetRemoteAddress() const override;
|
||||
int Bind(const SocketAddress& addr) override;
|
||||
int Connect(const SocketAddress& addr) override;
|
||||
int Send(const void* pv, size_t cb) override;
|
||||
int SendTo(const void* pv, size_t cb, const SocketAddress& addr) override;
|
||||
int Recv(void* pv, size_t cb) override;
|
||||
int RecvFrom(void* pv, size_t cb, SocketAddress* paddr) override;
|
||||
int Listen(int backlog) override;
|
||||
AsyncSocket* Accept(SocketAddress* paddr) override;
|
||||
int Close() override;
|
||||
int GetError() const override;
|
||||
void SetError(int error) override;
|
||||
ConnState GetState() const override;
|
||||
int EstimateMTU(uint16* mtu) override;
|
||||
int GetOption(Option opt, int* value) override;
|
||||
int SetOption(Option opt, int value) override;
|
||||
|
||||
protected:
|
||||
virtual void OnConnectEvent(AsyncSocket* socket) {
|
||||
SignalConnectEvent(this);
|
||||
}
|
||||
virtual void OnReadEvent(AsyncSocket* socket) {
|
||||
SignalReadEvent(this);
|
||||
}
|
||||
virtual void OnWriteEvent(AsyncSocket* socket) {
|
||||
SignalWriteEvent(this);
|
||||
}
|
||||
virtual void OnCloseEvent(AsyncSocket* socket, int err) {
|
||||
SignalCloseEvent(this, err);
|
||||
}
|
||||
virtual void OnConnectEvent(AsyncSocket* socket);
|
||||
virtual void OnReadEvent(AsyncSocket* socket);
|
||||
virtual void OnWriteEvent(AsyncSocket* socket);
|
||||
virtual void OnCloseEvent(AsyncSocket* socket, int err);
|
||||
|
||||
AsyncSocket* socket_;
|
||||
};
|
||||
|
|
|
@ -23,26 +23,28 @@ namespace rtc {
|
|||
class AsyncTCPSocketBase : public AsyncPacketSocket {
|
||||
public:
|
||||
AsyncTCPSocketBase(AsyncSocket* socket, bool listen, size_t max_packet_size);
|
||||
virtual ~AsyncTCPSocketBase();
|
||||
~AsyncTCPSocketBase() override;
|
||||
|
||||
// Pure virtual methods to send and recv data.
|
||||
virtual int Send(const void *pv, size_t cb,
|
||||
const rtc::PacketOptions& options) = 0;
|
||||
int Send(const void *pv, size_t cb,
|
||||
const rtc::PacketOptions& options) override = 0;
|
||||
virtual void ProcessInput(char* data, size_t* len) = 0;
|
||||
// Signals incoming connection.
|
||||
virtual void HandleIncomingConnection(AsyncSocket* socket) = 0;
|
||||
|
||||
virtual SocketAddress GetLocalAddress() const;
|
||||
virtual SocketAddress GetRemoteAddress() const;
|
||||
virtual int SendTo(const void *pv, size_t cb, const SocketAddress& addr,
|
||||
const rtc::PacketOptions& options);
|
||||
virtual int Close();
|
||||
SocketAddress GetLocalAddress() const override;
|
||||
SocketAddress GetRemoteAddress() const override;
|
||||
int SendTo(const void* pv,
|
||||
size_t cb,
|
||||
const SocketAddress& addr,
|
||||
const rtc::PacketOptions& options) override;
|
||||
int Close() override;
|
||||
|
||||
virtual State GetState() const;
|
||||
virtual int GetOption(Socket::Option opt, int* value);
|
||||
virtual int SetOption(Socket::Option opt, int value);
|
||||
virtual int GetError() const;
|
||||
virtual void SetError(int error);
|
||||
State GetState() const override;
|
||||
int GetOption(Socket::Option opt, int* value) override;
|
||||
int SetOption(Socket::Option opt, int value) override;
|
||||
int GetError() const override;
|
||||
void SetError(int error) override;
|
||||
|
||||
protected:
|
||||
// Binds and connects |socket| and creates AsyncTCPSocket for
|
||||
|
@ -84,12 +86,13 @@ class AsyncTCPSocket : public AsyncTCPSocketBase {
|
|||
const SocketAddress& bind_address,
|
||||
const SocketAddress& remote_address);
|
||||
AsyncTCPSocket(AsyncSocket* socket, bool listen);
|
||||
virtual ~AsyncTCPSocket() {}
|
||||
~AsyncTCPSocket() override {}
|
||||
|
||||
virtual int Send(const void* pv, size_t cb,
|
||||
const rtc::PacketOptions& options);
|
||||
virtual void ProcessInput(char* data, size_t* len);
|
||||
virtual void HandleIncomingConnection(AsyncSocket* socket);
|
||||
int Send(const void* pv,
|
||||
size_t cb,
|
||||
const rtc::PacketOptions& options) override;
|
||||
void ProcessInput(char* data, size_t* len) override;
|
||||
void HandleIncomingConnection(AsyncSocket* socket) override;
|
||||
|
||||
private:
|
||||
DISALLOW_EVIL_CONSTRUCTORS(AsyncTCPSocket);
|
||||
|
|
|
@ -31,21 +31,24 @@ class AsyncUDPSocket : public AsyncPacketSocket {
|
|||
static AsyncUDPSocket* Create(SocketFactory* factory,
|
||||
const SocketAddress& bind_address);
|
||||
explicit AsyncUDPSocket(AsyncSocket* socket);
|
||||
virtual ~AsyncUDPSocket();
|
||||
~AsyncUDPSocket() override;
|
||||
|
||||
virtual SocketAddress GetLocalAddress() const;
|
||||
virtual SocketAddress GetRemoteAddress() const;
|
||||
virtual int Send(const void *pv, size_t cb,
|
||||
const rtc::PacketOptions& options);
|
||||
virtual int SendTo(const void *pv, size_t cb, const SocketAddress& addr,
|
||||
const rtc::PacketOptions& options);
|
||||
virtual int Close();
|
||||
SocketAddress GetLocalAddress() const override;
|
||||
SocketAddress GetRemoteAddress() const override;
|
||||
int Send(const void* pv,
|
||||
size_t cb,
|
||||
const rtc::PacketOptions& options) override;
|
||||
int SendTo(const void* pv,
|
||||
size_t cb,
|
||||
const SocketAddress& addr,
|
||||
const rtc::PacketOptions& options) override;
|
||||
int Close() override;
|
||||
|
||||
virtual State GetState() const;
|
||||
virtual int GetOption(Socket::Option opt, int* value);
|
||||
virtual int SetOption(Socket::Option opt, int value);
|
||||
virtual int GetError() const;
|
||||
virtual void SetError(int error);
|
||||
State GetState() const override;
|
||||
int GetOption(Socket::Option opt, int* value) override;
|
||||
int SetOption(Socket::Option opt, int value) override;
|
||||
int GetError() const override;
|
||||
void SetError(int error) override;
|
||||
|
||||
private:
|
||||
// Called when the underlying socket is ready to be read from.
|
||||
|
|
|
@ -32,6 +32,12 @@ AutoDetectProxy::AutoDetectProxy(const std::string& user_agent)
|
|||
: agent_(user_agent), resolver_(NULL), socket_(NULL), next_(0) {
|
||||
}
|
||||
|
||||
bool AutoDetectProxy::GetProxyForUrl(const char* agent,
|
||||
const char* url,
|
||||
rtc::ProxyInfo* proxy) {
|
||||
return GetProxySettingsForUrl(agent, url, proxy, true);
|
||||
}
|
||||
|
||||
AutoDetectProxy::~AutoDetectProxy() {
|
||||
if (resolver_) {
|
||||
resolver_->Destroy(false);
|
||||
|
@ -55,7 +61,7 @@ void AutoDetectProxy::DoWork() {
|
|||
LOG(LS_INFO) << "AutoDetectProxy initiating proxy classification";
|
||||
Next();
|
||||
// Process I/O until Stop()
|
||||
Thread::Current()->ProcessMessages(kForever);
|
||||
Thread::Current()->ProcessMessages(Thread::kForever);
|
||||
// Clean up the autodetect socket, from the thread that created it
|
||||
delete socket_;
|
||||
}
|
||||
|
|
|
@ -50,20 +50,19 @@ class AutoDetectProxy : public SignalThread {
|
|||
}
|
||||
// Default implementation of GetProxySettingsForUrl. Override for special
|
||||
// implementation.
|
||||
virtual bool GetProxyForUrl(const char* agent, const char* url,
|
||||
rtc::ProxyInfo* proxy) {
|
||||
return GetProxySettingsForUrl(agent, url, proxy, true);
|
||||
}
|
||||
virtual bool GetProxyForUrl(const char* agent,
|
||||
const char* url,
|
||||
rtc::ProxyInfo* proxy);
|
||||
enum { MSG_TIMEOUT = SignalThread::ST_MSG_FIRST_AVAILABLE,
|
||||
MSG_UNRESOLVABLE,
|
||||
ADP_MSG_FIRST_AVAILABLE};
|
||||
|
||||
protected:
|
||||
virtual ~AutoDetectProxy();
|
||||
~AutoDetectProxy() override;
|
||||
|
||||
// SignalThread Interface
|
||||
virtual void DoWork();
|
||||
virtual void OnMessage(Message *msg);
|
||||
void DoWork() override;
|
||||
void OnMessage(Message* msg) override;
|
||||
|
||||
void Next();
|
||||
void Complete(ProxyType type);
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "webrtc/base/bandwidthsmoother.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <algorithm>
|
||||
|
||||
namespace rtc {
|
||||
|
||||
|
@ -20,15 +21,16 @@ BandwidthSmoother::BandwidthSmoother(int initial_bandwidth_guess,
|
|||
size_t samples_count_to_average,
|
||||
double min_sample_count_percent)
|
||||
: time_between_increase_(time_between_increase),
|
||||
percent_increase_(rtc::_max(1.0, percent_increase)),
|
||||
percent_increase_(std::max(1.0, percent_increase)),
|
||||
time_at_last_change_(0),
|
||||
bandwidth_estimation_(initial_bandwidth_guess),
|
||||
accumulator_(samples_count_to_average),
|
||||
min_sample_count_percent_(
|
||||
rtc::_min(1.0,
|
||||
rtc::_max(0.0, min_sample_count_percent))) {
|
||||
std::min(1.0, std::max(0.0, min_sample_count_percent))) {
|
||||
}
|
||||
|
||||
BandwidthSmoother::~BandwidthSmoother() = default;
|
||||
|
||||
// Samples a new bandwidth measurement
|
||||
// returns true if the bandwidth estimation changed
|
||||
bool BandwidthSmoother::Sample(uint32 sample_time, int bandwidth) {
|
||||
|
|
|
@ -35,6 +35,7 @@ class BandwidthSmoother {
|
|||
double percent_increase,
|
||||
size_t samples_count_to_average,
|
||||
double min_sample_count_percent);
|
||||
~BandwidthSmoother();
|
||||
|
||||
// Samples a new bandwidth measurement.
|
||||
// bandwidth is expected to be non-negative.
|
||||
|
|
|
@ -24,16 +24,6 @@
|
|||
}],
|
||||
],
|
||||
'targets': [
|
||||
{
|
||||
# Temporary target until Chromium's
|
||||
# src/third_party/libjingle/libjingle.gyp is updated to use rtc_base.
|
||||
# TODO(kjellander): Remove when r7140 is rolled into Chromium's DEPS.
|
||||
'target_name': 'webrtc_base',
|
||||
'type': 'none',
|
||||
'dependencies': [
|
||||
'rtc_base',
|
||||
],
|
||||
},
|
||||
{
|
||||
# The subset of rtc_base approved for use outside of libjingle.
|
||||
'target_name': 'rtc_base_approved',
|
||||
|
@ -41,45 +31,47 @@
|
|||
'sources': [
|
||||
'checks.cc',
|
||||
'checks.h',
|
||||
# Moved by mozilla
|
||||
# 'common.cc',
|
||||
# 'common.h',
|
||||
'event.cc',
|
||||
'event.h',
|
||||
'event_tracer.cc',
|
||||
'event_tracer.h',
|
||||
'exp_filter.cc',
|
||||
'exp_filter.h',
|
||||
'md5.cc',
|
||||
'md5.h',
|
||||
'md5digest.cc',
|
||||
'md5digest.h',
|
||||
'platform_file.cc',
|
||||
'platform_file.h',
|
||||
'safe_conversions.h',
|
||||
'safe_conversions_impl.h',
|
||||
'stringencode.cc',
|
||||
'stringencode.h',
|
||||
'stringutils.cc',
|
||||
'stringutils.h',
|
||||
'template_util.h',
|
||||
'thread_annotations.h',
|
||||
'thread_checker.h',
|
||||
'thread_checker_impl.cc',
|
||||
'thread_checker_impl.h',
|
||||
'timeutils.cc',
|
||||
'timeutils.h',
|
||||
],
|
||||
'conditions': [
|
||||
['OS=="mac"', {
|
||||
'sources': [
|
||||
'macutils.cc',
|
||||
'macutils.h',
|
||||
],
|
||||
}],
|
||||
'trace_event.h',
|
||||
],
|
||||
},
|
||||
{
|
||||
'target_name': 'rtc_base',
|
||||
'type': 'static_library',
|
||||
'dependencies': [
|
||||
'<(webrtc_root)/common.gyp:webrtc_common',
|
||||
'rtc_base_approved',
|
||||
],
|
||||
'defines': [
|
||||
'FEATURE_ENABLE_SSL',
|
||||
'LOGGING=1',
|
||||
'USE_WEBRTC_DEV_BRANCH',
|
||||
],
|
||||
'sources': [
|
||||
'arraysize.h',
|
||||
'asyncfile.cc',
|
||||
'asyncfile.h',
|
||||
'asynchttprequest.cc',
|
||||
|
@ -87,7 +79,9 @@
|
|||
'asyncinvoker.cc',
|
||||
'asyncinvoker.h',
|
||||
'asyncinvoker-inl.h',
|
||||
'asyncpacketsocket.cc',
|
||||
'asyncpacketsocket.h',
|
||||
'asyncresolverinterface.cc',
|
||||
'asyncresolverinterface.h',
|
||||
'asyncsocket.cc',
|
||||
'asyncsocket.h',
|
||||
|
@ -105,13 +99,14 @@
|
|||
'basicdefs.h',
|
||||
'basictypes.h',
|
||||
'bind.h',
|
||||
# 'bind.h.pump',
|
||||
'bind.h.pump',
|
||||
'buffer.cc',
|
||||
'buffer.h',
|
||||
'bytebuffer.cc',
|
||||
'bytebuffer.h',
|
||||
'byteorder.h',
|
||||
'callback.h',
|
||||
# 'callback.h.pump',
|
||||
'callback.h.pump',
|
||||
'constructormagic.h',
|
||||
'common.cc',
|
||||
'common.h',
|
||||
|
@ -119,7 +114,9 @@
|
|||
'cpumonitor.h',
|
||||
'crc32.cc',
|
||||
'crc32.h',
|
||||
'criticalsection.cc',
|
||||
'criticalsection.h',
|
||||
'cryptstring.cc',
|
||||
'cryptstring.h',
|
||||
'dbus.cc',
|
||||
'dbus.h',
|
||||
|
@ -127,8 +124,6 @@
|
|||
'diskcache.h',
|
||||
'diskcache_win32.cc',
|
||||
'diskcache_win32.h',
|
||||
'event.cc',
|
||||
'event.h',
|
||||
'filelock.cc',
|
||||
'filelock.h',
|
||||
'fileutils.cc',
|
||||
|
@ -138,6 +133,7 @@
|
|||
'firewallsocketserver.h',
|
||||
'flags.cc',
|
||||
'flags.h',
|
||||
'format_macros.h',
|
||||
'gunit_prod.h',
|
||||
'helpers.cc',
|
||||
'helpers.h',
|
||||
|
@ -160,9 +156,9 @@
|
|||
'json.cc',
|
||||
'json.h',
|
||||
'latebindingsymboltable.cc',
|
||||
# 'latebindingsymboltable.cc.def',
|
||||
'latebindingsymboltable.cc.def',
|
||||
'latebindingsymboltable.h',
|
||||
# 'latebindingsymboltable.h.def',
|
||||
'latebindingsymboltable.h.def',
|
||||
'libdbusglibsymboltable.cc',
|
||||
'libdbusglibsymboltable.h',
|
||||
'linux.cc',
|
||||
|
@ -182,9 +178,8 @@
|
|||
'macconversion.h',
|
||||
'macsocketserver.cc',
|
||||
'macsocketserver.h',
|
||||
# moved by mozilla
|
||||
# 'macutils.cc',
|
||||
# 'macutils.h',
|
||||
'macutils.cc',
|
||||
'macutils.h',
|
||||
'macwindowpicker.cc',
|
||||
'macwindowpicker.h',
|
||||
'mathutils.h',
|
||||
|
@ -230,8 +225,6 @@
|
|||
'refcount.h',
|
||||
'referencecountedsingletonfactory.h',
|
||||
'rollingaccumulator.h',
|
||||
'safe_conversions.h',
|
||||
'safe_conversions_impl.h',
|
||||
'schanneladapter.cc',
|
||||
'schanneladapter.h',
|
||||
'scoped_autorelease_pool.h',
|
||||
|
@ -242,11 +235,13 @@
|
|||
'sec_buffer.h',
|
||||
'sha1.cc',
|
||||
'sha1.h',
|
||||
'sha1digest.cc',
|
||||
'sha1digest.h',
|
||||
'sharedexclusivelock.cc',
|
||||
'sharedexclusivelock.h',
|
||||
'signalthread.cc',
|
||||
'signalthread.h',
|
||||
'sigslot.cc',
|
||||
'sigslot.h',
|
||||
'sigslotrepeater.h',
|
||||
'socket.h',
|
||||
|
@ -278,7 +273,6 @@
|
|||
'sslstreamadapterhelper.h',
|
||||
'stream.cc',
|
||||
'stream.h',
|
||||
'stringdigest.h',
|
||||
'systeminfo.cc',
|
||||
'systeminfo.h',
|
||||
'task.cc',
|
||||
|
@ -291,9 +285,6 @@
|
|||
'testclient.h',
|
||||
'thread.cc',
|
||||
'thread.h',
|
||||
'thread_checker.h',
|
||||
'thread_checker_impl.cc',
|
||||
'thread_checker_impl.h',
|
||||
'timing.cc',
|
||||
'timing.h',
|
||||
'transformadapter.cc',
|
||||
|
@ -369,16 +360,14 @@
|
|||
'asyncinvoker.cc',
|
||||
'asyncinvoker.h',
|
||||
'asyncinvoker-inl.h',
|
||||
'asyncresolverinterface.h',
|
||||
'atomicops.h',
|
||||
'bandwidthsmoother.cc',
|
||||
'bandwidthsmoother.h',
|
||||
'basictypes.h',
|
||||
'bind.h',
|
||||
# 'bind.h.pump',
|
||||
'buffer.h',
|
||||
'bind.h.pump',
|
||||
'callback.h',
|
||||
# 'callback.h.pump',
|
||||
'callback.h.pump',
|
||||
'constructormagic.h',
|
||||
'dbus.cc',
|
||||
'dbus.h',
|
||||
|
@ -388,15 +377,15 @@
|
|||
'filelock.h',
|
||||
'fileutils_mock.h',
|
||||
'genericslot.h',
|
||||
# 'genericslot.h.pump',
|
||||
'genericslot.h.pump',
|
||||
'httpserver.cc',
|
||||
'httpserver.h',
|
||||
'json.cc',
|
||||
'json.h',
|
||||
'latebindingsymboltable.cc',
|
||||
# 'latebindingsymboltable.cc.def',
|
||||
'latebindingsymboltable.cc.def',
|
||||
'latebindingsymboltable.h',
|
||||
# 'latebindingsymboltable.h.def',
|
||||
'latebindingsymboltable.h.def',
|
||||
'libdbusglibsymboltable.cc',
|
||||
'libdbusglibsymboltable.h',
|
||||
'linuxfdwalk.c',
|
||||
|
@ -442,7 +431,6 @@
|
|||
'sharedexclusivelock.h',
|
||||
'sslconfig.h',
|
||||
'sslroots.h',
|
||||
'stringdigest.h',
|
||||
'testbase64.h',
|
||||
'testclient.cc',
|
||||
'testclient.h',
|
||||
|
|
|
@ -79,8 +79,7 @@ bool Base64::GetNextBase64Char(char ch, char* next_ch) {
|
|||
if (next_ch == NULL) {
|
||||
return false;
|
||||
}
|
||||
// Evil due to base/stringutils.h wanting non-standard &char for the second arg
|
||||
const char* p = strchr(Base64Table, &ch);
|
||||
const char* p = strchr(Base64Table, ch);
|
||||
if (!p)
|
||||
return false;
|
||||
++p;
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
'cpumonitor_unittest.cc',
|
||||
'crc32_unittest.cc',
|
||||
'criticalsection_unittest.cc',
|
||||
'event_tracer_unittest.cc',
|
||||
'event_unittest.cc',
|
||||
'exp_filter_unittest.cc',
|
||||
'filelock_unittest.cc',
|
||||
|
@ -72,7 +73,7 @@
|
|||
'logging_unittest.cc',
|
||||
'md5digest_unittest.cc',
|
||||
'messagedigest_unittest.cc',
|
||||
#'messagequeue_unittest.cc',
|
||||
'messagequeue_unittest.cc',
|
||||
'multipart_unittest.cc',
|
||||
'nat_unittest.cc',
|
||||
'network_unittest.cc',
|
||||
|
|
|
@ -111,15 +111,6 @@ typedef int socklen_t;
|
|||
|
||||
// The following only works for C++
|
||||
#ifdef __cplusplus
|
||||
namespace rtc {
|
||||
template<class T> inline T _min(T a, T b) { return (a > b) ? b : a; }
|
||||
template<class T> inline T _max(T a, T b) { return (a < b) ? b : a; }
|
||||
|
||||
// For wait functions that take a number of milliseconds, kForever indicates
|
||||
// unlimited time.
|
||||
const int kForever = -1;
|
||||
}
|
||||
|
||||
#define ALIGNP(p, t) \
|
||||
(reinterpret_cast<uint8*>(((reinterpret_cast<uintptr_t>(p) + \
|
||||
((t) - 1)) & ~((t) - 1))))
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright 2015 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.
|
||||
*/
|
||||
|
||||
#include "webrtc/base/buffer.h"
|
||||
|
||||
namespace rtc {
|
||||
|
||||
Buffer::Buffer() {
|
||||
Construct(NULL, 0, 0);
|
||||
}
|
||||
|
||||
Buffer::Buffer(size_t size) : Buffer() {
|
||||
SetSize(size);
|
||||
}
|
||||
|
||||
Buffer::Buffer(const void* data, size_t size) {
|
||||
Construct(data, size, size);
|
||||
}
|
||||
|
||||
Buffer::Buffer(const void* data, size_t size, size_t capacity) {
|
||||
Construct(data, size, capacity);
|
||||
}
|
||||
|
||||
Buffer::Buffer(const Buffer& buf) {
|
||||
Construct(buf.data(), buf.size(), buf.size());
|
||||
}
|
||||
|
||||
Buffer::~Buffer() = default;
|
||||
|
||||
}; // namespace rtc
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
|
||||
namespace rtc {
|
||||
|
@ -21,58 +22,54 @@ namespace rtc {
|
|||
// Unlike std::string/vector, does not initialize data when expanding capacity.
|
||||
class Buffer {
|
||||
public:
|
||||
Buffer() {
|
||||
Construct(NULL, 0, 0);
|
||||
}
|
||||
Buffer(const void* data, size_t length) {
|
||||
Construct(data, length, length);
|
||||
}
|
||||
Buffer(const void* data, size_t length, size_t capacity) {
|
||||
Construct(data, length, capacity);
|
||||
}
|
||||
Buffer(const Buffer& buf) {
|
||||
Construct(buf.data(), buf.length(), buf.length());
|
||||
}
|
||||
Buffer();
|
||||
explicit Buffer(size_t size);
|
||||
Buffer(const void* data, size_t size);
|
||||
Buffer(const void* data, size_t size, size_t capacity);
|
||||
Buffer(const Buffer& buf);
|
||||
~Buffer();
|
||||
|
||||
const char* data() const { return data_.get(); }
|
||||
char* data() { return data_.get(); }
|
||||
// TODO: should this be size(), like STL?
|
||||
size_t length() const { return length_; }
|
||||
size_t size() const { return size_; }
|
||||
size_t capacity() const { return capacity_; }
|
||||
|
||||
// For backwards compatibility. TODO(kwiberg): Remove once Chromium doesn't
|
||||
// need it anymore.
|
||||
size_t length() const { return size(); }
|
||||
|
||||
Buffer& operator=(const Buffer& buf) {
|
||||
if (&buf != this) {
|
||||
Construct(buf.data(), buf.length(), buf.length());
|
||||
Construct(buf.data(), buf.size(), buf.size());
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
bool operator==(const Buffer& buf) const {
|
||||
return (length_ == buf.length() &&
|
||||
memcmp(data_.get(), buf.data(), length_) == 0);
|
||||
return (size_ == buf.size() && memcmp(data_.get(), buf.data(), size_) == 0);
|
||||
}
|
||||
bool operator!=(const Buffer& buf) const {
|
||||
return !operator==(buf);
|
||||
}
|
||||
|
||||
void SetData(const void* data, size_t length) {
|
||||
ASSERT(data != NULL || length == 0);
|
||||
SetLength(length);
|
||||
memcpy(data_.get(), data, length);
|
||||
void SetData(const void* data, size_t size) {
|
||||
ASSERT(data != NULL || size == 0);
|
||||
SetSize(size);
|
||||
memcpy(data_.get(), data, size);
|
||||
}
|
||||
void AppendData(const void* data, size_t length) {
|
||||
ASSERT(data != NULL || length == 0);
|
||||
size_t old_length = length_;
|
||||
SetLength(length_ + length);
|
||||
memcpy(data_.get() + old_length, data, length);
|
||||
void AppendData(const void* data, size_t size) {
|
||||
ASSERT(data != NULL || size == 0);
|
||||
size_t old_size = size_;
|
||||
SetSize(size_ + size);
|
||||
memcpy(data_.get() + old_size, data, size);
|
||||
}
|
||||
void SetLength(size_t length) {
|
||||
SetCapacity(length);
|
||||
length_ = length;
|
||||
void SetSize(size_t size) {
|
||||
SetCapacity(size);
|
||||
size_ = size;
|
||||
}
|
||||
void SetCapacity(size_t capacity) {
|
||||
if (capacity > capacity_) {
|
||||
rtc::scoped_ptr<char[]> data(new char[capacity]);
|
||||
memcpy(data.get(), data_.get(), length_);
|
||||
memcpy(data.get(), data_.get(), size_);
|
||||
data_.swap(data);
|
||||
capacity_ = capacity;
|
||||
}
|
||||
|
@ -81,19 +78,19 @@ class Buffer {
|
|||
void TransferTo(Buffer* buf) {
|
||||
ASSERT(buf != NULL);
|
||||
buf->data_.reset(data_.release());
|
||||
buf->length_ = length_;
|
||||
buf->size_ = size_;
|
||||
buf->capacity_ = capacity_;
|
||||
Construct(NULL, 0, 0);
|
||||
}
|
||||
|
||||
protected:
|
||||
void Construct(const void* data, size_t length, size_t capacity) {
|
||||
void Construct(const void* data, size_t size, size_t capacity) {
|
||||
data_.reset(new char[capacity_ = capacity]);
|
||||
SetData(data, length);
|
||||
SetData(data, size);
|
||||
}
|
||||
|
||||
scoped_ptr<char[]> data_;
|
||||
size_t length_;
|
||||
size_t size_;
|
||||
size_t capacity_;
|
||||
};
|
||||
|
||||
|
|
|
@ -19,21 +19,21 @@ static const char kTestData[] = {
|
|||
|
||||
TEST(BufferTest, TestConstructDefault) {
|
||||
Buffer buf;
|
||||
EXPECT_EQ(0U, buf.length());
|
||||
EXPECT_EQ(0U, buf.size());
|
||||
EXPECT_EQ(0U, buf.capacity());
|
||||
EXPECT_EQ(Buffer(), buf);
|
||||
}
|
||||
|
||||
TEST(BufferTest, TestConstructEmptyWithCapacity) {
|
||||
Buffer buf(NULL, 0, 256U);
|
||||
EXPECT_EQ(0U, buf.length());
|
||||
EXPECT_EQ(0U, buf.size());
|
||||
EXPECT_EQ(256U, buf.capacity());
|
||||
EXPECT_EQ(Buffer(), buf);
|
||||
}
|
||||
|
||||
TEST(BufferTest, TestConstructData) {
|
||||
Buffer buf(kTestData, sizeof(kTestData));
|
||||
EXPECT_EQ(sizeof(kTestData), buf.length());
|
||||
EXPECT_EQ(sizeof(kTestData), buf.size());
|
||||
EXPECT_EQ(sizeof(kTestData), buf.capacity());
|
||||
EXPECT_EQ(0, memcmp(buf.data(), kTestData, sizeof(kTestData)));
|
||||
EXPECT_EQ(Buffer(kTestData, sizeof(kTestData)), buf);
|
||||
|
@ -41,7 +41,7 @@ TEST(BufferTest, TestConstructData) {
|
|||
|
||||
TEST(BufferTest, TestConstructDataWithCapacity) {
|
||||
Buffer buf(kTestData, sizeof(kTestData), 256U);
|
||||
EXPECT_EQ(sizeof(kTestData), buf.length());
|
||||
EXPECT_EQ(sizeof(kTestData), buf.size());
|
||||
EXPECT_EQ(256U, buf.capacity());
|
||||
EXPECT_EQ(0, memcmp(buf.data(), kTestData, sizeof(kTestData)));
|
||||
EXPECT_EQ(Buffer(kTestData, sizeof(kTestData)), buf);
|
||||
|
@ -49,7 +49,7 @@ TEST(BufferTest, TestConstructDataWithCapacity) {
|
|||
|
||||
TEST(BufferTest, TestConstructCopy) {
|
||||
Buffer buf1(kTestData, sizeof(kTestData), 256), buf2(buf1);
|
||||
EXPECT_EQ(sizeof(kTestData), buf2.length());
|
||||
EXPECT_EQ(sizeof(kTestData), buf2.size());
|
||||
EXPECT_EQ(sizeof(kTestData), buf2.capacity()); // capacity isn't copied
|
||||
EXPECT_EQ(0, memcmp(buf2.data(), kTestData, sizeof(kTestData)));
|
||||
EXPECT_EQ(buf1, buf2);
|
||||
|
@ -59,7 +59,7 @@ TEST(BufferTest, TestAssign) {
|
|||
Buffer buf1, buf2(kTestData, sizeof(kTestData), 256);
|
||||
EXPECT_NE(buf1, buf2);
|
||||
buf1 = buf2;
|
||||
EXPECT_EQ(sizeof(kTestData), buf1.length());
|
||||
EXPECT_EQ(sizeof(kTestData), buf1.size());
|
||||
EXPECT_EQ(sizeof(kTestData), buf1.capacity()); // capacity isn't copied
|
||||
EXPECT_EQ(0, memcmp(buf1.data(), kTestData, sizeof(kTestData)));
|
||||
EXPECT_EQ(buf1, buf2);
|
||||
|
@ -68,7 +68,7 @@ TEST(BufferTest, TestAssign) {
|
|||
TEST(BufferTest, TestSetData) {
|
||||
Buffer buf;
|
||||
buf.SetData(kTestData, sizeof(kTestData));
|
||||
EXPECT_EQ(sizeof(kTestData), buf.length());
|
||||
EXPECT_EQ(sizeof(kTestData), buf.size());
|
||||
EXPECT_EQ(sizeof(kTestData), buf.capacity());
|
||||
EXPECT_EQ(0, memcmp(buf.data(), kTestData, sizeof(kTestData)));
|
||||
}
|
||||
|
@ -76,27 +76,27 @@ TEST(BufferTest, TestSetData) {
|
|||
TEST(BufferTest, TestAppendData) {
|
||||
Buffer buf(kTestData, sizeof(kTestData));
|
||||
buf.AppendData(kTestData, sizeof(kTestData));
|
||||
EXPECT_EQ(2 * sizeof(kTestData), buf.length());
|
||||
EXPECT_EQ(2 * sizeof(kTestData), buf.size());
|
||||
EXPECT_EQ(2 * sizeof(kTestData), buf.capacity());
|
||||
EXPECT_EQ(0, memcmp(buf.data(), kTestData, sizeof(kTestData)));
|
||||
EXPECT_EQ(0, memcmp(buf.data() + sizeof(kTestData),
|
||||
kTestData, sizeof(kTestData)));
|
||||
}
|
||||
|
||||
TEST(BufferTest, TestSetLengthSmaller) {
|
||||
TEST(BufferTest, TestSetSizeSmaller) {
|
||||
Buffer buf;
|
||||
buf.SetData(kTestData, sizeof(kTestData));
|
||||
buf.SetLength(sizeof(kTestData) / 2);
|
||||
EXPECT_EQ(sizeof(kTestData) / 2, buf.length());
|
||||
buf.SetSize(sizeof(kTestData) / 2);
|
||||
EXPECT_EQ(sizeof(kTestData) / 2, buf.size());
|
||||
EXPECT_EQ(sizeof(kTestData), buf.capacity());
|
||||
EXPECT_EQ(0, memcmp(buf.data(), kTestData, sizeof(kTestData) / 2));
|
||||
}
|
||||
|
||||
TEST(BufferTest, TestSetLengthLarger) {
|
||||
TEST(BufferTest, TestSetSizeLarger) {
|
||||
Buffer buf;
|
||||
buf.SetData(kTestData, sizeof(kTestData));
|
||||
buf.SetLength(sizeof(kTestData) * 2);
|
||||
EXPECT_EQ(sizeof(kTestData) * 2, buf.length());
|
||||
buf.SetSize(sizeof(kTestData) * 2);
|
||||
EXPECT_EQ(sizeof(kTestData) * 2, buf.size());
|
||||
EXPECT_EQ(sizeof(kTestData) * 2, buf.capacity());
|
||||
EXPECT_EQ(0, memcmp(buf.data(), kTestData, sizeof(kTestData)));
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ TEST(BufferTest, TestSetCapacitySmaller) {
|
|||
Buffer buf;
|
||||
buf.SetData(kTestData, sizeof(kTestData));
|
||||
buf.SetCapacity(sizeof(kTestData) / 2); // should be ignored
|
||||
EXPECT_EQ(sizeof(kTestData), buf.length());
|
||||
EXPECT_EQ(sizeof(kTestData), buf.size());
|
||||
EXPECT_EQ(sizeof(kTestData), buf.capacity());
|
||||
EXPECT_EQ(0, memcmp(buf.data(), kTestData, sizeof(kTestData)));
|
||||
}
|
||||
|
@ -113,17 +113,17 @@ TEST(BufferTest, TestSetCapacitySmaller) {
|
|||
TEST(BufferTest, TestSetCapacityLarger) {
|
||||
Buffer buf(kTestData, sizeof(kTestData));
|
||||
buf.SetCapacity(sizeof(kTestData) * 2);
|
||||
EXPECT_EQ(sizeof(kTestData), buf.length());
|
||||
EXPECT_EQ(sizeof(kTestData), buf.size());
|
||||
EXPECT_EQ(sizeof(kTestData) * 2, buf.capacity());
|
||||
EXPECT_EQ(0, memcmp(buf.data(), kTestData, sizeof(kTestData)));
|
||||
}
|
||||
|
||||
TEST(BufferTest, TestSetCapacityThenSetLength) {
|
||||
TEST(BufferTest, TestSetCapacityThenSetSize) {
|
||||
Buffer buf(kTestData, sizeof(kTestData));
|
||||
buf.SetCapacity(sizeof(kTestData) * 4);
|
||||
memcpy(buf.data() + sizeof(kTestData), kTestData, sizeof(kTestData));
|
||||
buf.SetLength(sizeof(kTestData) * 2);
|
||||
EXPECT_EQ(sizeof(kTestData) * 2, buf.length());
|
||||
buf.SetSize(sizeof(kTestData) * 2);
|
||||
EXPECT_EQ(sizeof(kTestData) * 2, buf.size());
|
||||
EXPECT_EQ(sizeof(kTestData) * 4, buf.capacity());
|
||||
EXPECT_EQ(0, memcmp(buf.data(), kTestData, sizeof(kTestData)));
|
||||
EXPECT_EQ(0, memcmp(buf.data() + sizeof(kTestData),
|
||||
|
@ -133,9 +133,9 @@ TEST(BufferTest, TestSetCapacityThenSetLength) {
|
|||
TEST(BufferTest, TestTransfer) {
|
||||
Buffer buf1(kTestData, sizeof(kTestData), 256U), buf2;
|
||||
buf1.TransferTo(&buf2);
|
||||
EXPECT_EQ(0U, buf1.length());
|
||||
EXPECT_EQ(0U, buf1.size());
|
||||
EXPECT_EQ(0U, buf1.capacity());
|
||||
EXPECT_EQ(sizeof(kTestData), buf2.length());
|
||||
EXPECT_EQ(sizeof(kTestData), buf2.size());
|
||||
EXPECT_EQ(256U, buf2.capacity()); // capacity does transfer
|
||||
EXPECT_EQ(0, memcmp(buf2.data(), kTestData, sizeof(kTestData)));
|
||||
}
|
||||
|
|
|
@ -189,13 +189,13 @@ char* ByteBuffer::ReserveWriteBuffer(size_t len) {
|
|||
}
|
||||
|
||||
void ByteBuffer::Resize(size_t size) {
|
||||
size_t len = _min(end_ - start_, size);
|
||||
size_t len = std::min(end_ - start_, size);
|
||||
if (size <= size_) {
|
||||
// Don't reallocate, just move data backwards
|
||||
memmove(bytes_, bytes_ + start_, len);
|
||||
} else {
|
||||
// Reallocate a larger buffer.
|
||||
size_ = _max(size, 3 * size_ / 2);
|
||||
size_ = std::max(size, 3 * size_ / 2);
|
||||
char* new_bytes = new char[size_];
|
||||
memcpy(new_bytes, bytes_ + start_, len);
|
||||
delete [] bytes_;
|
||||
|
|
|
@ -62,7 +62,6 @@
|
|||
#ifndef WEBRTC_BASE_CALLBACK_H_
|
||||
#define WEBRTC_BASE_CALLBACK_H_
|
||||
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/base/refcount.h"
|
||||
#include "webrtc/base/scoped_ref_ptr.h"
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
#if defined(__GLIBC__) && !defined(__UCLIBC__)
|
||||
#if defined(__GLIBCXX__) && !defined(__UCLIBC__)
|
||||
#include <cxxabi.h>
|
||||
#include <execinfo.h>
|
||||
#endif
|
||||
|
@ -55,7 +55,7 @@ void PrintError(const char* format, ...) {
|
|||
// to get usable symbols on Linux. This is copied from V8. Chromium has a more
|
||||
// advanced stace trace system; also more difficult to copy.
|
||||
void DumpBacktrace() {
|
||||
#if defined(__GLIBC__) && !defined(__UCLIBC__)
|
||||
#if defined(__GLIBCXX__) && !defined(__UCLIBC__)
|
||||
void* trace[100];
|
||||
int size = backtrace(trace, sizeof(trace) / sizeof(*trace));
|
||||
char** symbols = backtrace_symbols(trace, size);
|
||||
|
|
|
@ -71,10 +71,15 @@ namespace rtc {
|
|||
#define LAZY_STREAM(stream, condition) \
|
||||
!(condition) ? static_cast<void>(0) : rtc::FatalMessageVoidify() & (stream)
|
||||
|
||||
// The actual stream used isn't important.
|
||||
#define EAT_STREAM_PARAMETERS \
|
||||
true ? static_cast<void>(0) \
|
||||
: rtc::FatalMessageVoidify() & rtc::FatalMessage("", 0).stream()
|
||||
// The actual stream used isn't important. We reference condition in the code
|
||||
// but don't evaluate it; this is to avoid "unused variable" warnings (we do so
|
||||
// in a particularly convoluted way with an extra ?: because that appears to be
|
||||
// the simplest construct that keeps Visual Studio from complaining about
|
||||
// condition being unused).
|
||||
#define EAT_STREAM_PARAMETERS(condition) \
|
||||
(true ? true : !(condition)) \
|
||||
? static_cast<void>(0) \
|
||||
: rtc::FatalMessageVoidify() & rtc::FatalMessage("", 0).stream()
|
||||
|
||||
// CHECK dies with a fatal error if condition is not true. It is *not*
|
||||
// controlled by NDEBUG, so the check will be executed regardless of
|
||||
|
@ -159,8 +164,9 @@ DEFINE_CHECK_OP_IMPL(GT, > )
|
|||
#define CHECK_GE(val1, val2) CHECK_OP(GE, >=, val1, val2)
|
||||
#define CHECK_GT(val1, val2) CHECK_OP(GT, > , val1, val2)
|
||||
|
||||
// The DCHECK macro is equivalent to CHECK except that it only generates code in
|
||||
// debug builds.
|
||||
// The DCHECK macro is equivalent to CHECK except that it only generates code
|
||||
// in debug builds. It does reference the condition parameter in all cases,
|
||||
// though, so callers won't risk getting warnings about unused variables.
|
||||
#if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
|
||||
#define DCHECK(condition) CHECK(condition)
|
||||
#define DCHECK_EQ(v1, v2) CHECK_EQ(v1, v2)
|
||||
|
@ -170,13 +176,13 @@ DEFINE_CHECK_OP_IMPL(GT, > )
|
|||
#define DCHECK_GE(v1, v2) CHECK_GE(v1, v2)
|
||||
#define DCHECK_GT(v1, v2) CHECK_GT(v1, v2)
|
||||
#else
|
||||
#define DCHECK(condition) EAT_STREAM_PARAMETERS
|
||||
#define DCHECK_EQ(v1, v2) EAT_STREAM_PARAMETERS
|
||||
#define DCHECK_NE(v1, v2) EAT_STREAM_PARAMETERS
|
||||
#define DCHECK_LE(v1, v2) EAT_STREAM_PARAMETERS
|
||||
#define DCHECK_LT(v1, v2) EAT_STREAM_PARAMETERS
|
||||
#define DCHECK_GE(v1, v2) EAT_STREAM_PARAMETERS
|
||||
#define DCHECK_GT(v1, v2) EAT_STREAM_PARAMETERS
|
||||
#define DCHECK(condition) EAT_STREAM_PARAMETERS(condition)
|
||||
#define DCHECK_EQ(v1, v2) EAT_STREAM_PARAMETERS((v1) == (v2))
|
||||
#define DCHECK_NE(v1, v2) EAT_STREAM_PARAMETERS((v1) != (v2))
|
||||
#define DCHECK_LE(v1, v2) EAT_STREAM_PARAMETERS((v1) <= (v2))
|
||||
#define DCHECK_LT(v1, v2) EAT_STREAM_PARAMETERS((v1) < (v2))
|
||||
#define DCHECK_GE(v1, v2) EAT_STREAM_PARAMETERS((v1) >= (v2))
|
||||
#define DCHECK_GT(v1, v2) EAT_STREAM_PARAMETERS((v1) > (v2))
|
||||
#endif
|
||||
|
||||
// This is identical to LogMessageVoidify but in name.
|
||||
|
@ -190,6 +196,9 @@ class FatalMessageVoidify {
|
|||
|
||||
#endif // WEBRTC_CHROMIUM_BUILD
|
||||
|
||||
#define RTC_UNREACHABLE_CODE_HIT false
|
||||
#define RTC_NOTREACHED() DCHECK(RTC_UNREACHABLE_CODE_HIT)
|
||||
|
||||
#define FATAL() rtc::FatalMessage(__FILE__, __LINE__).stream()
|
||||
// TODO(ajm): Consider adding NOTIMPLEMENTED and NOTREACHED macros when
|
||||
// base/logging.h and system_wrappers/logging.h are consolidated such that we
|
||||
|
@ -211,6 +220,14 @@ class FatalMessage {
|
|||
std::ostringstream stream_;
|
||||
};
|
||||
|
||||
// Performs the integer division a/b and returns the result. CHECKs that the
|
||||
// remainder is zero.
|
||||
template <typename T>
|
||||
inline T CheckedDivExact(T a, T b) {
|
||||
CHECK_EQ(a % b, static_cast<T>(0));
|
||||
return a / b;
|
||||
}
|
||||
|
||||
} // namespace rtc
|
||||
|
||||
#endif // WEBRTC_BASE_CHECKS_H_
|
||||
|
|
|
@ -52,12 +52,7 @@ inline void RtcUnused(const void*) {}
|
|||
#define stricmp(x, y) strcasecmp(x, y)
|
||||
#endif
|
||||
|
||||
// TODO(fbarchard): Remove this. std::max should be used everywhere in the code.
|
||||
// NOMINMAX must be defined where we include <windows.h>.
|
||||
#define stdmax(x, y) std::max(x, y)
|
||||
#else
|
||||
#define stdmax(x, y) rtc::_max(x, y)
|
||||
#endif
|
||||
#endif // !defined(WEBRTC_WIN)
|
||||
|
||||
#define ARRAY_SIZE(x) (static_cast<int>(sizeof(x) / sizeof(x[0])))
|
||||
|
||||
|
@ -188,28 +183,6 @@ inline bool ImplicitCastToBool(bool result) { return result; }
|
|||
#define FORCE_INLINE
|
||||
#endif
|
||||
|
||||
// Borrowed from Chromium's base/compiler_specific.h.
|
||||
// Annotate a virtual method indicating it must be overriding a virtual
|
||||
// method in the parent class.
|
||||
// Use like:
|
||||
// virtual void foo() OVERRIDE;
|
||||
#if defined(WEBRTC_WIN)
|
||||
#define OVERRIDE override
|
||||
#elif defined(__clang__)
|
||||
// Clang defaults to C++03 and warns about using override. Squelch that.
|
||||
// Intentionally no push/pop here so all users of OVERRIDE ignore the warning
|
||||
// too. This is like passing -Wno-c++11-extensions, except that GCC won't die
|
||||
// (because it won't see this pragma).
|
||||
#pragma clang diagnostic ignored "-Wc++11-extensions"
|
||||
#define OVERRIDE override
|
||||
#elif defined(__GNUC__) && __cplusplus >= 201103 && \
|
||||
(__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40700
|
||||
// GCC 4.7 supports explicit virtual overrides when C++11 support is enabled.
|
||||
#define OVERRIDE override
|
||||
#else
|
||||
#define OVERRIDE
|
||||
#endif
|
||||
|
||||
// Annotate a function indicating the caller must examine the return value.
|
||||
// Use like:
|
||||
// int foo() WARN_UNUSED_RESULT;
|
||||
|
|
|
@ -1,82 +0,0 @@
|
|||
/*
|
||||
* Copyright 2013 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.
|
||||
*/
|
||||
|
||||
// COMPILE_ASSERT macro, borrowed from google3/base/macros.h.
|
||||
#ifndef WEBRTC_BASE_COMPILE_ASSERT_H_
|
||||
#define WEBRTC_BASE_COMPILE_ASSERT_H_
|
||||
|
||||
// The COMPILE_ASSERT macro can be used to verify that a compile time
|
||||
// expression is true. For example, you could use it to verify the
|
||||
// size of a static array:
|
||||
//
|
||||
// COMPILE_ASSERT(ARRAYSIZE(content_type_names) == CONTENT_NUM_TYPES,
|
||||
// content_type_names_incorrect_size);
|
||||
//
|
||||
// or to make sure a struct is smaller than a certain size:
|
||||
//
|
||||
// COMPILE_ASSERT(sizeof(foo) < 128, foo_too_large);
|
||||
//
|
||||
// The second argument to the macro is the name of the variable. If
|
||||
// the expression is false, most compilers will issue a warning/error
|
||||
// containing the name of the variable.
|
||||
|
||||
// TODO(ajm): Hack to avoid multiple definitions until the base/ of webrtc and
|
||||
// libjingle are merged.
|
||||
#if !defined(COMPILE_ASSERT)
|
||||
template <bool>
|
||||
struct CompileAssert {
|
||||
};
|
||||
|
||||
#define COMPILE_ASSERT(expr, msg) \
|
||||
typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1] // NOLINT
|
||||
#endif // COMPILE_ASSERT
|
||||
|
||||
// Implementation details of COMPILE_ASSERT:
|
||||
//
|
||||
// - COMPILE_ASSERT works by defining an array type that has -1
|
||||
// elements (and thus is invalid) when the expression is false.
|
||||
//
|
||||
// - The simpler definition
|
||||
//
|
||||
// #define COMPILE_ASSERT(expr, msg) typedef char msg[(expr) ? 1 : -1]
|
||||
//
|
||||
// does not work, as gcc supports variable-length arrays whose sizes
|
||||
// are determined at run-time (this is gcc's extension and not part
|
||||
// of the C++ standard). As a result, gcc fails to reject the
|
||||
// following code with the simple definition:
|
||||
//
|
||||
// int foo;
|
||||
// COMPILE_ASSERT(foo, msg); // not supposed to compile as foo is
|
||||
// // not a compile-time constant.
|
||||
//
|
||||
// - By using the type CompileAssert<(bool(expr))>, we ensures that
|
||||
// expr is a compile-time constant. (Template arguments must be
|
||||
// determined at compile-time.)
|
||||
//
|
||||
// - The outer parentheses in CompileAssert<(bool(expr))> are necessary
|
||||
// to work around a bug in gcc 3.4.4 and 4.0.1. If we had written
|
||||
//
|
||||
// CompileAssert<bool(expr)>
|
||||
//
|
||||
// instead, these compilers will refuse to compile
|
||||
//
|
||||
// COMPILE_ASSERT(5 > 0, some_message);
|
||||
//
|
||||
// (They seem to think the ">" in "5 > 0" marks the end of the
|
||||
// template argument list.)
|
||||
//
|
||||
// - The array size is (bool(expr) ? 1 : -1), instead of simply
|
||||
//
|
||||
// ((expr) ? 1 : -1).
|
||||
//
|
||||
// This is to avoid running into a bug in MS VC 7.1, which
|
||||
// causes ((0.0) ? 1 : -1) to incorrectly evaluate to 1.
|
||||
|
||||
#endif // WEBRTC_BASE_COMPILE_ASSERT_H_
|
|
@ -95,7 +95,7 @@ class CpuMonitor
|
|||
: public rtc::MessageHandler, public sigslot::has_slots<> {
|
||||
public:
|
||||
explicit CpuMonitor(Thread* thread);
|
||||
virtual ~CpuMonitor();
|
||||
~CpuMonitor() override;
|
||||
void set_thread(Thread* thread);
|
||||
|
||||
bool Start(int period_ms);
|
||||
|
@ -105,7 +105,7 @@ class CpuMonitor
|
|||
|
||||
protected:
|
||||
// Override virtual method of parent MessageHandler.
|
||||
virtual void OnMessage(rtc::Message* msg);
|
||||
void OnMessage(rtc::Message* msg) override;
|
||||
// Clear the monitor thread and stop sending it messages if the thread goes
|
||||
// away before our lifetime.
|
||||
void OnMessageQueueDestroyed() { monitor_thread_ = NULL; }
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright 2015 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.
|
||||
*/
|
||||
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/thread.h"
|
||||
|
||||
namespace rtc {
|
||||
|
||||
void GlobalLockPod::Lock() {
|
||||
while (AtomicOps::CompareAndSwap(&lock_acquired, 0, 1)) {
|
||||
Thread::SleepMs(0);
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalLockPod::Unlock() {
|
||||
int old_value = AtomicOps::CompareAndSwap(&lock_acquired, 1, 0);
|
||||
DCHECK_EQ(1, old_value) << "Unlock called without calling Lock first";
|
||||
}
|
||||
|
||||
GlobalLock::GlobalLock() {
|
||||
lock_acquired = 0;
|
||||
}
|
||||
|
||||
} // namespace rtc
|
|
@ -15,7 +15,12 @@
|
|||
#include "webrtc/base/thread_annotations.h"
|
||||
|
||||
#if defined(WEBRTC_WIN)
|
||||
#include "webrtc/base/win32.h"
|
||||
// Include winsock2.h before including <windows.h> to maintain consistency with
|
||||
// win32.h. We can't include win32.h directly here since it pulls in
|
||||
// headers such as basictypes.h which causes problems in Chromium where webrtc
|
||||
// exists as two separate projects, webrtc and libjingle.
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#if defined(WEBRTC_POSIX)
|
||||
|
@ -37,39 +42,27 @@ namespace rtc {
|
|||
#if defined(WEBRTC_WIN)
|
||||
class LOCKABLE CriticalSection {
|
||||
public:
|
||||
CriticalSection() {
|
||||
InitializeCriticalSection(&crit_);
|
||||
// Windows docs say 0 is not a valid thread id
|
||||
TRACK_OWNER(thread_ = 0);
|
||||
}
|
||||
~CriticalSection() {
|
||||
DeleteCriticalSection(&crit_);
|
||||
}
|
||||
CriticalSection() { InitializeCriticalSection(&crit_); }
|
||||
~CriticalSection() { DeleteCriticalSection(&crit_); }
|
||||
void Enter() EXCLUSIVE_LOCK_FUNCTION() {
|
||||
EnterCriticalSection(&crit_);
|
||||
TRACK_OWNER(thread_ = GetCurrentThreadId());
|
||||
}
|
||||
bool TryEnter() EXCLUSIVE_TRYLOCK_FUNCTION(true) {
|
||||
if (TryEnterCriticalSection(&crit_) != FALSE) {
|
||||
TRACK_OWNER(thread_ = GetCurrentThreadId());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return TryEnterCriticalSection(&crit_) != FALSE;
|
||||
}
|
||||
void Leave() UNLOCK_FUNCTION() {
|
||||
TRACK_OWNER(thread_ = 0);
|
||||
LeaveCriticalSection(&crit_);
|
||||
}
|
||||
|
||||
#if CS_TRACK_OWNER
|
||||
bool CurrentThreadIsOwner() const { return thread_ == GetCurrentThreadId(); }
|
||||
#endif // CS_TRACK_OWNER
|
||||
// Used for debugging.
|
||||
bool CurrentThreadIsOwner() const {
|
||||
return crit_.OwningThread == reinterpret_cast<HANDLE>(GetCurrentThreadId());
|
||||
}
|
||||
|
||||
private:
|
||||
CRITICAL_SECTION crit_;
|
||||
TRACK_OWNER(DWORD thread_); // The section's owning thread id
|
||||
};
|
||||
#endif // WEBRTC_WIN
|
||||
#endif // WEBRTC_WIN
|
||||
|
||||
#if defined(WEBRTC_POSIX)
|
||||
class LOCKABLE CriticalSection {
|
||||
|
@ -101,9 +94,14 @@ class LOCKABLE CriticalSection {
|
|||
pthread_mutex_unlock(&mutex_);
|
||||
}
|
||||
|
||||
// Used for debugging.
|
||||
bool CurrentThreadIsOwner() const {
|
||||
#if CS_TRACK_OWNER
|
||||
bool CurrentThreadIsOwner() const { return pthread_equal(thread_, pthread_self()); }
|
||||
return pthread_equal(thread_, pthread_self());
|
||||
#else
|
||||
return true;
|
||||
#endif // CS_TRACK_OWNER
|
||||
}
|
||||
|
||||
private:
|
||||
pthread_mutex_t mutex_;
|
||||
|
@ -159,22 +157,61 @@ class AtomicOps {
|
|||
public:
|
||||
#if defined(WEBRTC_WIN)
|
||||
// Assumes sizeof(int) == sizeof(LONG), which it is on Win32 and Win64.
|
||||
static int Increment(int* i) {
|
||||
return ::InterlockedIncrement(reinterpret_cast<LONG*>(i));
|
||||
static int Increment(volatile int* i) {
|
||||
return ::InterlockedIncrement(reinterpret_cast<volatile LONG*>(i));
|
||||
}
|
||||
static int Decrement(int* i) {
|
||||
return ::InterlockedDecrement(reinterpret_cast<LONG*>(i));
|
||||
static int Decrement(volatile int* i) {
|
||||
return ::InterlockedDecrement(reinterpret_cast<volatile LONG*>(i));
|
||||
}
|
||||
static int Load(volatile const int* i) {
|
||||
return *i;
|
||||
}
|
||||
static void Store(volatile int* i, int value) {
|
||||
*i = value;
|
||||
}
|
||||
static int CompareAndSwap(volatile int* i, int old_value, int new_value) {
|
||||
return ::InterlockedCompareExchange(reinterpret_cast<volatile LONG*>(i),
|
||||
new_value,
|
||||
old_value);
|
||||
}
|
||||
#else
|
||||
static int Increment(int* i) {
|
||||
static int Increment(volatile int* i) {
|
||||
return __sync_add_and_fetch(i, 1);
|
||||
}
|
||||
static int Decrement(int* i) {
|
||||
static int Decrement(volatile int* i) {
|
||||
return __sync_sub_and_fetch(i, 1);
|
||||
}
|
||||
static int Load(volatile const int* i) {
|
||||
// Adding 0 is a no-op, so const_cast is fine.
|
||||
return __sync_add_and_fetch(const_cast<volatile int*>(i), 0);
|
||||
}
|
||||
static void Store(volatile int* i, int value) {
|
||||
__sync_synchronize();
|
||||
*i = value;
|
||||
}
|
||||
static int CompareAndSwap(volatile int* i, int old_value, int new_value) {
|
||||
return __sync_val_compare_and_swap(i, old_value, new_value);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
// A POD lock used to protect global variables. Do NOT use for other purposes.
|
||||
// No custom constructor or private data member should be added.
|
||||
class LOCKABLE GlobalLockPod {
|
||||
public:
|
||||
void Lock() EXCLUSIVE_LOCK_FUNCTION();
|
||||
|
||||
void Unlock() UNLOCK_FUNCTION();
|
||||
|
||||
volatile int lock_acquired;
|
||||
};
|
||||
|
||||
class GlobalLock : public GlobalLockPod {
|
||||
public:
|
||||
GlobalLock();
|
||||
};
|
||||
|
||||
} // namespace rtc
|
||||
|
||||
#endif // WEBRTC_BASE_CRITICALSECTION_H__
|
||||
|
|
|
@ -26,16 +26,54 @@ const int kLongTime = 10000; // 10 seconds
|
|||
const int kNumThreads = 16;
|
||||
const int kOperationsToRun = 1000;
|
||||
|
||||
template <class T>
|
||||
class AtomicOpRunner : public MessageHandler {
|
||||
class UniqueValueVerifier {
|
||||
public:
|
||||
explicit AtomicOpRunner(int initial_value)
|
||||
: value_(initial_value),
|
||||
threads_active_(0),
|
||||
start_event_(true, false),
|
||||
done_event_(true, false) {}
|
||||
void Verify(const std::vector<int>& values) {
|
||||
for (size_t i = 0; i < values.size(); ++i) {
|
||||
std::pair<std::set<int>::iterator, bool> result =
|
||||
all_values_.insert(values[i]);
|
||||
// Each value should only be taken by one thread, so if this value
|
||||
// has already been added, something went wrong.
|
||||
EXPECT_TRUE(result.second)
|
||||
<< " Thread=" << Thread::Current() << " value=" << values[i];
|
||||
}
|
||||
}
|
||||
|
||||
int value() const { return value_; }
|
||||
void Finalize() {}
|
||||
|
||||
private:
|
||||
std::set<int> all_values_;
|
||||
};
|
||||
|
||||
class CompareAndSwapVerifier {
|
||||
public:
|
||||
CompareAndSwapVerifier() : zero_count_(0) {}
|
||||
|
||||
void Verify(const std::vector<int>& values) {
|
||||
for (auto v : values) {
|
||||
if (v == 0) {
|
||||
EXPECT_EQ(0, zero_count_) << "Thread=" << Thread::Current();
|
||||
++zero_count_;
|
||||
} else {
|
||||
EXPECT_EQ(1, v) << " Thread=" << Thread::Current();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Finalize() {
|
||||
EXPECT_EQ(1, zero_count_);
|
||||
}
|
||||
private:
|
||||
int zero_count_;
|
||||
};
|
||||
|
||||
class RunnerBase : public MessageHandler {
|
||||
public:
|
||||
explicit RunnerBase(int value)
|
||||
: threads_active_(0),
|
||||
start_event_(true, false),
|
||||
done_event_(true, false),
|
||||
shared_value_(value) {}
|
||||
|
||||
bool Run() {
|
||||
// Signal all threads to start.
|
||||
|
@ -49,43 +87,101 @@ class AtomicOpRunner : public MessageHandler {
|
|||
threads_active_ = count;
|
||||
}
|
||||
|
||||
virtual void OnMessage(Message* msg) {
|
||||
int shared_value() const { return shared_value_; }
|
||||
|
||||
protected:
|
||||
// Derived classes must override OnMessage, and call BeforeStart and AfterEnd
|
||||
// at the beginning and the end of OnMessage respectively.
|
||||
void BeforeStart() {
|
||||
ASSERT_TRUE(start_event_.Wait(kLongTime));
|
||||
}
|
||||
|
||||
// Returns true if all threads have finished.
|
||||
bool AfterEnd() {
|
||||
if (AtomicOps::Decrement(&threads_active_) == 0) {
|
||||
done_event_.Set();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int threads_active_;
|
||||
Event start_event_;
|
||||
Event done_event_;
|
||||
int shared_value_;
|
||||
};
|
||||
|
||||
class LOCKABLE CriticalSectionLock {
|
||||
public:
|
||||
void Lock() EXCLUSIVE_LOCK_FUNCTION() {
|
||||
cs_.Enter();
|
||||
}
|
||||
void Unlock() UNLOCK_FUNCTION() {
|
||||
cs_.Leave();
|
||||
}
|
||||
|
||||
private:
|
||||
CriticalSection cs_;
|
||||
};
|
||||
|
||||
template <class Lock>
|
||||
class LockRunner : public RunnerBase {
|
||||
public:
|
||||
LockRunner() : RunnerBase(0) {}
|
||||
|
||||
void OnMessage(Message* msg) override {
|
||||
BeforeStart();
|
||||
|
||||
lock_.Lock();
|
||||
|
||||
EXPECT_EQ(0, shared_value_);
|
||||
int old = shared_value_;
|
||||
|
||||
// Use a loop to increase the chance of race.
|
||||
for (int i = 0; i < kOperationsToRun; ++i) {
|
||||
++shared_value_;
|
||||
}
|
||||
EXPECT_EQ(old + kOperationsToRun, shared_value_);
|
||||
shared_value_ = 0;
|
||||
|
||||
lock_.Unlock();
|
||||
|
||||
AfterEnd();
|
||||
}
|
||||
|
||||
private:
|
||||
Lock lock_;
|
||||
};
|
||||
|
||||
template <class Op, class Verifier>
|
||||
class AtomicOpRunner : public RunnerBase {
|
||||
public:
|
||||
explicit AtomicOpRunner(int initial_value) : RunnerBase(initial_value) {}
|
||||
|
||||
void OnMessage(Message* msg) override {
|
||||
BeforeStart();
|
||||
|
||||
std::vector<int> values;
|
||||
values.reserve(kOperationsToRun);
|
||||
|
||||
// Wait to start.
|
||||
ASSERT_TRUE(start_event_.Wait(kLongTime));
|
||||
|
||||
// Generate a bunch of values by updating value_ atomically.
|
||||
// Generate a bunch of values by updating shared_value_ atomically.
|
||||
for (int i = 0; i < kOperationsToRun; ++i) {
|
||||
values.push_back(T::AtomicOp(&value_));
|
||||
values.push_back(Op::AtomicOp(&shared_value_));
|
||||
}
|
||||
|
||||
{ // Add them all to the set.
|
||||
CritScope cs(&all_values_crit_);
|
||||
for (size_t i = 0; i < values.size(); ++i) {
|
||||
std::pair<std::set<int>::iterator, bool> result =
|
||||
all_values_.insert(values[i]);
|
||||
// Each value should only be taken by one thread, so if this value
|
||||
// has already been added, something went wrong.
|
||||
EXPECT_TRUE(result.second)
|
||||
<< "Thread=" << Thread::Current() << " value=" << values[i];
|
||||
}
|
||||
verifier_.Verify(values);
|
||||
}
|
||||
|
||||
// Signal that we're done.
|
||||
if (AtomicOps::Decrement(&threads_active_) == 0) {
|
||||
done_event_.Set();
|
||||
if (AfterEnd()) {
|
||||
verifier_.Finalize();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
int value_;
|
||||
int threads_active_;
|
||||
CriticalSection all_values_crit_;
|
||||
std::set<int> all_values_;
|
||||
Event start_event_;
|
||||
Event done_event_;
|
||||
Verifier verifier_;
|
||||
};
|
||||
|
||||
struct IncrementOp {
|
||||
|
@ -96,6 +192,10 @@ struct DecrementOp {
|
|||
static int AtomicOp(int* i) { return AtomicOps::Decrement(i); }
|
||||
};
|
||||
|
||||
struct CompareAndSwapOp {
|
||||
static int AtomicOp(int* i) { return AtomicOps::CompareAndSwap(i, 0, 1); }
|
||||
};
|
||||
|
||||
void StartThreads(ScopedPtrCollection<Thread>* threads,
|
||||
MessageHandler* handler) {
|
||||
for (int i = 0; i < kNumThreads; ++i) {
|
||||
|
@ -122,26 +222,63 @@ TEST(AtomicOpsTest, Simple) {
|
|||
|
||||
TEST(AtomicOpsTest, Increment) {
|
||||
// Create and start lots of threads.
|
||||
AtomicOpRunner<IncrementOp> runner(0);
|
||||
AtomicOpRunner<IncrementOp, UniqueValueVerifier> runner(0);
|
||||
ScopedPtrCollection<Thread> threads;
|
||||
StartThreads(&threads, &runner);
|
||||
runner.SetExpectedThreadCount(kNumThreads);
|
||||
|
||||
// Release the hounds!
|
||||
EXPECT_TRUE(runner.Run());
|
||||
EXPECT_EQ(kOperationsToRun * kNumThreads, runner.value());
|
||||
EXPECT_EQ(kOperationsToRun * kNumThreads, runner.shared_value());
|
||||
}
|
||||
|
||||
TEST(AtomicOpsTest, Decrement) {
|
||||
// Create and start lots of threads.
|
||||
AtomicOpRunner<DecrementOp> runner(kOperationsToRun * kNumThreads);
|
||||
AtomicOpRunner<DecrementOp, UniqueValueVerifier> runner(
|
||||
kOperationsToRun * kNumThreads);
|
||||
ScopedPtrCollection<Thread> threads;
|
||||
StartThreads(&threads, &runner);
|
||||
runner.SetExpectedThreadCount(kNumThreads);
|
||||
|
||||
// Release the hounds!
|
||||
EXPECT_TRUE(runner.Run());
|
||||
EXPECT_EQ(0, runner.value());
|
||||
EXPECT_EQ(0, runner.shared_value());
|
||||
}
|
||||
|
||||
TEST(AtomicOpsTest, CompareAndSwap) {
|
||||
// Create and start lots of threads.
|
||||
AtomicOpRunner<CompareAndSwapOp, CompareAndSwapVerifier> runner(0);
|
||||
ScopedPtrCollection<Thread> threads;
|
||||
StartThreads(&threads, &runner);
|
||||
runner.SetExpectedThreadCount(kNumThreads);
|
||||
|
||||
// Release the hounds!
|
||||
EXPECT_TRUE(runner.Run());
|
||||
EXPECT_EQ(1, runner.shared_value());
|
||||
}
|
||||
|
||||
TEST(GlobalLockTest, Basic) {
|
||||
// Create and start lots of threads.
|
||||
LockRunner<GlobalLock> runner;
|
||||
ScopedPtrCollection<Thread> threads;
|
||||
StartThreads(&threads, &runner);
|
||||
runner.SetExpectedThreadCount(kNumThreads);
|
||||
|
||||
// Release the hounds!
|
||||
EXPECT_TRUE(runner.Run());
|
||||
EXPECT_EQ(0, runner.shared_value());
|
||||
}
|
||||
|
||||
TEST(CriticalSectionTest, Basic) {
|
||||
// Create and start lots of threads.
|
||||
LockRunner<CriticalSectionLock> runner;
|
||||
ScopedPtrCollection<Thread> threads;
|
||||
StartThreads(&threads, &runner);
|
||||
runner.SetExpectedThreadCount(kNumThreads);
|
||||
|
||||
// Release the hounds!
|
||||
EXPECT_TRUE(runner.Run());
|
||||
EXPECT_EQ(0, runner.shared_value());
|
||||
}
|
||||
|
||||
} // namespace rtc
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* Copyright 2015 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.
|
||||
*/
|
||||
|
||||
#include "webrtc/base/cryptstring.h"
|
||||
|
||||
namespace rtc {
|
||||
|
||||
size_t EmptyCryptStringImpl::GetLength() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void EmptyCryptStringImpl::CopyTo(char* dest, bool nullterminate) const {
|
||||
if (nullterminate) {
|
||||
*dest = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
std::string EmptyCryptStringImpl::UrlEncode() const {
|
||||
return "";
|
||||
}
|
||||
|
||||
CryptStringImpl* EmptyCryptStringImpl::Copy() const {
|
||||
return new EmptyCryptStringImpl();
|
||||
}
|
||||
|
||||
void EmptyCryptStringImpl::CopyRawTo(std::vector<unsigned char>* dest) const {
|
||||
dest->clear();
|
||||
}
|
||||
|
||||
CryptString::CryptString() : impl_(new EmptyCryptStringImpl()) {
|
||||
}
|
||||
|
||||
CryptString::CryptString(const CryptString& other)
|
||||
: impl_(other.impl_->Copy()) {
|
||||
}
|
||||
|
||||
CryptString::CryptString(const CryptStringImpl& impl) : impl_(impl.Copy()) {
|
||||
}
|
||||
|
||||
CryptString::~CryptString() = default;
|
||||
|
||||
size_t InsecureCryptStringImpl::GetLength() const {
|
||||
return password_.size();
|
||||
}
|
||||
|
||||
void InsecureCryptStringImpl::CopyTo(char* dest, bool nullterminate) const {
|
||||
memcpy(dest, password_.data(), password_.size());
|
||||
if (nullterminate)
|
||||
dest[password_.size()] = 0;
|
||||
}
|
||||
|
||||
std::string InsecureCryptStringImpl::UrlEncode() const {
|
||||
return password_;
|
||||
}
|
||||
|
||||
CryptStringImpl* InsecureCryptStringImpl::Copy() const {
|
||||
InsecureCryptStringImpl* copy = new InsecureCryptStringImpl;
|
||||
copy->password() = password_;
|
||||
return copy;
|
||||
}
|
||||
|
||||
void InsecureCryptStringImpl::CopyRawTo(
|
||||
std::vector<unsigned char>* dest) const {
|
||||
dest->resize(password_.size());
|
||||
memcpy(&dest->front(), password_.data(), password_.size());
|
||||
}
|
||||
|
||||
}; // namespace rtc
|
|
@ -33,27 +33,22 @@ public:
|
|||
|
||||
class EmptyCryptStringImpl : public CryptStringImpl {
|
||||
public:
|
||||
virtual ~EmptyCryptStringImpl() {}
|
||||
virtual size_t GetLength() const { return 0; }
|
||||
virtual void CopyTo(char * dest, bool nullterminate) const {
|
||||
if (nullterminate) {
|
||||
*dest = '\0';
|
||||
}
|
||||
}
|
||||
virtual std::string UrlEncode() const { return ""; }
|
||||
virtual CryptStringImpl * Copy() const { return new EmptyCryptStringImpl(); }
|
||||
virtual void CopyRawTo(std::vector<unsigned char> * dest) const {
|
||||
dest->clear();
|
||||
}
|
||||
~EmptyCryptStringImpl() override {}
|
||||
size_t GetLength() const override;
|
||||
void CopyTo(char* dest, bool nullterminate) const override;
|
||||
std::string UrlEncode() const override;
|
||||
CryptStringImpl* Copy() const override;
|
||||
void CopyRawTo(std::vector<unsigned char>* dest) const override;
|
||||
};
|
||||
|
||||
class CryptString {
|
||||
public:
|
||||
CryptString() : impl_(new EmptyCryptStringImpl()) {}
|
||||
CryptString();
|
||||
size_t GetLength() const { return impl_->GetLength(); }
|
||||
void CopyTo(char * dest, bool nullterminate) const { impl_->CopyTo(dest, nullterminate); }
|
||||
CryptString(const CryptString & other) : impl_(other.impl_->Copy()) {}
|
||||
explicit CryptString(const CryptStringImpl & impl) : impl_(impl.Copy()) {}
|
||||
CryptString(const CryptString& other);
|
||||
explicit CryptString(const CryptStringImpl& impl);
|
||||
~CryptString();
|
||||
CryptString & operator=(const CryptString & other) {
|
||||
if (this != &other) {
|
||||
impl_.reset(other.impl_->Copy());
|
||||
|
@ -158,22 +153,13 @@ class InsecureCryptStringImpl : public CryptStringImpl {
|
|||
std::string& password() { return password_; }
|
||||
const std::string& password() const { return password_; }
|
||||
|
||||
virtual ~InsecureCryptStringImpl() {}
|
||||
virtual size_t GetLength() const { return password_.size(); }
|
||||
virtual void CopyTo(char * dest, bool nullterminate) const {
|
||||
memcpy(dest, password_.data(), password_.size());
|
||||
if (nullterminate) dest[password_.size()] = 0;
|
||||
}
|
||||
virtual std::string UrlEncode() const { return password_; }
|
||||
virtual CryptStringImpl * Copy() const {
|
||||
InsecureCryptStringImpl * copy = new InsecureCryptStringImpl;
|
||||
copy->password() = password_;
|
||||
return copy;
|
||||
}
|
||||
virtual void CopyRawTo(std::vector<unsigned char> * dest) const {
|
||||
dest->resize(password_.size());
|
||||
memcpy(&dest->front(), password_.data(), password_.size());
|
||||
}
|
||||
~InsecureCryptStringImpl() override = default;
|
||||
size_t GetLength() const override;
|
||||
void CopyTo(char* dest, bool nullterminate) const override;
|
||||
std::string UrlEncode() const override;
|
||||
CryptStringImpl* Copy() const override;
|
||||
void CopyRawTo(std::vector<unsigned char>* dest) const override;
|
||||
|
||||
private:
|
||||
std::string password_;
|
||||
};
|
||||
|
|
|
@ -344,7 +344,11 @@ bool DBusMonitor::AddFilter(DBusSigFilter *filter) {
|
|||
bool DBusMonitor::StartMonitoring() {
|
||||
if (!monitoring_thread_) {
|
||||
g_type_init();
|
||||
// g_thread_init API is deprecated since glib 2.31.0, see release note:
|
||||
// http://mail.gnome.org/archives/gnome-announce-list/2011-October/msg00041.html
|
||||
#if !GLIB_CHECK_VERSION(2, 31, 0)
|
||||
g_thread_init(NULL);
|
||||
#endif
|
||||
GetSymbols()->dbus_g_thread_init()();
|
||||
|
||||
GMainContext *context = g_main_context_new();
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "webrtc/base/win32.h"
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/diskcache.h"
|
||||
#include "webrtc/base/fileutils.h"
|
||||
|
@ -42,7 +43,7 @@ public:
|
|||
StreamInterface* stream)
|
||||
: StreamAdapterInterface(stream), cache_(cache), id_(id), index_(index)
|
||||
{ }
|
||||
virtual ~DiskCacheAdapter() {
|
||||
~DiskCacheAdapter() override {
|
||||
Close();
|
||||
cache_->ReleaseResource(id_, index_);
|
||||
}
|
||||
|
@ -127,7 +128,7 @@ StreamInterface* DiskCache::WriteResource(const std::string& id, size_t index) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
entry->streams = stdmax(entry->streams, index + 1);
|
||||
entry->streams = std::max(entry->streams, index + 1);
|
||||
entry->size -= previous_size;
|
||||
total_size_ -= previous_size;
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <tchar.h>
|
||||
|
||||
#include <time.h>
|
||||
#include <algorithm>
|
||||
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/diskcache.h"
|
||||
|
@ -45,7 +46,7 @@ bool DiskCacheWin32::InitializeEntries() {
|
|||
Entry* entry = GetOrCreateEntry(id, true);
|
||||
entry->size += find_data.nFileSizeLow;
|
||||
total_size_ += find_data.nFileSizeLow;
|
||||
entry->streams = _max(entry->streams, index + 1);
|
||||
entry->streams = std::max(entry->streams, index + 1);
|
||||
FileTimeToUnixTime(find_data.ftLastWriteTime, &entry->last_modified);
|
||||
|
||||
} while (FindNextFile(find_handle, &find_data));
|
||||
|
|
|
@ -20,18 +20,18 @@
|
|||
#error "Must define either WEBRTC_WIN or WEBRTC_POSIX."
|
||||
#endif
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
|
||||
namespace rtc {
|
||||
|
||||
#if defined(WEBRTC_WIN)
|
||||
|
||||
Event::Event(bool manual_reset, bool initially_signaled)
|
||||
: is_manual_reset_(manual_reset),
|
||||
is_initially_signaled_(initially_signaled) {
|
||||
Event::Event(bool manual_reset, bool initially_signaled) {
|
||||
event_handle_ = ::CreateEvent(NULL, // Security attributes.
|
||||
is_manual_reset_,
|
||||
is_initially_signaled_,
|
||||
manual_reset,
|
||||
initially_signaled,
|
||||
NULL); // Name.
|
||||
ASSERT(event_handle_ != NULL);
|
||||
CHECK(event_handle_);
|
||||
}
|
||||
|
||||
Event::~Event() {
|
||||
|
@ -46,8 +46,8 @@ void Event::Reset() {
|
|||
ResetEvent(event_handle_);
|
||||
}
|
||||
|
||||
bool Event::Wait(int cms) {
|
||||
DWORD ms = (cms == kForever)? INFINITE : cms;
|
||||
bool Event::Wait(int milliseconds) {
|
||||
DWORD ms = (milliseconds == kForever) ? INFINITE : milliseconds;
|
||||
return (WaitForSingleObject(event_handle_, ms) == WAIT_OBJECT_0);
|
||||
}
|
||||
|
||||
|
@ -56,8 +56,8 @@ bool Event::Wait(int cms) {
|
|||
Event::Event(bool manual_reset, bool initially_signaled)
|
||||
: is_manual_reset_(manual_reset),
|
||||
event_status_(initially_signaled) {
|
||||
VERIFY(pthread_mutex_init(&event_mutex_, NULL) == 0);
|
||||
VERIFY(pthread_cond_init(&event_cond_, NULL) == 0);
|
||||
CHECK(pthread_mutex_init(&event_mutex_, NULL) == 0);
|
||||
CHECK(pthread_cond_init(&event_cond_, NULL) == 0);
|
||||
}
|
||||
|
||||
Event::~Event() {
|
||||
|
@ -78,11 +78,11 @@ void Event::Reset() {
|
|||
pthread_mutex_unlock(&event_mutex_);
|
||||
}
|
||||
|
||||
bool Event::Wait(int cms) {
|
||||
bool Event::Wait(int milliseconds) {
|
||||
pthread_mutex_lock(&event_mutex_);
|
||||
int error = 0;
|
||||
|
||||
if (cms != kForever) {
|
||||
if (milliseconds != kForever) {
|
||||
// Converting from seconds and microseconds (1e-6) plus
|
||||
// milliseconds (1e-3) to seconds and nanoseconds (1e-9).
|
||||
|
||||
|
@ -90,14 +90,14 @@ bool Event::Wait(int cms) {
|
|||
#if HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE
|
||||
// Use relative time version, which tends to be more efficient for
|
||||
// pthread implementations where provided (like on Android).
|
||||
ts.tv_sec = cms / 1000;
|
||||
ts.tv_nsec = (cms % 1000) * 1000000;
|
||||
ts.tv_sec = milliseconds / 1000;
|
||||
ts.tv_nsec = (milliseconds % 1000) * 1000000;
|
||||
#else
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
|
||||
ts.tv_sec = tv.tv_sec + (cms / 1000);
|
||||
ts.tv_nsec = tv.tv_usec * 1000 + (cms % 1000) * 1000000;
|
||||
ts.tv_sec = tv.tv_sec + (milliseconds / 1000);
|
||||
ts.tv_nsec = tv.tv_usec * 1000 + (milliseconds % 1000) * 1000000;
|
||||
|
||||
// Handle overflow.
|
||||
if (ts.tv_nsec >= 1000000000) {
|
||||
|
|
|
@ -20,29 +20,31 @@
|
|||
#endif
|
||||
|
||||
#include "webrtc/base/basictypes.h"
|
||||
#include "webrtc/base/common.h"
|
||||
|
||||
namespace rtc {
|
||||
|
||||
class Event {
|
||||
public:
|
||||
static const int kForever = -1;
|
||||
|
||||
Event(bool manual_reset, bool initially_signaled);
|
||||
~Event();
|
||||
|
||||
void Set();
|
||||
void Reset();
|
||||
bool Wait(int cms);
|
||||
|
||||
// Wait for the event to become signaled, for the specified number of
|
||||
// |milliseconds|. To wait indefinetly, pass kForever.
|
||||
bool Wait(int milliseconds);
|
||||
|
||||
private:
|
||||
bool is_manual_reset_;
|
||||
|
||||
#if defined(WEBRTC_WIN)
|
||||
bool is_initially_signaled_;
|
||||
HANDLE event_handle_;
|
||||
#elif defined(WEBRTC_POSIX)
|
||||
bool event_status_;
|
||||
pthread_mutex_t event_mutex_;
|
||||
pthread_cond_t event_cond_;
|
||||
const bool is_manual_reset_;
|
||||
bool event_status_;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Copyright (c) 2012 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.
|
||||
*/
|
||||
|
||||
#include "webrtc/base/event_tracer.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
namespace {
|
||||
|
||||
GetCategoryEnabledPtr g_get_category_enabled_ptr = 0;
|
||||
AddTraceEventPtr g_add_trace_event_ptr = 0;
|
||||
|
||||
} // namespace
|
||||
|
||||
void SetupEventTracer(GetCategoryEnabledPtr get_category_enabled_ptr,
|
||||
AddTraceEventPtr add_trace_event_ptr) {
|
||||
g_get_category_enabled_ptr = get_category_enabled_ptr;
|
||||
g_add_trace_event_ptr = add_trace_event_ptr;
|
||||
}
|
||||
|
||||
// static
|
||||
const unsigned char* EventTracer::GetCategoryEnabled(const char* name) {
|
||||
if (g_get_category_enabled_ptr)
|
||||
return g_get_category_enabled_ptr(name);
|
||||
|
||||
// A string with null terminator means category is disabled.
|
||||
return reinterpret_cast<const unsigned char*>("\0");
|
||||
}
|
||||
|
||||
// static
|
||||
void EventTracer::AddTraceEvent(char phase,
|
||||
const unsigned char* category_enabled,
|
||||
const char* name,
|
||||
unsigned long long id,
|
||||
int num_args,
|
||||
const char** arg_names,
|
||||
const unsigned char* arg_types,
|
||||
const unsigned long long* arg_values,
|
||||
unsigned char flags) {
|
||||
if (g_add_trace_event_ptr) {
|
||||
g_add_trace_event_ptr(phase,
|
||||
category_enabled,
|
||||
name,
|
||||
id,
|
||||
num_args,
|
||||
arg_names,
|
||||
arg_types,
|
||||
arg_values,
|
||||
flags);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* Copyright (c) 2012 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.
|
||||
*/
|
||||
|
||||
// This file defines the interface for event tracing in WebRTC.
|
||||
//
|
||||
// Event log handlers are set through SetupEventTracer(). User of this API will
|
||||
// provide two function pointers to handle event tracing calls.
|
||||
//
|
||||
// * GetCategoryEnabledPtr
|
||||
// Event tracing system calls this function to determine if a particular
|
||||
// event category is enabled.
|
||||
//
|
||||
// * AddTraceEventPtr
|
||||
// Adds a tracing event. It is the user's responsibility to log the data
|
||||
// provided.
|
||||
//
|
||||
// Parameters for the above two functions are described in trace_event.h.
|
||||
|
||||
#ifndef WEBRTC_BASE_EVENT_TRACER_H_
|
||||
#define WEBRTC_BASE_EVENT_TRACER_H_
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
typedef const unsigned char* (*GetCategoryEnabledPtr)(const char* name);
|
||||
typedef void (*AddTraceEventPtr)(char phase,
|
||||
const unsigned char* category_enabled,
|
||||
const char* name,
|
||||
unsigned long long id,
|
||||
int num_args,
|
||||
const char** arg_names,
|
||||
const unsigned char* arg_types,
|
||||
const unsigned long long* arg_values,
|
||||
unsigned char flags);
|
||||
|
||||
// User of WebRTC can call this method to setup event tracing.
|
||||
//
|
||||
// This method must be called before any WebRTC methods. Functions
|
||||
// provided should be thread-safe.
|
||||
void SetupEventTracer(
|
||||
GetCategoryEnabledPtr get_category_enabled_ptr,
|
||||
AddTraceEventPtr add_trace_event_ptr);
|
||||
|
||||
// This class defines interface for the event tracing system to call
|
||||
// internally. Do not call these methods directly.
|
||||
class EventTracer {
|
||||
public:
|
||||
static const unsigned char* GetCategoryEnabled(
|
||||
const char* name);
|
||||
|
||||
static void AddTraceEvent(
|
||||
char phase,
|
||||
const unsigned char* category_enabled,
|
||||
const char* name,
|
||||
unsigned long long id,
|
||||
int num_args,
|
||||
const char** arg_names,
|
||||
const unsigned char* arg_types,
|
||||
const unsigned long long* arg_values,
|
||||
unsigned char flags);
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_BASE_EVENT_TRACER_H_
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* Copyright (c) 2012 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.
|
||||
*/
|
||||
|
||||
#include "webrtc/base/event_tracer.h"
|
||||
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/system_wrappers/interface/static_instance.h"
|
||||
#include "webrtc/system_wrappers/interface/trace_event.h"
|
||||
|
||||
namespace {
|
||||
|
||||
class TestStatistics {
|
||||
public:
|
||||
TestStatistics() : events_logged_(0) {
|
||||
}
|
||||
|
||||
void Reset() {
|
||||
events_logged_ = 0;
|
||||
}
|
||||
|
||||
void Increment() {
|
||||
++events_logged_;
|
||||
}
|
||||
|
||||
int Count() const { return events_logged_; }
|
||||
|
||||
static TestStatistics* Get() {
|
||||
static TestStatistics* test_stats = NULL;
|
||||
if (!test_stats)
|
||||
test_stats = new TestStatistics();
|
||||
return test_stats;
|
||||
}
|
||||
|
||||
private:
|
||||
int events_logged_;
|
||||
};
|
||||
|
||||
static const unsigned char* GetCategoryEnabledHandler(const char* name) {
|
||||
return reinterpret_cast<const unsigned char*>("test");
|
||||
}
|
||||
|
||||
static void AddTraceEventHandler(char phase,
|
||||
const unsigned char* category_enabled,
|
||||
const char* name,
|
||||
unsigned long long id,
|
||||
int num_args,
|
||||
const char** arg_names,
|
||||
const unsigned char* arg_types,
|
||||
const unsigned long long* arg_values,
|
||||
unsigned char flags) {
|
||||
TestStatistics::Get()->Increment();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
TEST(EventTracerTest, EventTracerDisabled) {
|
||||
{
|
||||
TRACE_EVENT0("test", "EventTracerDisabled");
|
||||
}
|
||||
EXPECT_FALSE(TestStatistics::Get()->Count());
|
||||
TestStatistics::Get()->Reset();
|
||||
}
|
||||
|
||||
TEST(EventTracerTest, ScopedTraceEvent) {
|
||||
SetupEventTracer(&GetCategoryEnabledHandler, &AddTraceEventHandler);
|
||||
{
|
||||
TRACE_EVENT0("test", "ScopedTraceEvent");
|
||||
}
|
||||
EXPECT_EQ(2, TestStatistics::Get()->Count());
|
||||
TestStatistics::Get()->Reset();
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
|
@ -40,8 +40,9 @@ class FileLockTest : public testing::Test, public Runnable {
|
|||
protected:
|
||||
virtual void SetUp() {
|
||||
thread_lock_failed_ = false;
|
||||
Filesystem::GetAppTempFolder(&temp_dir_);
|
||||
temp_file_ = Pathname(temp_dir_.pathname(), kLockFile);
|
||||
Pathname temp_dir;
|
||||
Filesystem::GetAppTempFolder(&temp_dir);
|
||||
temp_file_.SetPathname(rtc::Filesystem::TempFilename(temp_dir, kLockFile));
|
||||
}
|
||||
|
||||
void LockOnThread() {
|
||||
|
@ -52,7 +53,6 @@ class FileLockTest : public testing::Test, public Runnable {
|
|||
Event done_;
|
||||
Thread locker_;
|
||||
bool thread_lock_failed_;
|
||||
Pathname temp_dir_;
|
||||
Pathname temp_file_;
|
||||
};
|
||||
|
||||
|
|
|
@ -148,6 +148,10 @@ FilesystemInterface *Filesystem::EnsureDefaultFilesystem() {
|
|||
return default_filesystem_;
|
||||
}
|
||||
|
||||
DirectoryIterator* FilesystemInterface::IterateDirectory() {
|
||||
return new DirectoryIterator();
|
||||
}
|
||||
|
||||
bool FilesystemInterface::CopyFolder(const Pathname &old_path,
|
||||
const Pathname &new_path) {
|
||||
bool success = true;
|
||||
|
@ -208,6 +212,10 @@ bool FilesystemInterface::DeleteFolderContents(const Pathname &folder) {
|
|||
return success;
|
||||
}
|
||||
|
||||
bool FilesystemInterface::DeleteFolderAndContents(const Pathname& folder) {
|
||||
return DeleteFolderContents(folder) && DeleteEmptyFolder(folder);
|
||||
}
|
||||
|
||||
bool FilesystemInterface::CleanAppTempFolder() {
|
||||
Pathname path;
|
||||
if (!GetAppTempFolder(&path))
|
||||
|
|
|
@ -95,9 +95,7 @@ class FilesystemInterface {
|
|||
|
||||
// Returns a DirectoryIterator for a given pathname.
|
||||
// TODO: Do fancy abstracted stuff
|
||||
virtual DirectoryIterator *IterateDirectory() {
|
||||
return new DirectoryIterator();
|
||||
}
|
||||
virtual DirectoryIterator* IterateDirectory();
|
||||
|
||||
// Opens a file. Returns an open StreamInterface if function succeeds.
|
||||
// Otherwise, returns NULL.
|
||||
|
@ -133,9 +131,7 @@ class FilesystemInterface {
|
|||
|
||||
// This deletes the contents of a folder, recursively, and then deletes
|
||||
// the folder itself.
|
||||
virtual bool DeleteFolderAndContents(const Pathname &folder) {
|
||||
return DeleteFolderContents(folder) && DeleteEmptyFolder(folder);
|
||||
}
|
||||
virtual bool DeleteFolderAndContents(const Pathname& folder);
|
||||
|
||||
// This will delete whatever is located at path, be it a file or a folder.
|
||||
// If it is a folder, it will delete it recursively by calling
|
||||
|
|
|
@ -25,7 +25,7 @@ class FirewallSocket : public AsyncSocketAdapter {
|
|||
: AsyncSocketAdapter(socket), server_(server), type_(type) {
|
||||
}
|
||||
|
||||
virtual int Connect(const SocketAddress& addr) {
|
||||
int Connect(const SocketAddress& addr) override {
|
||||
if (type_ == SOCK_STREAM) {
|
||||
if (!server_->Check(FP_TCP, GetLocalAddress(), addr)) {
|
||||
LOG(LS_VERBOSE) << "FirewallSocket outbound TCP connection from "
|
||||
|
@ -38,10 +38,10 @@ class FirewallSocket : public AsyncSocketAdapter {
|
|||
}
|
||||
return AsyncSocketAdapter::Connect(addr);
|
||||
}
|
||||
virtual int Send(const void* pv, size_t cb) {
|
||||
int Send(const void* pv, size_t cb) override {
|
||||
return SendTo(pv, cb, GetRemoteAddress());
|
||||
}
|
||||
virtual int SendTo(const void* pv, size_t cb, const SocketAddress& addr) {
|
||||
int SendTo(const void* pv, size_t cb, const SocketAddress& addr) override {
|
||||
if (type_ == SOCK_DGRAM) {
|
||||
if (!server_->Check(FP_UDP, GetLocalAddress(), addr)) {
|
||||
LOG(LS_VERBOSE) << "FirewallSocket outbound UDP packet from "
|
||||
|
@ -52,11 +52,11 @@ class FirewallSocket : public AsyncSocketAdapter {
|
|||
}
|
||||
return AsyncSocketAdapter::SendTo(pv, cb, addr);
|
||||
}
|
||||
virtual int Recv(void* pv, size_t cb) {
|
||||
int Recv(void* pv, size_t cb) override {
|
||||
SocketAddress addr;
|
||||
return RecvFrom(pv, cb, &addr);
|
||||
}
|
||||
virtual int RecvFrom(void* pv, size_t cb, SocketAddress* paddr) {
|
||||
int RecvFrom(void* pv, size_t cb, SocketAddress* paddr) override {
|
||||
if (type_ == SOCK_DGRAM) {
|
||||
while (true) {
|
||||
int res = AsyncSocketAdapter::RecvFrom(pv, cb, paddr);
|
||||
|
@ -72,7 +72,7 @@ class FirewallSocket : public AsyncSocketAdapter {
|
|||
return AsyncSocketAdapter::RecvFrom(pv, cb, paddr);
|
||||
}
|
||||
|
||||
virtual int Listen(int backlog) {
|
||||
int Listen(int backlog) override {
|
||||
if (!server_->tcp_listen_enabled()) {
|
||||
LOG(LS_VERBOSE) << "FirewallSocket listen attempt denied";
|
||||
return -1;
|
||||
|
@ -80,7 +80,7 @@ class FirewallSocket : public AsyncSocketAdapter {
|
|||
|
||||
return AsyncSocketAdapter::Listen(backlog);
|
||||
}
|
||||
virtual AsyncSocket* Accept(SocketAddress* paddr) {
|
||||
AsyncSocket* Accept(SocketAddress* paddr) override {
|
||||
SocketAddress addr;
|
||||
while (AsyncSocket* sock = AsyncSocketAdapter::Accept(&addr)) {
|
||||
if (server_->Check(FP_TCP, addr, GetLocalAddress())) {
|
||||
|
@ -190,6 +190,18 @@ AsyncSocket* FirewallSocketServer::CreateAsyncSocket(int family, int type) {
|
|||
return WrapSocket(server_->CreateAsyncSocket(family, type), type);
|
||||
}
|
||||
|
||||
void FirewallSocketServer::SetMessageQueue(MessageQueue* queue) {
|
||||
server_->SetMessageQueue(queue);
|
||||
}
|
||||
|
||||
bool FirewallSocketServer::Wait(int cms, bool process_io) {
|
||||
return server_->Wait(cms, process_io);
|
||||
}
|
||||
|
||||
void FirewallSocketServer::WakeUp() {
|
||||
return server_->WakeUp();
|
||||
}
|
||||
|
||||
AsyncSocket* FirewallSocketServer::WrapSocket(AsyncSocket* sock, int type) {
|
||||
if (!sock ||
|
||||
(type == SOCK_STREAM && !tcp_sockets_enabled_) ||
|
||||
|
|
|
@ -29,7 +29,7 @@ class FirewallSocketServer : public SocketServer {
|
|||
FirewallSocketServer(SocketServer * server,
|
||||
FirewallManager * manager = NULL,
|
||||
bool should_delete_server = false);
|
||||
virtual ~FirewallSocketServer();
|
||||
~FirewallSocketServer() override;
|
||||
|
||||
SocketServer* socketserver() const { return server_; }
|
||||
void set_socketserver(SocketServer* server) {
|
||||
|
@ -58,21 +58,15 @@ class FirewallSocketServer : public SocketServer {
|
|||
bool Check(FirewallProtocol p,
|
||||
const SocketAddress& src, const SocketAddress& dst);
|
||||
|
||||
virtual Socket* CreateSocket(int type);
|
||||
virtual Socket* CreateSocket(int family, int type);
|
||||
Socket* CreateSocket(int type) override;
|
||||
Socket* CreateSocket(int family, int type) override;
|
||||
|
||||
virtual AsyncSocket* CreateAsyncSocket(int type);
|
||||
virtual AsyncSocket* CreateAsyncSocket(int family, int type);
|
||||
AsyncSocket* CreateAsyncSocket(int type) override;
|
||||
AsyncSocket* CreateAsyncSocket(int family, int type) override;
|
||||
|
||||
virtual void SetMessageQueue(MessageQueue* queue) {
|
||||
server_->SetMessageQueue(queue);
|
||||
}
|
||||
virtual bool Wait(int cms, bool process_io) {
|
||||
return server_->Wait(cms, process_io);
|
||||
}
|
||||
virtual void WakeUp() {
|
||||
return server_->WakeUp();
|
||||
}
|
||||
void SetMessageQueue(MessageQueue* queue) override;
|
||||
bool Wait(int cms, bool process_io) override;
|
||||
void WakeUp() override;
|
||||
|
||||
Socket * WrapSocket(Socket * sock, int type);
|
||||
AsyncSocket * WrapSocket(AsyncSocket * sock, int type);
|
||||
|
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* Copyright (c) 2014 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_BASE_FORMAT_MACROS_H_
|
||||
#define WEBRTC_BASE_FORMAT_MACROS_H_
|
||||
|
||||
// This file defines the format macros for some integer types and is derived
|
||||
// from Chromium's base/format_macros.h.
|
||||
|
||||
// To print a 64-bit value in a portable way:
|
||||
// int64_t value;
|
||||
// printf("xyz:%" PRId64, value);
|
||||
// The "d" in the macro corresponds to %d; you can also use PRIu64 etc.
|
||||
//
|
||||
// To print a size_t value in a portable way:
|
||||
// size_t size;
|
||||
// printf("xyz: %" PRIuS, size);
|
||||
// The "u" in the macro corresponds to %u, and S is for "size".
|
||||
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
#if defined(WEBRTC_POSIX)
|
||||
|
||||
#if (defined(_INTTYPES_H) || defined(_INTTYPES_H_)) && !defined(PRId64)
|
||||
#error "inttypes.h has already been included before this header file, but "
|
||||
#error "without __STDC_FORMAT_MACROS defined."
|
||||
#endif
|
||||
|
||||
#if !defined(__STDC_FORMAT_MACROS)
|
||||
#define __STDC_FORMAT_MACROS
|
||||
#endif
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#if !defined(PRIuS)
|
||||
#define PRIuS "zu"
|
||||
#endif
|
||||
|
||||
// The size of NSInteger and NSUInteger varies between 32-bit and 64-bit
|
||||
// architectures and Apple does not provides standard format macros and
|
||||
// recommends casting. This has many drawbacks, so instead define macros
|
||||
// for formatting those types.
|
||||
#if defined(WEBRTC_MAC)
|
||||
#if defined(WEBRTC_ARCH_64_BITS)
|
||||
#if !defined(PRIdNS)
|
||||
#define PRIdNS "ld"
|
||||
#endif
|
||||
#if !defined(PRIuNS)
|
||||
#define PRIuNS "lu"
|
||||
#endif
|
||||
#if !defined(PRIxNS)
|
||||
#define PRIxNS "lx"
|
||||
#endif
|
||||
#else // defined(WEBRTC_ARCH_64_BITS)
|
||||
#if !defined(PRIdNS)
|
||||
#define PRIdNS "d"
|
||||
#endif
|
||||
#if !defined(PRIuNS)
|
||||
#define PRIuNS "u"
|
||||
#endif
|
||||
#if !defined(PRIxNS)
|
||||
#define PRIxNS "x"
|
||||
#endif
|
||||
#endif
|
||||
#endif // defined(WEBRTC_MAC)
|
||||
|
||||
#else // WEBRTC_WIN
|
||||
|
||||
#if !defined(PRId64)
|
||||
#define PRId64 "I64d"
|
||||
#endif
|
||||
|
||||
#if !defined(PRIu64)
|
||||
#define PRIu64 "I64u"
|
||||
#endif
|
||||
|
||||
#if !defined(PRIx64)
|
||||
#define PRIx64 "I64x"
|
||||
#endif
|
||||
|
||||
#if !defined(PRIuS)
|
||||
#define PRIuS "Iu"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif // WEBRTC_BASE_FORMAT_MACROS_H_
|
|
@ -51,11 +51,9 @@ class RandomGenerator {
|
|||
class SecureRandomGenerator : public RandomGenerator {
|
||||
public:
|
||||
SecureRandomGenerator() {}
|
||||
~SecureRandomGenerator() {}
|
||||
virtual bool Init(const void* seed, size_t len) {
|
||||
return true;
|
||||
}
|
||||
virtual bool Generate(void* buf, size_t len) {
|
||||
~SecureRandomGenerator() override {}
|
||||
bool Init(const void* seed, size_t len) override { return true; }
|
||||
bool Generate(void* buf, size_t len) override {
|
||||
return (RAND_bytes(reinterpret_cast<unsigned char*>(buf), len) > 0);
|
||||
}
|
||||
};
|
||||
|
@ -65,11 +63,9 @@ class SecureRandomGenerator : public RandomGenerator {
|
|||
class SecureRandomGenerator : public RandomGenerator {
|
||||
public:
|
||||
SecureRandomGenerator() {}
|
||||
~SecureRandomGenerator() {}
|
||||
virtual bool Init(const void* seed, size_t len) {
|
||||
return true;
|
||||
}
|
||||
virtual bool Generate(void* buf, size_t len) {
|
||||
~SecureRandomGenerator() override {}
|
||||
bool Init(const void* seed, size_t len) override { return true; }
|
||||
bool Generate(void* buf, size_t len) override {
|
||||
return (PK11_GenerateRandom(reinterpret_cast<unsigned char*>(buf),
|
||||
static_cast<int>(len)) == SECSuccess);
|
||||
}
|
||||
|
@ -153,12 +149,10 @@ class TestRandomGenerator : public RandomGenerator {
|
|||
public:
|
||||
TestRandomGenerator() : seed_(7) {
|
||||
}
|
||||
~TestRandomGenerator() {
|
||||
~TestRandomGenerator() override {
|
||||
}
|
||||
virtual bool Init(const void* seed, size_t len) {
|
||||
return true;
|
||||
}
|
||||
virtual bool Generate(void* buf, size_t len) {
|
||||
bool Init(const void* seed, size_t len) override { return true; }
|
||||
bool Generate(void* buf, size_t len) override {
|
||||
for (size_t i = 0; i < len; ++i) {
|
||||
static_cast<uint8*>(buf)[i] = static_cast<uint8>(GetRandom());
|
||||
}
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
|
||||
#if defined(WEBRTC_WIN)
|
||||
#include "webrtc/base/win32.h"
|
||||
#else // !WEBRTC_WIN
|
||||
#else // !WEBRTC_WIN
|
||||
#define SEC_E_CERT_EXPIRED (-2146893016)
|
||||
#endif // !WEBRTC_WIN
|
||||
#endif // !WEBRTC_WIN
|
||||
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/httpbase.h"
|
||||
|
@ -234,7 +234,7 @@ public:
|
|||
BlockingMemoryStream(char* buffer, size_t size)
|
||||
: ExternalMemoryStream(buffer, size) { }
|
||||
|
||||
virtual StreamResult DoReserve(size_t size, int* error) {
|
||||
StreamResult DoReserve(size_t size, int* error) override {
|
||||
return (buffer_length_ >= size) ? SR_SUCCESS : SR_BLOCK;
|
||||
}
|
||||
};
|
||||
|
@ -243,7 +243,7 @@ class HttpBase::DocumentStream : public StreamInterface {
|
|||
public:
|
||||
DocumentStream(HttpBase* base) : base_(base), error_(HE_DEFAULT) { }
|
||||
|
||||
virtual StreamState GetState() const {
|
||||
StreamState GetState() const override {
|
||||
if (NULL == base_)
|
||||
return SS_CLOSED;
|
||||
if (HM_RECV == base_->mode_)
|
||||
|
@ -251,8 +251,10 @@ public:
|
|||
return SS_OPENING;
|
||||
}
|
||||
|
||||
virtual StreamResult Read(void* buffer, size_t buffer_len,
|
||||
size_t* read, int* error) {
|
||||
StreamResult Read(void* buffer,
|
||||
size_t buffer_len,
|
||||
size_t* read,
|
||||
int* error) override {
|
||||
if (!base_) {
|
||||
if (error) *error = error_;
|
||||
return (HE_NONE == error_) ? SR_EOS : SR_ERROR;
|
||||
|
@ -309,13 +311,15 @@ public:
|
|||
return result;
|
||||
}
|
||||
|
||||
virtual StreamResult Write(const void* data, size_t data_len,
|
||||
size_t* written, int* error) {
|
||||
StreamResult Write(const void* data,
|
||||
size_t data_len,
|
||||
size_t* written,
|
||||
int* error) override {
|
||||
if (error) *error = -1;
|
||||
return SR_ERROR;
|
||||
}
|
||||
|
||||
virtual void Close() {
|
||||
void Close() override {
|
||||
if (base_) {
|
||||
HttpBase* base = Disconnect(HE_NONE);
|
||||
if (HM_RECV == base->mode_ && base->http_stream_) {
|
||||
|
@ -326,7 +330,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
virtual bool GetAvailable(size_t* size) const {
|
||||
bool GetAvailable(size_t* size) const override {
|
||||
if (!base_ || HM_RECV != base_->mode_)
|
||||
return false;
|
||||
size_t data_size = base_->GetDataRemaining();
|
||||
|
@ -528,8 +532,9 @@ bool HttpBase::DoReceiveLoop(HttpError* error) {
|
|||
// Attempt to process the data already in our buffer.
|
||||
break;
|
||||
case SR_EOS:
|
||||
// Clean close, with no error. Fall through to HandleStreamClose.
|
||||
// Clean close, with no error.
|
||||
read_error = 0;
|
||||
FALLTHROUGH(); // Fall through to HandleStreamClose.
|
||||
case SR_ERROR:
|
||||
*error = HandleStreamClose(read_error);
|
||||
return true;
|
||||
|
|
|
@ -94,7 +94,7 @@ class HttpBase
|
|||
{
|
||||
public:
|
||||
HttpBase();
|
||||
virtual ~HttpBase();
|
||||
~HttpBase() override;
|
||||
|
||||
void notify(IHttpNotify* notify) { notify_ = notify; }
|
||||
bool attach(StreamInterface* stream);
|
||||
|
@ -145,16 +145,22 @@ protected:
|
|||
void OnDocumentEvent(StreamInterface* stream, int events, int error);
|
||||
|
||||
// HttpParser Interface
|
||||
virtual ProcessResult ProcessLeader(const char* line, size_t len,
|
||||
HttpError* error);
|
||||
virtual ProcessResult ProcessHeader(const char* name, size_t nlen,
|
||||
const char* value, size_t vlen,
|
||||
HttpError* error);
|
||||
virtual ProcessResult ProcessHeaderComplete(bool chunked, size_t& data_size,
|
||||
HttpError* error);
|
||||
virtual ProcessResult ProcessData(const char* data, size_t len, size_t& read,
|
||||
HttpError* error);
|
||||
virtual void OnComplete(HttpError err);
|
||||
ProcessResult ProcessLeader(const char* line,
|
||||
size_t len,
|
||||
HttpError* error) override;
|
||||
ProcessResult ProcessHeader(const char* name,
|
||||
size_t nlen,
|
||||
const char* value,
|
||||
size_t vlen,
|
||||
HttpError* error) override;
|
||||
ProcessResult ProcessHeaderComplete(bool chunked,
|
||||
size_t& data_size,
|
||||
HttpError* error) override;
|
||||
ProcessResult ProcessData(const char* data,
|
||||
size_t len,
|
||||
size_t& read,
|
||||
HttpError* error) override;
|
||||
void OnComplete(HttpError err) override;
|
||||
|
||||
private:
|
||||
class DocumentStream;
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "webrtc/base/gunit.h"
|
||||
#include "webrtc/base/httpbase.h"
|
||||
#include "webrtc/base/testutils.h"
|
||||
|
@ -229,7 +231,8 @@ void HttpBaseTest::ReadDocumentStreamData(const char* expected_data) {
|
|||
while (verified_length < expected_length) {
|
||||
size_t read = 0;
|
||||
char buffer[5] = { 0 };
|
||||
size_t amt_to_read = _min(expected_length - verified_length, sizeof(buffer));
|
||||
size_t amt_to_read =
|
||||
std::min(expected_length - verified_length, sizeof(buffer));
|
||||
EXPECT_EQ(SR_SUCCESS, http_stream->Read(buffer, amt_to_read, &read, NULL));
|
||||
EXPECT_EQ(amt_to_read, read);
|
||||
EXPECT_TRUE(0 == memcmp(expected_data + verified_length, buffer, read));
|
||||
|
|
|
@ -9,13 +9,12 @@
|
|||
*/
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include "webrtc/base/httpcommon-inl.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include "webrtc/base/asyncsocket.h"
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/diskcache.h"
|
||||
#include "webrtc/base/httpclient.h"
|
||||
#include "webrtc/base/httpcommon-inl.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/base/pathutils.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
|
@ -119,7 +118,7 @@ HttpCacheState HttpGetCacheState(const HttpTransaction& t) {
|
|||
if (t.response.hasHeader(HH_AGE, &s_temp)
|
||||
&& HttpStringToUInt(s_temp, (&i_temp))) {
|
||||
u_temp = static_cast<time_t>(i_temp);
|
||||
corrected_received_age = stdmax(apparent_age, u_temp);
|
||||
corrected_received_age = std::max(apparent_age, u_temp);
|
||||
}
|
||||
|
||||
time_t response_delay = response_time - request_time;
|
||||
|
@ -540,6 +539,7 @@ bool HttpClient::CheckCache() {
|
|||
return false;
|
||||
}
|
||||
// Couldn't validate, fall through.
|
||||
FALLTHROUGH();
|
||||
case HCS_NONE:
|
||||
// Cache content is not useable. Issue a regular request.
|
||||
response().clear(false);
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
// be freed by the caller. Otherwise, an internal object is allocated.
|
||||
HttpClient(const std::string& agent, StreamPool* pool,
|
||||
HttpTransaction* transaction = NULL);
|
||||
virtual ~HttpClient();
|
||||
~HttpClient() override;
|
||||
|
||||
void set_pool(StreamPool* pool) { pool_ = pool; }
|
||||
|
||||
|
@ -161,10 +161,10 @@ protected:
|
|||
void OnResolveResult(AsyncResolverInterface* resolver);
|
||||
|
||||
// IHttpNotify Interface
|
||||
virtual HttpError onHttpHeaderComplete(bool chunked, size_t& data_size);
|
||||
virtual void onHttpComplete(HttpMode mode, HttpError err);
|
||||
virtual void onHttpClosed(HttpError err);
|
||||
|
||||
HttpError onHttpHeaderComplete(bool chunked, size_t& data_size) override;
|
||||
void onHttpComplete(HttpMode mode, HttpError err) override;
|
||||
void onHttpClosed(HttpError err) override;
|
||||
|
||||
private:
|
||||
enum CacheState { CS_READY, CS_WRITING, CS_READING, CS_VALIDATING };
|
||||
bool IsCacheActive() const { return (cache_state_ > CS_READY); }
|
||||
|
|
|
@ -19,14 +19,15 @@
|
|||
#include <security.h>
|
||||
#endif
|
||||
|
||||
#include "webrtc/base/httpcommon-inl.h"
|
||||
#include <algorithm>
|
||||
|
||||
#include "webrtc/base/base64.h"
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/cryptstring.h"
|
||||
#include "webrtc/base/httpcommon-inl.h"
|
||||
#include "webrtc/base/httpcommon.h"
|
||||
#include "webrtc/base/messagedigest.h"
|
||||
#include "webrtc/base/socketaddress.h"
|
||||
#include "webrtc/base/stringdigest.h"
|
||||
#include "webrtc/base/stringencode.h"
|
||||
#include "webrtc/base/stringutils.h"
|
||||
|
||||
|
@ -400,6 +401,11 @@ std::string HttpAddress(const SocketAddress& address, bool secure) {
|
|||
// HttpData
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
HttpData::HttpData() : version(HVER_1_1) {
|
||||
}
|
||||
|
||||
HttpData::~HttpData() = default;
|
||||
|
||||
void
|
||||
HttpData::clear(bool release_document) {
|
||||
// Clear headers first, since releasing a document may have far-reaching
|
||||
|
@ -954,26 +960,26 @@ HttpAuthResult HttpAuthenticate(
|
|||
std::string::size_type pos = username.find('\\');
|
||||
if (pos == std::string::npos) {
|
||||
auth_id.UserLength = static_cast<unsigned long>(
|
||||
_min(sizeof(userbuf) - 1, username.size()));
|
||||
std::min(sizeof(userbuf) - 1, username.size()));
|
||||
memcpy(userbuf, username.c_str(), auth_id.UserLength);
|
||||
userbuf[auth_id.UserLength] = 0;
|
||||
auth_id.DomainLength = 0;
|
||||
domainbuf[auth_id.DomainLength] = 0;
|
||||
auth_id.PasswordLength = static_cast<unsigned long>(
|
||||
_min(sizeof(passbuf) - 1, password.GetLength()));
|
||||
std::min(sizeof(passbuf) - 1, password.GetLength()));
|
||||
memcpy(passbuf, sensitive, auth_id.PasswordLength);
|
||||
passbuf[auth_id.PasswordLength] = 0;
|
||||
} else {
|
||||
auth_id.UserLength = static_cast<unsigned long>(
|
||||
_min(sizeof(userbuf) - 1, username.size() - pos - 1));
|
||||
std::min(sizeof(userbuf) - 1, username.size() - pos - 1));
|
||||
memcpy(userbuf, username.c_str() + pos + 1, auth_id.UserLength);
|
||||
userbuf[auth_id.UserLength] = 0;
|
||||
auth_id.DomainLength = static_cast<unsigned long>(
|
||||
_min(sizeof(domainbuf) - 1, pos));
|
||||
auth_id.DomainLength =
|
||||
static_cast<unsigned long>(std::min(sizeof(domainbuf) - 1, pos));
|
||||
memcpy(domainbuf, username.c_str(), auth_id.DomainLength);
|
||||
domainbuf[auth_id.DomainLength] = 0;
|
||||
auth_id.PasswordLength = static_cast<unsigned long>(
|
||||
_min(sizeof(passbuf) - 1, password.GetLength()));
|
||||
std::min(sizeof(passbuf) - 1, password.GetLength()));
|
||||
memcpy(passbuf, sensitive, auth_id.PasswordLength);
|
||||
passbuf[auth_id.PasswordLength] = 0;
|
||||
}
|
||||
|
|
|
@ -283,7 +283,7 @@ struct HttpData {
|
|||
HttpVersion version;
|
||||
scoped_ptr<StreamInterface> document;
|
||||
|
||||
HttpData() : version(HVER_1_1) { }
|
||||
HttpData();
|
||||
|
||||
enum HeaderCombine { HC_YES, HC_NO, HC_AUTO, HC_REPLACE, HC_NEW };
|
||||
void changeHeader(const std::string& name, const std::string& value,
|
||||
|
@ -368,7 +368,7 @@ struct HttpData {
|
|||
virtual HttpError parseLeader(const char* line, size_t len) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~HttpData() { }
|
||||
virtual ~HttpData();
|
||||
void clear(bool release_document);
|
||||
void copy(const HttpData& src);
|
||||
|
||||
|
@ -385,8 +385,8 @@ struct HttpRequestData : public HttpData {
|
|||
void clear(bool release_document);
|
||||
void copy(const HttpRequestData& src);
|
||||
|
||||
virtual size_t formatLeader(char* buffer, size_t size) const;
|
||||
virtual HttpError parseLeader(const char* line, size_t len);
|
||||
size_t formatLeader(char* buffer, size_t size) const override;
|
||||
HttpError parseLeader(const char* line, size_t len) override;
|
||||
|
||||
bool getAbsoluteUri(std::string* uri) const;
|
||||
bool getRelativeUri(std::string* host, std::string* path) const;
|
||||
|
@ -408,8 +408,8 @@ struct HttpResponseData : public HttpData {
|
|||
uint32 scode = HC_MOVED_TEMPORARILY);
|
||||
void set_error(uint32 scode);
|
||||
|
||||
virtual size_t formatLeader(char* buffer, size_t size) const;
|
||||
virtual HttpError parseLeader(const char* line, size_t len);
|
||||
size_t formatLeader(char* buffer, size_t size) const override;
|
||||
HttpError parseLeader(const char* line, size_t len) override;
|
||||
};
|
||||
|
||||
struct HttpTransaction {
|
||||
|
|
|
@ -54,6 +54,8 @@ HttpRequest::HttpRequest(const std::string &user_agent)
|
|||
client_(user_agent.c_str(), NULL), error_(HE_NONE) {
|
||||
}
|
||||
|
||||
HttpRequest::~HttpRequest() = default;
|
||||
|
||||
void HttpRequest::Send() {
|
||||
// TODO: Rewrite this to use the thread's native socket server, and a more
|
||||
// natural flow?
|
||||
|
|
|
@ -30,6 +30,7 @@ class MemoryStream;
|
|||
class HttpRequest {
|
||||
public:
|
||||
HttpRequest(const std::string &user_agent);
|
||||
~HttpRequest();
|
||||
|
||||
void Send();
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ private:
|
|||
class Connection : private IHttpNotify {
|
||||
public:
|
||||
Connection(int connection_id, HttpServer* server);
|
||||
virtual ~Connection();
|
||||
~Connection() override;
|
||||
|
||||
void BeginProcess(StreamInterface* stream);
|
||||
StreamInterface* EndProcess();
|
||||
|
@ -89,10 +89,10 @@ private:
|
|||
void InitiateClose(bool force);
|
||||
|
||||
// IHttpNotify Interface
|
||||
virtual HttpError onHttpHeaderComplete(bool chunked, size_t& data_size);
|
||||
virtual void onHttpComplete(HttpMode mode, HttpError err);
|
||||
virtual void onHttpClosed(HttpError err);
|
||||
|
||||
HttpError onHttpHeaderComplete(bool chunked, size_t& data_size) override;
|
||||
void onHttpComplete(HttpMode mode, HttpError err) override;
|
||||
void onHttpClosed(HttpError err) override;
|
||||
|
||||
int connection_id_;
|
||||
HttpServer* server_;
|
||||
HttpBase base_;
|
||||
|
@ -116,7 +116,7 @@ private:
|
|||
class HttpListenServer : public HttpServer, public sigslot::has_slots<> {
|
||||
public:
|
||||
HttpListenServer();
|
||||
virtual ~HttpListenServer();
|
||||
~HttpListenServer() override;
|
||||
|
||||
int Listen(const SocketAddress& address);
|
||||
bool GetAddress(SocketAddress* address) const;
|
||||
|
|
|
@ -275,7 +275,7 @@ bool IPIsAny(const IPAddress& ip) {
|
|||
case AF_INET:
|
||||
return ip == IPAddress(INADDR_ANY);
|
||||
case AF_INET6:
|
||||
return ip == IPAddress(in6addr_any);
|
||||
return ip == IPAddress(in6addr_any) || ip == IPAddress(kV4MappedPrefix);
|
||||
case AF_UNSPEC:
|
||||
return false;
|
||||
}
|
||||
|
@ -300,9 +300,7 @@ bool IPIsPrivate(const IPAddress& ip) {
|
|||
return IsPrivateV4(ip.v4AddressAsHostOrderInteger());
|
||||
}
|
||||
case AF_INET6: {
|
||||
in6_addr v6 = ip.ipv6_address();
|
||||
return (v6.s6_addr[0] == 0xFE && v6.s6_addr[1] == 0x80) ||
|
||||
IPIsLoopback(ip);
|
||||
return IPIsLinkLocal(ip) || IPIsLoopback(ip);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -432,6 +430,21 @@ bool IPIs6To4(const IPAddress& ip) {
|
|||
return IPIsHelper(ip, k6To4Prefix, 16);
|
||||
}
|
||||
|
||||
bool IPIsLinkLocal(const IPAddress& ip) {
|
||||
// Can't use the helper because the prefix is 10 bits.
|
||||
in6_addr addr = ip.ipv6_address();
|
||||
return addr.s6_addr[0] == 0xFE && addr.s6_addr[1] == 0x80;
|
||||
}
|
||||
|
||||
// According to http://www.ietf.org/rfc/rfc2373.txt, Appendix A, page 19. An
|
||||
// address which contains MAC will have its 11th and 12th bytes as FF:FE as well
|
||||
// as the U/L bit as 1.
|
||||
bool IPIsMacBased(const IPAddress& ip) {
|
||||
in6_addr addr = ip.ipv6_address();
|
||||
return ((addr.s6_addr[8] & 0x02) && addr.s6_addr[11] == 0xFF &&
|
||||
addr.s6_addr[12] == 0xFE);
|
||||
}
|
||||
|
||||
bool IPIsSiteLocal(const IPAddress& ip) {
|
||||
// Can't use the helper because the prefix is 10 bits.
|
||||
in6_addr addr = ip.ipv6_address();
|
||||
|
|
|
@ -162,6 +162,8 @@ size_t HashIP(const IPAddress& ip);
|
|||
// These are only really applicable for IPv6 addresses.
|
||||
bool IPIs6Bone(const IPAddress& ip);
|
||||
bool IPIs6To4(const IPAddress& ip);
|
||||
bool IPIsLinkLocal(const IPAddress& ip);
|
||||
bool IPIsMacBased(const IPAddress& ip);
|
||||
bool IPIsSiteLocal(const IPAddress& ip);
|
||||
bool IPIsTeredo(const IPAddress& ip);
|
||||
bool IPIsULA(const IPAddress& ip);
|
||||
|
|
|
@ -46,6 +46,10 @@ static const std::string kIPv4PublicAddrAnonymizedString = "1.2.3.x";
|
|||
static const std::string kIPv6AnyAddrString = "::";
|
||||
static const std::string kIPv6LoopbackAddrString = "::1";
|
||||
static const std::string kIPv6LinkLocalAddrString = "fe80::be30:5bff:fee5:c3";
|
||||
static const std::string kIPv6EuiAddrString =
|
||||
"2620:0:1008:1201:a248:1cff:fe98:360";
|
||||
static const std::string kIPv6TemporaryAddrString =
|
||||
"2620:0:1008:1201:2089:6dda:385e:80c0";
|
||||
static const std::string kIPv6PublicAddrString =
|
||||
"2401:fa00:4:1000:be30:5bff:fee5:c3";
|
||||
static const std::string kIPv6PublicAddrAnonymizedString = "2401:fa00:4::";
|
||||
|
@ -552,6 +556,37 @@ TEST(IPAddressTest, TestIsLoopback) {
|
|||
EXPECT_TRUE(IPIsLoopback(IPAddress(in6addr_loopback)));
|
||||
}
|
||||
|
||||
// Verify that IPIsAny catches all cases of "any" address.
|
||||
TEST(IPAddressTest, TestIsAny) {
|
||||
IPAddress addr;
|
||||
|
||||
EXPECT_TRUE(IPFromString(kIPv6AnyAddrString, &addr));
|
||||
EXPECT_TRUE(IPIsAny(addr));
|
||||
|
||||
EXPECT_TRUE(IPFromString(kIPv4AnyAddrString, &addr));
|
||||
EXPECT_TRUE(IPIsAny(addr));
|
||||
|
||||
EXPECT_TRUE(IPIsAny(IPAddress(kIPv4MappedAnyAddr)));
|
||||
}
|
||||
|
||||
TEST(IPAddressTest, TestIsEui64) {
|
||||
IPAddress addr;
|
||||
EXPECT_TRUE(IPFromString(kIPv6EuiAddrString, &addr));
|
||||
EXPECT_TRUE(IPIsMacBased(addr));
|
||||
|
||||
EXPECT_TRUE(IPFromString(kIPv6TemporaryAddrString, &addr));
|
||||
EXPECT_FALSE(IPIsMacBased(addr));
|
||||
|
||||
EXPECT_TRUE(IPFromString(kIPv6LinkLocalAddrString, &addr));
|
||||
EXPECT_TRUE(IPIsMacBased(addr));
|
||||
|
||||
EXPECT_TRUE(IPFromString(kIPv6AnyAddrString, &addr));
|
||||
EXPECT_FALSE(IPIsMacBased(addr));
|
||||
|
||||
EXPECT_TRUE(IPFromString(kIPv6LoopbackAddrString, &addr));
|
||||
EXPECT_FALSE(IPIsMacBased(addr));
|
||||
}
|
||||
|
||||
TEST(IPAddressTest, TestNormalized) {
|
||||
// Check normalizing a ::ffff:a.b.c.d address.
|
||||
IPAddress addr;
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
#include <sstream>
|
||||
|
||||
namespace rtc {
|
||||
|
||||
bool GetStringFromJson(const Json::Value& in, std::string* out) {
|
||||
if (!in.isString()) {
|
||||
std::ostringstream s;
|
||||
|
@ -294,3 +296,5 @@ std::string JsonValueToString(const Json::Value& json) {
|
|||
std::string value = w.write(json);
|
||||
return value.substr(0, value.size() - 1); // trim trailing newline
|
||||
}
|
||||
|
||||
} // namespace rtc
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "third_party/jsoncpp/json.h"
|
||||
#endif
|
||||
|
||||
// TODO: Move to rtc namespace
|
||||
namespace rtc {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// JSON Helpers
|
||||
|
@ -86,4 +86,6 @@ bool GetDoubleFromJsonObject(const Json::Value& in, const std::string& k,
|
|||
// Writes out a Json value as a string.
|
||||
std::string JsonValueToString(const Json::Value& json);
|
||||
|
||||
} // namespace rtc
|
||||
|
||||
#endif // WEBRTC_BASE_JSON_H_
|
||||
|
|
|
@ -8,10 +8,14 @@
|
|||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include "webrtc/base/gunit.h"
|
||||
#include "webrtc/base/json.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/base/gunit.h"
|
||||
|
||||
namespace rtc {
|
||||
|
||||
static Json::Value in_s("foo");
|
||||
static Json::Value in_sn("99");
|
||||
static Json::Value in_si("-99");
|
||||
|
@ -275,3 +279,5 @@ TEST(JsonTest, DoubleVectorToFromArray) {
|
|||
EXPECT_EQ(in[i], outj[i]);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace rtc
|
||||
|
|
|
@ -27,10 +27,11 @@ static const int kMaxLogLineSize = 1024 - 60;
|
|||
#endif // WEBRTC_MAC && !defined(WEBRTC_IOS) || WEBRTC_ANDROID
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include <ostream>
|
||||
#include <iomanip>
|
||||
#include <limits.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <iomanip>
|
||||
#include <ostream>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/base/logging.h"
|
||||
|
@ -247,7 +248,7 @@ int LogMessage::GetLogToStream(StreamInterface* stream) {
|
|||
int sev = NO_LOGGING;
|
||||
for (StreamList::iterator it = streams_.begin(); it != streams_.end(); ++it) {
|
||||
if (!stream || stream == it->first) {
|
||||
sev = _min(sev, it->second);
|
||||
sev = std::min(sev, it->second);
|
||||
}
|
||||
}
|
||||
return sev;
|
||||
|
@ -368,7 +369,7 @@ int LogMessage::ParseLogSeverity(const std::string& value) {
|
|||
void LogMessage::UpdateMinLogSeverity() {
|
||||
int min_sev = dbg_sev_;
|
||||
for (StreamList::iterator it = streams_.begin(); it != streams_.end(); ++it) {
|
||||
min_sev = _min(dbg_sev_, it->second);
|
||||
min_sev = std::min(dbg_sev_, it->second);
|
||||
}
|
||||
min_sev_ = min_sev;
|
||||
}
|
||||
|
@ -524,7 +525,7 @@ void LogMultiline(LoggingSeverity level, const char* label, bool input,
|
|||
while (len > 0) {
|
||||
memset(asc_line, ' ', sizeof(asc_line));
|
||||
memset(hex_line, ' ', sizeof(hex_line));
|
||||
size_t line_len = _min(len, LINE_SIZE);
|
||||
size_t line_len = std::min(len, LINE_SIZE);
|
||||
for (size_t i = 0; i < line_len; ++i) {
|
||||
unsigned char ch = udata[i];
|
||||
asc_line[i] = isprint(ch) ? ch : '.';
|
||||
|
|
|
@ -28,29 +28,30 @@ class MacBaseSocketServer;
|
|||
class MacAsyncSocket : public AsyncSocket, public sigslot::has_slots<> {
|
||||
public:
|
||||
MacAsyncSocket(MacBaseSocketServer* ss, int family);
|
||||
virtual ~MacAsyncSocket();
|
||||
~MacAsyncSocket() override;
|
||||
|
||||
bool valid() const { return source_ != NULL; }
|
||||
|
||||
// Socket interface
|
||||
virtual SocketAddress GetLocalAddress() const;
|
||||
virtual SocketAddress GetRemoteAddress() const;
|
||||
virtual int Bind(const SocketAddress& addr);
|
||||
virtual int Connect(const SocketAddress& addr);
|
||||
virtual int Send(const void* buffer, size_t length);
|
||||
virtual int SendTo(const void* buffer, size_t length,
|
||||
const SocketAddress& addr);
|
||||
virtual int Recv(void* buffer, size_t length);
|
||||
virtual int RecvFrom(void* buffer, size_t length, SocketAddress* out_addr);
|
||||
virtual int Listen(int backlog);
|
||||
virtual MacAsyncSocket* Accept(SocketAddress* out_addr);
|
||||
virtual int Close();
|
||||
virtual int GetError() const;
|
||||
virtual void SetError(int error);
|
||||
virtual ConnState GetState() const;
|
||||
virtual int EstimateMTU(uint16* mtu);
|
||||
virtual int GetOption(Option opt, int* value);
|
||||
virtual int SetOption(Option opt, int value);
|
||||
SocketAddress GetLocalAddress() const override;
|
||||
SocketAddress GetRemoteAddress() const override;
|
||||
int Bind(const SocketAddress& addr) override;
|
||||
int Connect(const SocketAddress& addr) override;
|
||||
int Send(const void* buffer, size_t length) override;
|
||||
int SendTo(const void* buffer,
|
||||
size_t length,
|
||||
const SocketAddress& addr) override;
|
||||
int Recv(void* buffer, size_t length) override;
|
||||
int RecvFrom(void* buffer, size_t length, SocketAddress* out_addr) override;
|
||||
int Listen(int backlog) override;
|
||||
MacAsyncSocket* Accept(SocketAddress* out_addr) override;
|
||||
int Close() override;
|
||||
int GetError() const override;
|
||||
void SetError(int error) override;
|
||||
ConnState GetState() const override;
|
||||
int EstimateMTU(uint16* mtu) override;
|
||||
int GetOption(Option opt, int* value) override;
|
||||
int SetOption(Option opt, int value) override;
|
||||
|
||||
// For the MacBaseSocketServer to disable callbacks when process_io is false.
|
||||
void EnableCallbacks();
|
||||
|
|
|
@ -29,10 +29,10 @@ namespace rtc {
|
|||
class MacCocoaSocketServer : public MacBaseSocketServer {
|
||||
public:
|
||||
explicit MacCocoaSocketServer();
|
||||
virtual ~MacCocoaSocketServer();
|
||||
~MacCocoaSocketServer() override;
|
||||
|
||||
virtual bool Wait(int cms, bool process_io);
|
||||
virtual void WakeUp();
|
||||
bool Wait(int cms, bool process_io) override;
|
||||
void WakeUp() override;
|
||||
|
||||
private:
|
||||
MacCocoaSocketServerHelperRtc* helper_;
|
||||
|
|
|
@ -29,6 +29,14 @@ MacBaseSocketServer::MacBaseSocketServer() {
|
|||
MacBaseSocketServer::~MacBaseSocketServer() {
|
||||
}
|
||||
|
||||
Socket* MacBaseSocketServer::CreateSocket(int type) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Socket* MacBaseSocketServer::CreateSocket(int family, int type) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
AsyncSocket* MacBaseSocketServer::CreateAsyncSocket(int type) {
|
||||
return CreateAsyncSocket(AF_INET, type);
|
||||
}
|
||||
|
|
|
@ -26,23 +26,23 @@ class MacAsyncSocket;
|
|||
class MacBaseSocketServer : public PhysicalSocketServer {
|
||||
public:
|
||||
MacBaseSocketServer();
|
||||
virtual ~MacBaseSocketServer();
|
||||
~MacBaseSocketServer() override;
|
||||
|
||||
// SocketServer Interface
|
||||
virtual Socket* CreateSocket(int type) { return NULL; }
|
||||
virtual Socket* CreateSocket(int family, int type) { return NULL; }
|
||||
Socket* CreateSocket(int type) override;
|
||||
Socket* CreateSocket(int family, int type) override;
|
||||
|
||||
virtual AsyncSocket* CreateAsyncSocket(int type);
|
||||
virtual AsyncSocket* CreateAsyncSocket(int family, int type);
|
||||
AsyncSocket* CreateAsyncSocket(int type) override;
|
||||
AsyncSocket* CreateAsyncSocket(int family, int type) override;
|
||||
|
||||
virtual bool Wait(int cms, bool process_io) = 0;
|
||||
virtual void WakeUp() = 0;
|
||||
bool Wait(int cms, bool process_io) override = 0;
|
||||
void WakeUp() override = 0;
|
||||
|
||||
void RegisterSocket(MacAsyncSocket* socket);
|
||||
void UnregisterSocket(MacAsyncSocket* socket);
|
||||
|
||||
// PhysicalSocketServer Overrides
|
||||
virtual bool SetPosixSignalHandler(int signum, void (*handler)(int));
|
||||
bool SetPosixSignalHandler(int signum, void (*handler)(int)) override;
|
||||
|
||||
protected:
|
||||
void EnableSocketCallbacks(bool enable);
|
||||
|
@ -65,11 +65,11 @@ class MacBaseSocketServer : public PhysicalSocketServer {
|
|||
class MacCFSocketServer : public MacBaseSocketServer {
|
||||
public:
|
||||
MacCFSocketServer();
|
||||
virtual ~MacCFSocketServer();
|
||||
~MacCFSocketServer() override;
|
||||
|
||||
// SocketServer Interface
|
||||
virtual bool Wait(int cms, bool process_io);
|
||||
virtual void WakeUp();
|
||||
bool Wait(int cms, bool process_io) override;
|
||||
void WakeUp() override;
|
||||
void OnWakeUpCallback();
|
||||
|
||||
private:
|
||||
|
|
|
@ -10,9 +10,7 @@
|
|||
|
||||
#include <sstream>
|
||||
|
||||
#ifndef WEBRTC_MOZILLA_BUILD
|
||||
#include "webrtc/base/common.h"
|
||||
#endif
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/base/macutils.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
|
@ -72,9 +70,7 @@ void DecodeFourChar(UInt32 fc, std::string* out) {
|
|||
}
|
||||
|
||||
static bool GetGestalt(OSType ostype, int* value) {
|
||||
#ifndef WEBRTC_MOZILLA_BUILD
|
||||
ASSERT(NULL != value);
|
||||
#endif
|
||||
SInt32 native_value;
|
||||
OSStatus result = Gestalt(ostype, &native_value);
|
||||
if (noErr == result) {
|
||||
|
@ -83,16 +79,12 @@ static bool GetGestalt(OSType ostype, int* value) {
|
|||
}
|
||||
std::string str;
|
||||
DecodeFourChar(ostype, &str);
|
||||
#ifndef WEBRTC_MOZILLA_BUILD
|
||||
LOG_E(LS_ERROR, OS, result) << "Gestalt(" << str << ")";
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GetOSVersion(int* major, int* minor, int* bugfix) {
|
||||
#ifndef WEBRTC_MOZILLA_BUILD
|
||||
ASSERT(major && minor && bugfix);
|
||||
#endif
|
||||
if (!GetGestalt(gestaltSystemVersion, major)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -149,7 +141,6 @@ bool GetQuickTimeVersion(std::string* out) {
|
|||
return true;
|
||||
}
|
||||
|
||||
#ifndef WEBRTC_MOZILLA_BUILD
|
||||
bool RunAppleScript(const std::string& script) {
|
||||
// TODO(thaloun): Add a .mm file that contains something like this:
|
||||
// NSString source from script
|
||||
|
@ -223,8 +214,6 @@ bool RunAppleScript(const std::string& script) {
|
|||
return false;
|
||||
#endif // CARBON_DEPRECATED
|
||||
}
|
||||
#endif // !WEBRTC_MOZILLA
|
||||
|
||||
#endif // WEBRTC_MAC && !defined(WEBRTC_IOS)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -47,12 +47,10 @@ bool GetOSVersion(int* major, int* minor, int* bugfix);
|
|||
MacOSVersionName GetOSVersionName();
|
||||
bool GetQuickTimeVersion(std::string* version);
|
||||
|
||||
#ifndef WEBRTC_MOZILLA_BUILD
|
||||
// Runs the given apple script. Only supports scripts that does not
|
||||
// require user interaction.
|
||||
bool RunAppleScript(const std::string& script);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
|
|
@ -17,14 +17,15 @@ namespace rtc {
|
|||
class MacWindowPicker : public WindowPicker {
|
||||
public:
|
||||
MacWindowPicker();
|
||||
~MacWindowPicker();
|
||||
virtual bool Init();
|
||||
virtual bool IsVisible(const WindowId& id);
|
||||
virtual bool MoveToFront(const WindowId& id);
|
||||
virtual bool GetWindowList(WindowDescriptionList* descriptions);
|
||||
virtual bool GetDesktopList(DesktopDescriptionList* descriptions);
|
||||
virtual bool GetDesktopDimensions(const DesktopId& id, int* width,
|
||||
int* height);
|
||||
~MacWindowPicker() override;
|
||||
bool Init() override;
|
||||
bool IsVisible(const WindowId& id) override;
|
||||
bool MoveToFront(const WindowId& id) override;
|
||||
bool GetWindowList(WindowDescriptionList* descriptions) override;
|
||||
bool GetDesktopList(DesktopDescriptionList* descriptions) override;
|
||||
bool GetDesktopDimensions(const DesktopId& id,
|
||||
int* width,
|
||||
int* height) override;
|
||||
|
||||
private:
|
||||
void* lib_handle_;
|
||||
|
|
|
@ -26,9 +26,6 @@
|
|||
|
||||
namespace rtc {
|
||||
|
||||
// Canonical name for a MD5 context structure, used in many crypto libs.
|
||||
typedef struct MD5Context MD5_CTX;
|
||||
|
||||
struct MD5Context {
|
||||
uint32 buf[4];
|
||||
uint32 bits[2];
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright 2015 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.
|
||||
*/
|
||||
|
||||
#include "webrtc/base/md5digest.h"
|
||||
|
||||
namespace rtc {
|
||||
|
||||
size_t Md5Digest::Size() const {
|
||||
return kSize;
|
||||
}
|
||||
|
||||
void Md5Digest::Update(const void* buf, size_t len) {
|
||||
MD5Update(&ctx_, static_cast<const uint8*>(buf), len);
|
||||
}
|
||||
|
||||
size_t Md5Digest::Finish(void* buf, size_t len) {
|
||||
if (len < kSize) {
|
||||
return 0;
|
||||
}
|
||||
MD5Final(&ctx_, static_cast<uint8*>(buf));
|
||||
MD5Init(&ctx_); // Reset for next use.
|
||||
return kSize;
|
||||
}
|
||||
|
||||
}; // namespace rtc
|
|
@ -23,22 +23,12 @@ class Md5Digest : public MessageDigest {
|
|||
Md5Digest() {
|
||||
MD5Init(&ctx_);
|
||||
}
|
||||
virtual size_t Size() const {
|
||||
return kSize;
|
||||
}
|
||||
virtual void Update(const void* buf, size_t len) {
|
||||
MD5Update(&ctx_, static_cast<const uint8*>(buf), len);
|
||||
}
|
||||
virtual size_t Finish(void* buf, size_t len) {
|
||||
if (len < kSize) {
|
||||
return 0;
|
||||
}
|
||||
MD5Final(&ctx_, static_cast<uint8*>(buf));
|
||||
MD5Init(&ctx_); // Reset for next use.
|
||||
return kSize;
|
||||
}
|
||||
size_t Size() const override;
|
||||
void Update(const void* buf, size_t len) override;
|
||||
size_t Finish(void* buf, size_t len) override;
|
||||
|
||||
private:
|
||||
MD5_CTX ctx_;
|
||||
MD5Context ctx_;
|
||||
};
|
||||
|
||||
} // namespace rtc
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
#include "webrtc/base/basictypes.h"
|
||||
#include "webrtc/base/sslconfig.h"
|
||||
#if SSL_USE_OPENSSL
|
||||
#include "webrtc/base/openssldigest.h"
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/base/messagequeue.h"
|
||||
|
@ -57,7 +59,9 @@ void MessageQueueManager::AddInternal(MessageQueue *message_queue) {
|
|||
// MessageQueueManager methods should be non-reentrant, so we
|
||||
// ASSERT that is the case. If any of these ASSERT, please
|
||||
// contact bpm or jbeda.
|
||||
#if CS_TRACK_OWNER // CurrentThreadIsOwner returns true by default.
|
||||
ASSERT(!crit_.CurrentThreadIsOwner());
|
||||
#endif
|
||||
CritScope cs(&crit_);
|
||||
message_queues_.push_back(message_queue);
|
||||
}
|
||||
|
@ -69,7 +73,9 @@ void MessageQueueManager::Remove(MessageQueue *message_queue) {
|
|||
return Instance()->RemoveInternal(message_queue);
|
||||
}
|
||||
void MessageQueueManager::RemoveInternal(MessageQueue *message_queue) {
|
||||
#if CS_TRACK_OWNER // CurrentThreadIsOwner returns true by default.
|
||||
ASSERT(!crit_.CurrentThreadIsOwner()); // See note above.
|
||||
#endif
|
||||
// If this is the last MessageQueue, destroy the manager as well so that
|
||||
// we don't leak this object at program shutdown. As mentioned above, this is
|
||||
// not thread-safe, but this should only happen at program termination (when
|
||||
|
@ -98,7 +104,9 @@ void MessageQueueManager::Clear(MessageHandler *handler) {
|
|||
return Instance()->ClearInternal(handler);
|
||||
}
|
||||
void MessageQueueManager::ClearInternal(MessageHandler *handler) {
|
||||
#if CS_TRACK_OWNER // CurrentThreadIsOwner returns true by default.
|
||||
ASSERT(!crit_.CurrentThreadIsOwner()); // See note above.
|
||||
#endif
|
||||
CritScope cs(&crit_);
|
||||
std::vector<MessageQueue *>::iterator iter;
|
||||
for (iter = message_queues_.begin(); iter != message_queues_.end(); iter++)
|
||||
|
@ -244,7 +252,7 @@ bool MessageQueue::Get(Message *pmsg, int cmsWait, bool process_io) {
|
|||
if (cmsWait == kForever) {
|
||||
cmsNext = cmsDelayNext;
|
||||
} else {
|
||||
cmsNext = _max(0, cmsTotal - cmsElapsed);
|
||||
cmsNext = std::max(0, cmsTotal - cmsElapsed);
|
||||
if ((cmsDelayNext != kForever) && (cmsDelayNext < cmsNext))
|
||||
cmsNext = cmsDelayNext;
|
||||
}
|
||||
|
@ -289,6 +297,20 @@ void MessageQueue::Post(MessageHandler *phandler, uint32 id,
|
|||
ss_->WakeUp();
|
||||
}
|
||||
|
||||
void MessageQueue::PostDelayed(int cmsDelay,
|
||||
MessageHandler* phandler,
|
||||
uint32 id,
|
||||
MessageData* pdata) {
|
||||
return DoDelayPost(cmsDelay, TimeAfter(cmsDelay), phandler, id, pdata);
|
||||
}
|
||||
|
||||
void MessageQueue::PostAt(uint32 tstamp,
|
||||
MessageHandler* phandler,
|
||||
uint32 id,
|
||||
MessageData* pdata) {
|
||||
return DoDelayPost(TimeUntil(tstamp), tstamp, phandler, id, pdata);
|
||||
}
|
||||
|
||||
void MessageQueue::DoDelayPost(int cmsDelay, uint32 tstamp,
|
||||
MessageHandler *phandler, uint32 id, MessageData* pdata) {
|
||||
if (fStop_)
|
||||
|
|
|
@ -165,6 +165,8 @@ class DelayedMessage {
|
|||
|
||||
class MessageQueue {
|
||||
public:
|
||||
static const int kForever = -1;
|
||||
|
||||
explicit MessageQueue(SocketServer* ss = NULL);
|
||||
virtual ~MessageQueue();
|
||||
|
||||
|
@ -190,14 +192,14 @@ class MessageQueue {
|
|||
virtual bool Peek(Message *pmsg, int cmsWait = 0);
|
||||
virtual void Post(MessageHandler *phandler, uint32 id = 0,
|
||||
MessageData *pdata = NULL, bool time_sensitive = false);
|
||||
virtual void PostDelayed(int cmsDelay, MessageHandler *phandler,
|
||||
uint32 id = 0, MessageData *pdata = NULL) {
|
||||
return DoDelayPost(cmsDelay, TimeAfter(cmsDelay), phandler, id, pdata);
|
||||
}
|
||||
virtual void PostAt(uint32 tstamp, MessageHandler *phandler,
|
||||
uint32 id = 0, MessageData *pdata = NULL) {
|
||||
return DoDelayPost(TimeUntil(tstamp), tstamp, phandler, id, pdata);
|
||||
}
|
||||
virtual void PostDelayed(int cmsDelay,
|
||||
MessageHandler* phandler,
|
||||
uint32 id = 0,
|
||||
MessageData* pdata = NULL);
|
||||
virtual void PostAt(uint32 tstamp,
|
||||
MessageHandler* phandler,
|
||||
uint32 id = 0,
|
||||
MessageData* pdata = NULL);
|
||||
virtual void Clear(MessageHandler *phandler, uint32 id = MQID_ANY,
|
||||
MessageList* removed = NULL);
|
||||
virtual void Dispatch(Message *pmsg);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012 The WebRTC Project Authors. All rights reserved.
|
||||
* Copyright (c) 2013 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
|
||||
|
@ -8,8 +8,12 @@
|
|||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef THIRD_PARTY_WEBRTC_FILES_WEBRTC_BASE_MOVE_H_
|
||||
#define THIRD_PARTY_WEBRTC_FILES_WEBRTC_BASE_MOVE_H_
|
||||
// Borrowed from Chromium's src/base/move.h.
|
||||
|
||||
#ifndef WEBRTC_BASE_MOVE_H_
|
||||
#define WEBRTC_BASE_MOVE_H_
|
||||
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
// Macro with the boilerplate that makes a type move-only in C++03.
|
||||
//
|
||||
|
@ -32,7 +36,7 @@
|
|||
//
|
||||
// template <typename T>
|
||||
// class scoped_ptr {
|
||||
// TALK_MOVE_ONLY_TYPE_FOR_CPP_03(scoped_ptr, RValue)
|
||||
// RTC_MOVE_ONLY_TYPE_FOR_CPP_03(scoped_ptr, RValue)
|
||||
// public:
|
||||
// scoped_ptr(RValue& other) : ptr_(other.release()) { }
|
||||
// scoped_ptr& operator=(RValue& other) {
|
||||
|
@ -94,7 +98,7 @@
|
|||
// Here's an example with comments explaining what gets triggered where:
|
||||
//
|
||||
// class Foo {
|
||||
// TALK_MOVE_ONLY_TYPE_FOR_CPP_03(Foo, RValue);
|
||||
// RTC_MOVE_ONLY_TYPE_FOR_CPP_03(Foo, RValue);
|
||||
//
|
||||
// public:
|
||||
// ... API ...
|
||||
|
@ -142,6 +146,16 @@
|
|||
// choose the one that adheres to the standard.
|
||||
//
|
||||
//
|
||||
// WHY HAVE typedef void MoveOnlyTypeForCPP03
|
||||
//
|
||||
// Callback<>/Bind() needs to understand movable-but-not-copyable semantics
|
||||
// to call .Pass() appropriately when it is expected to transfer the value.
|
||||
// The cryptic typedef MoveOnlyTypeForCPP03 is added to make this check
|
||||
// easy and automatic in helper templates for Callback<>/Bind().
|
||||
// See IsMoveOnlyType template and its usage in base/callback_internal.h
|
||||
// for more details.
|
||||
//
|
||||
//
|
||||
// COMPARED TO C++11
|
||||
//
|
||||
// In C++11, you would implement this functionality using an r-value reference
|
||||
|
@ -197,7 +211,7 @@
|
|||
//
|
||||
// The workaround is to explicitly declare your copy constructor.
|
||||
//
|
||||
#define TALK_MOVE_ONLY_TYPE_FOR_CPP_03(type, rvalue_type) \
|
||||
#define RTC_MOVE_ONLY_TYPE_FOR_CPP_03(type, rvalue_type) \
|
||||
private: \
|
||||
struct rvalue_type { \
|
||||
explicit rvalue_type(type* object) : object(object) {} \
|
||||
|
@ -207,7 +221,17 @@
|
|||
void operator=(type&); \
|
||||
public: \
|
||||
operator rvalue_type() { return rvalue_type(this); } \
|
||||
type Pass() { return type(rvalue_type(this)); } \
|
||||
type Pass() WARN_UNUSED_RESULT { return type(rvalue_type(this)); } \
|
||||
typedef void MoveOnlyTypeForCPP03; \
|
||||
private:
|
||||
|
||||
#endif // THIRD_PARTY_WEBRTC_FILES_WEBRTC_BASE_MOVE_H_
|
||||
#define RTC_MOVE_ONLY_TYPE_WITH_MOVE_CONSTRUCTOR_FOR_CPP_03(type) \
|
||||
private: \
|
||||
type(type&); \
|
||||
void operator=(type&); \
|
||||
public: \
|
||||
type&& Pass() WARN_UNUSED_RESULT { return static_cast<type&&>(*this); } \
|
||||
typedef void MoveOnlyTypeForCPP03; \
|
||||
private:
|
||||
|
||||
#endif // WEBRTC_BASE_MOVE_H_
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/httpcommon.h"
|
||||
#include "webrtc/base/multipart.h"
|
||||
|
@ -184,7 +184,7 @@ bool MultipartStream::SetPosition(size_t position) {
|
|||
return false;
|
||||
}
|
||||
if (part_offset + part_size > position) {
|
||||
for (size_t j = i+1; j < _min(parts_.size(), current_+1); ++j) {
|
||||
for (size_t j = i + 1; j < std::min(parts_.size(), current_ + 1); ++j) {
|
||||
if (!parts_[j]->Rewind()) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace rtc {
|
|||
class MultipartStream : public StreamInterface, public sigslot::has_slots<> {
|
||||
public:
|
||||
MultipartStream(const std::string& type, const std::string& boundary);
|
||||
virtual ~MultipartStream();
|
||||
~MultipartStream() override;
|
||||
|
||||
void GetContentType(std::string* content_type);
|
||||
|
||||
|
@ -48,16 +48,20 @@ class MultipartStream : public StreamInterface, public sigslot::has_slots<> {
|
|||
size_t GetEndPartSize() const;
|
||||
|
||||
// StreamInterface
|
||||
virtual StreamState GetState() const;
|
||||
virtual StreamResult Read(void* buffer, size_t buffer_len,
|
||||
size_t* read, int* error);
|
||||
virtual StreamResult Write(const void* data, size_t data_len,
|
||||
size_t* written, int* error);
|
||||
virtual void Close();
|
||||
virtual bool SetPosition(size_t position);
|
||||
virtual bool GetPosition(size_t* position) const;
|
||||
virtual bool GetSize(size_t* size) const;
|
||||
virtual bool GetAvailable(size_t* size) const;
|
||||
StreamState GetState() const 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;
|
||||
bool SetPosition(size_t position) override;
|
||||
bool GetPosition(size_t* position) const override;
|
||||
bool GetSize(size_t* size) const override;
|
||||
bool GetAvailable(size_t* size) const override;
|
||||
|
||||
private:
|
||||
typedef std::vector<StreamInterface*> PartList;
|
||||
|
|
|
@ -54,7 +54,7 @@ class NATServer : public sigslot::has_slots<> {
|
|||
NATServer(
|
||||
NATType type, SocketFactory* internal, const SocketAddress& internal_addr,
|
||||
SocketFactory* external, const SocketAddress& external_ip);
|
||||
~NATServer();
|
||||
~NATServer() override;
|
||||
|
||||
SocketAddress internal_address() const {
|
||||
return server_socket_->GetLocalAddress();
|
||||
|
|
|
@ -72,20 +72,20 @@ class NATSocket : public AsyncSocket, public sigslot::has_slots<> {
|
|||
socket_(NULL), buf_(NULL), size_(0) {
|
||||
}
|
||||
|
||||
virtual ~NATSocket() {
|
||||
~NATSocket() override {
|
||||
delete socket_;
|
||||
delete[] buf_;
|
||||
}
|
||||
|
||||
virtual SocketAddress GetLocalAddress() const {
|
||||
SocketAddress GetLocalAddress() const override {
|
||||
return (socket_) ? socket_->GetLocalAddress() : SocketAddress();
|
||||
}
|
||||
|
||||
virtual SocketAddress GetRemoteAddress() const {
|
||||
SocketAddress GetRemoteAddress() const override {
|
||||
return remote_addr_; // will be NIL if not connected
|
||||
}
|
||||
|
||||
virtual int Bind(const SocketAddress& addr) {
|
||||
int Bind(const SocketAddress& addr) override {
|
||||
if (socket_) { // already bound, bubble up error
|
||||
return -1;
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ class NATSocket : public AsyncSocket, public sigslot::has_slots<> {
|
|||
return result;
|
||||
}
|
||||
|
||||
virtual int Connect(const SocketAddress& addr) {
|
||||
int Connect(const SocketAddress& addr) override {
|
||||
if (!socket_) { // socket must be bound, for now
|
||||
return -1;
|
||||
}
|
||||
|
@ -126,12 +126,14 @@ class NATSocket : public AsyncSocket, public sigslot::has_slots<> {
|
|||
return result;
|
||||
}
|
||||
|
||||
virtual int Send(const void* data, size_t size) {
|
||||
int Send(const void* data, size_t size) override {
|
||||
ASSERT(connected_);
|
||||
return SendTo(data, size, remote_addr_);
|
||||
}
|
||||
|
||||
virtual int SendTo(const void* data, size_t size, const SocketAddress& addr) {
|
||||
int SendTo(const void* data,
|
||||
size_t size,
|
||||
const SocketAddress& addr) override {
|
||||
ASSERT(!connected_ || addr == remote_addr_);
|
||||
if (server_addr_.IsNil() || type_ == SOCK_STREAM) {
|
||||
return socket_->SendTo(data, size, addr);
|
||||
|
@ -151,12 +153,12 @@ class NATSocket : public AsyncSocket, public sigslot::has_slots<> {
|
|||
return result;
|
||||
}
|
||||
|
||||
virtual int Recv(void* data, size_t size) {
|
||||
int Recv(void* data, size_t size) override {
|
||||
SocketAddress addr;
|
||||
return RecvFrom(data, size, &addr);
|
||||
}
|
||||
|
||||
virtual int RecvFrom(void* data, size_t size, SocketAddress *out_addr) {
|
||||
int RecvFrom(void* data, size_t size, SocketAddress* out_addr) override {
|
||||
if (server_addr_.IsNil() || type_ == SOCK_STREAM) {
|
||||
return socket_->RecvFrom(data, size, out_addr);
|
||||
}
|
||||
|
@ -196,7 +198,7 @@ class NATSocket : public AsyncSocket, public sigslot::has_slots<> {
|
|||
return result;
|
||||
}
|
||||
|
||||
virtual int Close() {
|
||||
int Close() override {
|
||||
int result = 0;
|
||||
if (socket_) {
|
||||
result = socket_->Close();
|
||||
|
@ -210,28 +212,20 @@ class NATSocket : public AsyncSocket, public sigslot::has_slots<> {
|
|||
return result;
|
||||
}
|
||||
|
||||
virtual int Listen(int backlog) {
|
||||
return socket_->Listen(backlog);
|
||||
}
|
||||
virtual AsyncSocket* Accept(SocketAddress *paddr) {
|
||||
int Listen(int backlog) override { return socket_->Listen(backlog); }
|
||||
AsyncSocket* Accept(SocketAddress* paddr) override {
|
||||
return socket_->Accept(paddr);
|
||||
}
|
||||
virtual int GetError() const {
|
||||
return socket_->GetError();
|
||||
}
|
||||
virtual void SetError(int error) {
|
||||
socket_->SetError(error);
|
||||
}
|
||||
virtual ConnState GetState() const {
|
||||
int GetError() const override { return socket_->GetError(); }
|
||||
void SetError(int error) override { socket_->SetError(error); }
|
||||
ConnState GetState() const override {
|
||||
return connected_ ? CS_CONNECTED : CS_CLOSED;
|
||||
}
|
||||
virtual int EstimateMTU(uint16* mtu) {
|
||||
return socket_->EstimateMTU(mtu);
|
||||
}
|
||||
virtual int GetOption(Option opt, int* value) {
|
||||
int EstimateMTU(uint16* mtu) override { return socket_->EstimateMTU(mtu); }
|
||||
int GetOption(Option opt, int* value) override {
|
||||
return socket_->GetOption(opt, value);
|
||||
}
|
||||
virtual int SetOption(Option opt, int value) {
|
||||
int SetOption(Option opt, int value) override {
|
||||
return socket_->SetOption(opt, value);
|
||||
}
|
||||
|
||||
|
@ -371,6 +365,19 @@ AsyncSocket* NATSocketServer::CreateAsyncSocket(int family, int type) {
|
|||
return new NATSocket(this, family, type);
|
||||
}
|
||||
|
||||
void NATSocketServer::SetMessageQueue(MessageQueue* queue) {
|
||||
msg_queue_ = queue;
|
||||
server_->SetMessageQueue(queue);
|
||||
}
|
||||
|
||||
bool NATSocketServer::Wait(int cms, bool process_io) {
|
||||
return server_->Wait(cms, process_io);
|
||||
}
|
||||
|
||||
void NATSocketServer::WakeUp() {
|
||||
server_->WakeUp();
|
||||
}
|
||||
|
||||
AsyncSocket* NATSocketServer::CreateInternalSocket(int family, int type,
|
||||
const SocketAddress& local_addr, SocketAddress* nat_addr) {
|
||||
AsyncSocket* socket = NULL;
|
||||
|
@ -400,6 +407,7 @@ NATSocketServer::Translator::Translator(
|
|||
ext_factory, ext_ip));
|
||||
}
|
||||
|
||||
NATSocketServer::Translator::~Translator() = default;
|
||||
|
||||
NATSocketServer::Translator* NATSocketServer::Translator::GetTranslator(
|
||||
const SocketAddress& ext_ip) {
|
||||
|
|
|
@ -40,14 +40,16 @@ class NATSocketFactory : public SocketFactory, public NATInternalSocketFactory {
|
|||
NATSocketFactory(SocketFactory* factory, const SocketAddress& nat_addr);
|
||||
|
||||
// SocketFactory implementation
|
||||
virtual Socket* CreateSocket(int type);
|
||||
virtual Socket* CreateSocket(int family, int type);
|
||||
virtual AsyncSocket* CreateAsyncSocket(int type);
|
||||
virtual AsyncSocket* CreateAsyncSocket(int family, int type);
|
||||
Socket* CreateSocket(int type) override;
|
||||
Socket* CreateSocket(int family, int type) override;
|
||||
AsyncSocket* CreateAsyncSocket(int type) override;
|
||||
AsyncSocket* CreateAsyncSocket(int family, int type) override;
|
||||
|
||||
// NATInternalSocketFactory implementation
|
||||
virtual AsyncSocket* CreateInternalSocket(int family, int type,
|
||||
const SocketAddress& local_addr, SocketAddress* nat_addr);
|
||||
AsyncSocket* CreateInternalSocket(int family,
|
||||
int type,
|
||||
const SocketAddress& local_addr,
|
||||
SocketAddress* nat_addr) override;
|
||||
|
||||
private:
|
||||
SocketFactory* factory_;
|
||||
|
@ -89,6 +91,7 @@ class NATSocketServer : public SocketServer, public NATInternalSocketFactory {
|
|||
Translator(NATSocketServer* server, NATType type,
|
||||
const SocketAddress& int_addr, SocketFactory* ext_factory,
|
||||
const SocketAddress& ext_addr);
|
||||
~Translator();
|
||||
|
||||
SocketFactory* internal_factory() { return internal_factory_.get(); }
|
||||
SocketAddress internal_address() const {
|
||||
|
@ -128,26 +131,21 @@ class NATSocketServer : public SocketServer, public NATInternalSocketFactory {
|
|||
void RemoveTranslator(const SocketAddress& ext_ip);
|
||||
|
||||
// SocketServer implementation
|
||||
virtual Socket* CreateSocket(int type);
|
||||
virtual Socket* CreateSocket(int family, int type);
|
||||
Socket* CreateSocket(int type) override;
|
||||
Socket* CreateSocket(int family, int type) override;
|
||||
|
||||
virtual AsyncSocket* CreateAsyncSocket(int type);
|
||||
virtual AsyncSocket* CreateAsyncSocket(int family, int type);
|
||||
AsyncSocket* CreateAsyncSocket(int type) override;
|
||||
AsyncSocket* CreateAsyncSocket(int family, int type) override;
|
||||
|
||||
virtual void SetMessageQueue(MessageQueue* queue) {
|
||||
msg_queue_ = queue;
|
||||
server_->SetMessageQueue(queue);
|
||||
}
|
||||
virtual bool Wait(int cms, bool process_io) {
|
||||
return server_->Wait(cms, process_io);
|
||||
}
|
||||
virtual void WakeUp() {
|
||||
server_->WakeUp();
|
||||
}
|
||||
void SetMessageQueue(MessageQueue* queue) override;
|
||||
bool Wait(int cms, bool process_io) override;
|
||||
void WakeUp() override;
|
||||
|
||||
// NATInternalSocketFactory implementation
|
||||
virtual AsyncSocket* CreateInternalSocket(int family, int type,
|
||||
const SocketAddress& local_addr, SocketAddress* nat_addr);
|
||||
AsyncSocket* CreateInternalSocket(int family,
|
||||
int type,
|
||||
const SocketAddress& local_addr,
|
||||
SocketAddress* nat_addr) override;
|
||||
|
||||
private:
|
||||
SocketServer* server_;
|
||||
|
|
|
@ -16,30 +16,30 @@ namespace rtc {
|
|||
|
||||
class SymmetricNAT : public NAT {
|
||||
public:
|
||||
bool IsSymmetric() { return true; }
|
||||
bool FiltersIP() { return true; }
|
||||
bool FiltersPort() { return true; }
|
||||
bool IsSymmetric() override { return true; }
|
||||
bool FiltersIP() override { return true; }
|
||||
bool FiltersPort() override { return true; }
|
||||
};
|
||||
|
||||
class OpenConeNAT : public NAT {
|
||||
public:
|
||||
bool IsSymmetric() { return false; }
|
||||
bool FiltersIP() { return false; }
|
||||
bool FiltersPort() { return false; }
|
||||
bool IsSymmetric() override { return false; }
|
||||
bool FiltersIP() override { return false; }
|
||||
bool FiltersPort() override { return false; }
|
||||
};
|
||||
|
||||
class AddressRestrictedNAT : public NAT {
|
||||
public:
|
||||
bool IsSymmetric() { return false; }
|
||||
bool FiltersIP() { return true; }
|
||||
bool FiltersPort() { return false; }
|
||||
bool IsSymmetric() override { return false; }
|
||||
bool FiltersIP() override { return true; }
|
||||
bool FiltersPort() override { return false; }
|
||||
};
|
||||
|
||||
class PortRestrictedNAT : public NAT {
|
||||
public:
|
||||
bool IsSymmetric() { return false; }
|
||||
bool FiltersIP() { return true; }
|
||||
bool FiltersPort() { return true; }
|
||||
bool IsSymmetric() override { return false; }
|
||||
bool FiltersIP() override { return true; }
|
||||
bool FiltersPort() override { return true; }
|
||||
};
|
||||
|
||||
NAT* NAT::Create(NATType type) {
|
||||
|
|
|
@ -60,6 +60,8 @@ int ResolveHostname(const std::string& hostname, int family,
|
|||
AsyncResolver::AsyncResolver() : error_(-1) {
|
||||
}
|
||||
|
||||
AsyncResolver::~AsyncResolver() = default;
|
||||
|
||||
void AsyncResolver::Start(const SocketAddress& addr) {
|
||||
addr_ = addr;
|
||||
// SignalThred Start will kickoff the resolve process.
|
||||
|
@ -80,6 +82,14 @@ bool AsyncResolver::GetResolvedAddress(int family, SocketAddress* addr) const {
|
|||
return false;
|
||||
}
|
||||
|
||||
int AsyncResolver::GetError() const {
|
||||
return error_;
|
||||
}
|
||||
|
||||
void AsyncResolver::Destroy(bool wait) {
|
||||
SignalThread::Destroy(wait);
|
||||
}
|
||||
|
||||
void AsyncResolver::DoWork() {
|
||||
error_ = ResolveHostname(addr_.hostname().c_str(), addr_.family(),
|
||||
&addresses_);
|
||||
|
|
|
@ -34,19 +34,19 @@ class AsyncResolverTest;
|
|||
class AsyncResolver : public SignalThread, public AsyncResolverInterface {
|
||||
public:
|
||||
AsyncResolver();
|
||||
virtual ~AsyncResolver() {}
|
||||
~AsyncResolver() override;
|
||||
|
||||
virtual void Start(const SocketAddress& addr);
|
||||
virtual bool GetResolvedAddress(int family, SocketAddress* addr) const;
|
||||
virtual int GetError() const { return error_; }
|
||||
virtual void Destroy(bool wait) { SignalThread::Destroy(wait); }
|
||||
void Start(const SocketAddress& addr) override;
|
||||
bool GetResolvedAddress(int family, SocketAddress* addr) const override;
|
||||
int GetError() const override;
|
||||
void Destroy(bool wait) override;
|
||||
|
||||
const std::vector<IPAddress>& addresses() const { return addresses_; }
|
||||
void set_error(int error) { error_ = error; }
|
||||
|
||||
protected:
|
||||
virtual void DoWork();
|
||||
virtual void OnWorkDone();
|
||||
void DoWork() override;
|
||||
void OnWorkDone() override;
|
||||
|
||||
private:
|
||||
SocketAddress addr_;
|
||||
|
|
|
@ -57,6 +57,11 @@
|
|||
namespace rtc {
|
||||
namespace {
|
||||
|
||||
// Turning on IPv6 could make many IPv6 interfaces available for connectivity
|
||||
// check and delay the call setup time. kMaxIPv6Networks is the default upper
|
||||
// limit of IPv6 networks but could be changed by set_max_ipv6_networks().
|
||||
const int kMaxIPv6Networks = 5;
|
||||
|
||||
const uint32 kUpdateNetworksMessage = 1;
|
||||
const uint32 kSignalNetworksMessage = 2;
|
||||
|
||||
|
@ -115,12 +120,34 @@ std::string AdapterTypeToString(AdapterType type) {
|
|||
return "Cellular";
|
||||
case ADAPTER_TYPE_VPN:
|
||||
return "VPN";
|
||||
case ADAPTER_TYPE_LOOPBACK:
|
||||
return "Loopback";
|
||||
default:
|
||||
ASSERT(false);
|
||||
DCHECK(false) << "Invalid type " << type;
|
||||
return std::string();
|
||||
}
|
||||
}
|
||||
|
||||
bool IsIgnoredIPv6(const IPAddress& ip) {
|
||||
if (ip.family() != AF_INET6) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Link-local addresses require scope id to be bound successfully.
|
||||
// However, our IPAddress structure doesn't carry that so the
|
||||
// information is lost and causes binding failure.
|
||||
if (IPIsLinkLocal(ip)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Any MAC based IPv6 should be avoided to prevent the MAC tracking.
|
||||
if (IPIsMacBased(ip)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
std::string MakeNetworkKey(const std::string& name, const IPAddress& prefix,
|
||||
|
@ -136,22 +163,60 @@ NetworkManager::NetworkManager() {
|
|||
NetworkManager::~NetworkManager() {
|
||||
}
|
||||
|
||||
NetworkManagerBase::NetworkManagerBase() : ipv6_enabled_(true) {
|
||||
NetworkManagerBase::NetworkManagerBase()
|
||||
: max_ipv6_networks_(kMaxIPv6Networks), ipv6_enabled_(true) {
|
||||
}
|
||||
|
||||
NetworkManagerBase::~NetworkManagerBase() {
|
||||
for (NetworkMap::iterator i = networks_map_.begin();
|
||||
i != networks_map_.end(); ++i) {
|
||||
delete i->second;
|
||||
for (const auto& kv : networks_map_) {
|
||||
delete kv.second;
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkManagerBase::GetAnyAddressNetworks(NetworkList* networks) {
|
||||
if (!ipv4_any_address_network_) {
|
||||
const rtc::IPAddress ipv4_any_address(INADDR_ANY);
|
||||
ipv4_any_address_network_.reset(
|
||||
new rtc::Network("any", "any", ipv4_any_address, 0));
|
||||
ipv4_any_address_network_->AddIP(ipv4_any_address);
|
||||
}
|
||||
networks->push_back(ipv4_any_address_network_.get());
|
||||
|
||||
if (ipv6_enabled()) {
|
||||
if (!ipv6_any_address_network_) {
|
||||
const rtc::IPAddress ipv6_any_address(in6addr_any);
|
||||
ipv6_any_address_network_.reset(
|
||||
new rtc::Network("any", "any", ipv6_any_address, 0));
|
||||
ipv6_any_address_network_->AddIP(ipv6_any_address);
|
||||
}
|
||||
networks->push_back(ipv6_any_address_network_.get());
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkManagerBase::GetNetworks(NetworkList* result) const {
|
||||
*result = networks_;
|
||||
int ipv6_networks = 0;
|
||||
result->clear();
|
||||
for (Network* network : networks_) {
|
||||
// Keep the number of IPv6 networks under |max_ipv6_networks_|.
|
||||
if (network->prefix().family() == AF_INET6) {
|
||||
if (ipv6_networks >= max_ipv6_networks_) {
|
||||
continue;
|
||||
}
|
||||
++ipv6_networks;
|
||||
}
|
||||
result->push_back(network);
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkManagerBase::MergeNetworkList(const NetworkList& new_networks,
|
||||
bool* changed) {
|
||||
NetworkManager::Stats stats;
|
||||
MergeNetworkList(new_networks, changed, &stats);
|
||||
}
|
||||
|
||||
void NetworkManagerBase::MergeNetworkList(const NetworkList& new_networks,
|
||||
bool* changed,
|
||||
NetworkManager::Stats* stats) {
|
||||
// AddressList in this map will track IP addresses for all Networks
|
||||
// with the same key.
|
||||
std::map<std::string, AddressList> consolidated_address_list;
|
||||
|
@ -167,49 +232,51 @@ void NetworkManagerBase::MergeNetworkList(const NetworkList& new_networks,
|
|||
*changed = true;
|
||||
|
||||
// First, build a set of network-keys to the ipaddresses.
|
||||
for (uint32 i = 0; i < list.size(); ++i) {
|
||||
for (Network* network : list) {
|
||||
bool might_add_to_merged_list = false;
|
||||
std::string key = MakeNetworkKey(list[i]->name(),
|
||||
list[i]->prefix(),
|
||||
list[i]->prefix_length());
|
||||
std::string key = MakeNetworkKey(network->name(),
|
||||
network->prefix(),
|
||||
network->prefix_length());
|
||||
if (consolidated_address_list.find(key) ==
|
||||
consolidated_address_list.end()) {
|
||||
AddressList addrlist;
|
||||
addrlist.net = list[i];
|
||||
addrlist.net = network;
|
||||
consolidated_address_list[key] = addrlist;
|
||||
might_add_to_merged_list = true;
|
||||
}
|
||||
const std::vector<InterfaceAddress>& addresses = list[i]->GetIPs();
|
||||
const std::vector<InterfaceAddress>& addresses = network->GetIPs();
|
||||
AddressList& current_list = consolidated_address_list[key];
|
||||
for (std::vector<InterfaceAddress>::const_iterator it = addresses.begin();
|
||||
it != addresses.end();
|
||||
++it) {
|
||||
current_list.ips.push_back(*it);
|
||||
for (const InterfaceAddress& address : addresses) {
|
||||
current_list.ips.push_back(address);
|
||||
}
|
||||
if (!might_add_to_merged_list) {
|
||||
delete list[i];
|
||||
delete network;
|
||||
} else {
|
||||
if (current_list.ips[0].family() == AF_INET) {
|
||||
stats->ipv4_network_count++;
|
||||
} else {
|
||||
ASSERT(current_list.ips[0].family() == AF_INET6);
|
||||
stats->ipv6_network_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Next, look for existing network objects to re-use.
|
||||
for (std::map<std::string, AddressList>::iterator it =
|
||||
consolidated_address_list.begin();
|
||||
it != consolidated_address_list.end();
|
||||
++it) {
|
||||
const std::string& key = it->first;
|
||||
Network* net = it->second.net;
|
||||
NetworkMap::iterator existing = networks_map_.find(key);
|
||||
for (const auto& kv : consolidated_address_list) {
|
||||
const std::string& key = kv.first;
|
||||
Network* net = kv.second.net;
|
||||
auto existing = networks_map_.find(key);
|
||||
if (existing == networks_map_.end()) {
|
||||
// This network is new. Place it in the network map.
|
||||
merged_list.push_back(net);
|
||||
networks_map_[key] = net;
|
||||
// Also, we might have accumulated IPAddresses from the first
|
||||
// step, set it here.
|
||||
net->SetIPs(it->second.ips, true);
|
||||
net->SetIPs(kv.second.ips, true);
|
||||
*changed = true;
|
||||
} else {
|
||||
// This network exists in the map already. Reset its IP addresses.
|
||||
*changed = existing->second->SetIPs(it->second.ips, *changed);
|
||||
*changed = existing->second->SetIPs(kv.second.ips, *changed);
|
||||
merged_list.push_back(existing->second);
|
||||
if (existing->second != net) {
|
||||
delete net;
|
||||
|
@ -219,7 +286,7 @@ void NetworkManagerBase::MergeNetworkList(const NetworkList& new_networks,
|
|||
networks_ = merged_list;
|
||||
|
||||
// If the network lists changes, we resort it.
|
||||
if (changed) {
|
||||
if (*changed) {
|
||||
std::sort(networks_.begin(), networks_.end(), SortNetworks);
|
||||
// Now network interfaces are sorted, we should set the preference value
|
||||
// for each of the interfaces we are planning to use.
|
||||
|
@ -229,9 +296,8 @@ void NetworkManagerBase::MergeNetworkList(const NetworkList& new_networks,
|
|||
// requirements, we will just assign a preference value starting with 127,
|
||||
// in decreasing order.
|
||||
int pref = kHighestNetworkPreference;
|
||||
for (NetworkList::const_iterator iter = networks_.begin();
|
||||
iter != networks_.end(); ++iter) {
|
||||
(*iter)->set_preference(pref);
|
||||
for (Network* network : networks_) {
|
||||
network->set_preference(pref);
|
||||
if (pref > 0) {
|
||||
--pref;
|
||||
} else {
|
||||
|
@ -244,6 +310,7 @@ void NetworkManagerBase::MergeNetworkList(const NetworkList& new_networks,
|
|||
|
||||
BasicNetworkManager::BasicNetworkManager()
|
||||
: thread_(NULL), sent_first_update_(false), start_count_(0),
|
||||
network_ignore_mask_(kDefaultNetworkIgnoreMask),
|
||||
ignore_non_default_routes_(false) {
|
||||
}
|
||||
|
||||
|
@ -287,6 +354,11 @@ void BasicNetworkManager::ConvertIfAddrs(struct ifaddrs* interfaces,
|
|||
if (ipv6_enabled()) {
|
||||
ip = IPAddress(
|
||||
reinterpret_cast<sockaddr_in6*>(cursor->ifa_addr)->sin6_addr);
|
||||
|
||||
if (IsIgnoredIPv6(ip)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
mask = IPAddress(
|
||||
reinterpret_cast<sockaddr_in6*>(cursor->ifa_netmask)->sin6_addr);
|
||||
scope_id =
|
||||
|
@ -305,17 +377,21 @@ void BasicNetworkManager::ConvertIfAddrs(struct ifaddrs* interfaces,
|
|||
prefix = TruncateIP(ip, prefix_length);
|
||||
std::string key = MakeNetworkKey(std::string(cursor->ifa_name),
|
||||
prefix, prefix_length);
|
||||
NetworkMap::iterator existing_network = current_networks.find(key);
|
||||
auto existing_network = current_networks.find(key);
|
||||
if (existing_network == current_networks.end()) {
|
||||
AdapterType adapter_type = ADAPTER_TYPE_UNKNOWN;
|
||||
if (cursor->ifa_flags & IFF_LOOPBACK) {
|
||||
// TODO(phoglund): Need to recognize other types as well.
|
||||
adapter_type = ADAPTER_TYPE_LOOPBACK;
|
||||
}
|
||||
scoped_ptr<Network> network(new Network(cursor->ifa_name,
|
||||
cursor->ifa_name,
|
||||
prefix,
|
||||
prefix_length));
|
||||
prefix_length,
|
||||
adapter_type));
|
||||
network->set_scope_id(scope_id);
|
||||
network->AddIP(ip);
|
||||
bool ignored = ((cursor->ifa_flags & IFF_LOOPBACK) ||
|
||||
IsIgnoredNetwork(*network));
|
||||
network->set_ignored(ignored);
|
||||
network->set_ignored(IsIgnoredNetwork(*network));
|
||||
if (include_ignored || !network->ignored()) {
|
||||
networks->push_back(network.release());
|
||||
}
|
||||
|
@ -438,6 +514,11 @@ bool BasicNetworkManager::CreateNetworks(bool include_ignored,
|
|||
reinterpret_cast<sockaddr_in6*>(address->Address.lpSockaddr);
|
||||
scope_id = v6_addr->sin6_scope_id;
|
||||
ip = IPAddress(v6_addr->sin6_addr);
|
||||
|
||||
if (IsIgnoredIPv6(ip)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
} else {
|
||||
continue;
|
||||
|
@ -451,17 +532,22 @@ bool BasicNetworkManager::CreateNetworks(bool include_ignored,
|
|||
IPAddress prefix;
|
||||
int prefix_length = GetPrefix(prefixlist, ip, &prefix);
|
||||
std::string key = MakeNetworkKey(name, prefix, prefix_length);
|
||||
NetworkMap::iterator existing_network = current_networks.find(key);
|
||||
auto existing_network = current_networks.find(key);
|
||||
if (existing_network == current_networks.end()) {
|
||||
AdapterType adapter_type = ADAPTER_TYPE_UNKNOWN;
|
||||
if (adapter_addrs->IfType == IF_TYPE_SOFTWARE_LOOPBACK) {
|
||||
// TODO(phoglund): Need to recognize other types as well.
|
||||
adapter_type = ADAPTER_TYPE_LOOPBACK;
|
||||
}
|
||||
scoped_ptr<Network> network(new Network(name,
|
||||
description,
|
||||
prefix,
|
||||
prefix_length));
|
||||
prefix_length,
|
||||
adapter_type));
|
||||
network->set_scope_id(scope_id);
|
||||
network->AddIP(ip);
|
||||
bool ignore = ((adapter_addrs->IfType == IF_TYPE_SOFTWARE_LOOPBACK) ||
|
||||
IsIgnoredNetwork(*network));
|
||||
network->set_ignored(ignore);
|
||||
bool ignored = IsIgnoredNetwork(*network);
|
||||
network->set_ignored(ignored);
|
||||
if (include_ignored || !network->ignored()) {
|
||||
networks->push_back(network.release());
|
||||
}
|
||||
|
@ -508,15 +594,21 @@ bool IsDefaultRoute(const std::string& network_name) {
|
|||
|
||||
bool BasicNetworkManager::IsIgnoredNetwork(const Network& network) const {
|
||||
// Ignore networks on the explicit ignore list.
|
||||
for (size_t i = 0; i < network_ignore_list_.size(); ++i) {
|
||||
if (network.name() == network_ignore_list_[i]) {
|
||||
for (const std::string& ignored_name : network_ignore_list_) {
|
||||
if (network.name() == ignored_name) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (network_ignore_mask_ & network.type()) {
|
||||
return true;
|
||||
}
|
||||
#if defined(WEBRTC_POSIX)
|
||||
// Filter out VMware interfaces, typically named vmnet1 and vmnet8
|
||||
// Filter out VMware/VirtualBox interfaces, typically named vmnet1,
|
||||
// vmnet8, or vboxnet0.
|
||||
if (strncmp(network.name().c_str(), "vmnet", 5) == 0 ||
|
||||
strncmp(network.name().c_str(), "vnic", 4) == 0) {
|
||||
strncmp(network.name().c_str(), "vnic", 4) == 0 ||
|
||||
strncmp(network.name().c_str(), "vboxnet", 7) == 0) {
|
||||
return true;
|
||||
}
|
||||
#if defined(WEBRTC_LINUX)
|
||||
|
@ -539,6 +631,7 @@ bool BasicNetworkManager::IsIgnoredNetwork(const Network& network) const {
|
|||
if (network.prefix().family() == AF_INET) {
|
||||
return (network.prefix().v4AddressAsHostOrderInteger() < 0x01000000);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -608,8 +701,7 @@ void BasicNetworkManager::DumpNetworks(bool include_ignored) {
|
|||
NetworkList list;
|
||||
CreateNetworks(include_ignored, &list);
|
||||
LOG(LS_INFO) << "NetworkManager detected " << list.size() << " networks:";
|
||||
for (size_t i = 0; i < list.size(); ++i) {
|
||||
const Network* network = list[i];
|
||||
for (const Network* network : list) {
|
||||
if (!network->ignored() || include_ignored) {
|
||||
LOG(LS_INFO) << network->ToString() << ": "
|
||||
<< network->description()
|
||||
|
@ -618,8 +710,8 @@ void BasicNetworkManager::DumpNetworks(bool include_ignored) {
|
|||
}
|
||||
// Release the network list created previously.
|
||||
// Do this in a seperated for loop for better readability.
|
||||
for (size_t i = 0; i < list.size(); ++i) {
|
||||
delete list[i];
|
||||
for (Network* network : list) {
|
||||
delete network;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -639,25 +731,23 @@ Network::Network(const std::string& name, const std::string& desc,
|
|||
ignored_(false), type_(type), preference_(0) {
|
||||
}
|
||||
|
||||
Network::~Network() = default;
|
||||
|
||||
// Sets the addresses of this network. Returns true if the address set changed.
|
||||
// Change detection is short circuited if the changed argument is true.
|
||||
bool Network::SetIPs(const std::vector<InterfaceAddress>& ips, bool changed) {
|
||||
changed = changed || ips.size() != ips_.size();
|
||||
// Detect changes with a nested loop; n-squared but we expect on the order
|
||||
// of 2-3 addresses per network.
|
||||
for (std::vector<InterfaceAddress>::const_iterator it = ips.begin();
|
||||
!changed && it != ips.end();
|
||||
++it) {
|
||||
bool found = false;
|
||||
for (std::vector<InterfaceAddress>::iterator inner_it = ips_.begin();
|
||||
!found && inner_it != ips_.end();
|
||||
++inner_it) {
|
||||
if (*it == *inner_it) {
|
||||
found = true;
|
||||
changed = changed || ips.size() != ips_.size();
|
||||
if (!changed) {
|
||||
for (const InterfaceAddress& ip : ips) {
|
||||
if (std::find(ips_.begin(), ips_.end(), ip) == ips_.end()) {
|
||||
changed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
changed = !found;
|
||||
}
|
||||
|
||||
ips_ = ips;
|
||||
return changed;
|
||||
}
|
||||
|
@ -674,21 +764,21 @@ IPAddress Network::GetBestIP() const {
|
|||
|
||||
InterfaceAddress selected_ip, ula_ip;
|
||||
|
||||
for (size_t i = 0; i < ips_.size(); i++) {
|
||||
for (const InterfaceAddress& ip : ips_) {
|
||||
// Ignore any address which has been deprecated already.
|
||||
if (ips_[i].ipv6_flags() & IPV6_ADDRESS_FLAG_DEPRECATED)
|
||||
if (ip.ipv6_flags() & IPV6_ADDRESS_FLAG_DEPRECATED)
|
||||
continue;
|
||||
|
||||
// ULA address should only be returned when we have no other
|
||||
// global IP.
|
||||
if (IPIsULA(static_cast<const IPAddress&>(ips_[i]))) {
|
||||
ula_ip = ips_[i];
|
||||
if (IPIsULA(static_cast<const IPAddress&>(ip))) {
|
||||
ula_ip = ip;
|
||||
continue;
|
||||
}
|
||||
selected_ip = ips_[i];
|
||||
selected_ip = ip;
|
||||
|
||||
// Search could stop once a temporary non-deprecated one is found.
|
||||
if (ips_[i].ipv6_flags() & IPV6_ADDRESS_FLAG_TEMPORARY)
|
||||
if (ip.ipv6_flags() & IPV6_ADDRESS_FLAG_TEMPORARY)
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "webrtc/base/basictypes.h"
|
||||
#include "webrtc/base/ipaddress.h"
|
||||
#include "webrtc/base/messagehandler.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/base/sigslot.h"
|
||||
|
||||
#if defined(WEBRTC_POSIX)
|
||||
|
@ -33,12 +34,16 @@ class Thread;
|
|||
enum AdapterType {
|
||||
// This enum resembles the one in Chromium net::ConnectionType.
|
||||
ADAPTER_TYPE_UNKNOWN = 0,
|
||||
ADAPTER_TYPE_ETHERNET = 1,
|
||||
ADAPTER_TYPE_WIFI = 2,
|
||||
ADAPTER_TYPE_CELLULAR = 3,
|
||||
ADAPTER_TYPE_VPN = 4
|
||||
ADAPTER_TYPE_ETHERNET = 1 << 0,
|
||||
ADAPTER_TYPE_WIFI = 1 << 1,
|
||||
ADAPTER_TYPE_CELLULAR = 1 << 2,
|
||||
ADAPTER_TYPE_VPN = 1 << 3,
|
||||
ADAPTER_TYPE_LOOPBACK = 1 << 4
|
||||
};
|
||||
|
||||
// By default, ignore loopback interfaces on the host.
|
||||
const int kDefaultNetworkIgnoreMask = ADAPTER_TYPE_LOOPBACK;
|
||||
|
||||
// Makes a string key for this network. Used in the network manager's maps.
|
||||
// Network objects are keyed on interface name, network prefix and the
|
||||
// length of that prefix.
|
||||
|
@ -61,9 +66,9 @@ class NetworkManager {
|
|||
sigslot::signal0<> SignalError;
|
||||
|
||||
// Start/Stop monitoring of network interfaces
|
||||
// list. SignalNetworksChanged or SignalError is emitted immidiately
|
||||
// list. SignalNetworksChanged or SignalError is emitted immediately
|
||||
// after StartUpdating() is called. After that SignalNetworksChanged
|
||||
// is emitted wheneven list of networks changes.
|
||||
// is emitted whenever list of networks changes.
|
||||
virtual void StartUpdating() = 0;
|
||||
virtual void StopUpdating() = 0;
|
||||
|
||||
|
@ -74,20 +79,40 @@ class NetworkManager {
|
|||
// include ignored networks.
|
||||
virtual void GetNetworks(NetworkList* networks) const = 0;
|
||||
|
||||
// "AnyAddressNetwork" is a network which only contains single "any address"
|
||||
// IP address. (i.e. INADDR_ANY for IPv4 or in6addr_any for IPv6). This is
|
||||
// useful as binding to such interfaces allow default routing behavior like
|
||||
// http traffic.
|
||||
// TODO(guoweis): remove this body when chromium implements this.
|
||||
virtual void GetAnyAddressNetworks(NetworkList* networks) {}
|
||||
|
||||
// Dumps a list of networks available to LS_INFO.
|
||||
virtual void DumpNetworks(bool include_ignored) {}
|
||||
|
||||
struct Stats {
|
||||
int ipv4_network_count;
|
||||
int ipv6_network_count;
|
||||
Stats() {
|
||||
ipv4_network_count = 0;
|
||||
ipv6_network_count = 0;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// Base class for NetworkManager implementations.
|
||||
class NetworkManagerBase : public NetworkManager {
|
||||
public:
|
||||
NetworkManagerBase();
|
||||
virtual ~NetworkManagerBase();
|
||||
~NetworkManagerBase() override;
|
||||
|
||||
virtual void GetNetworks(std::vector<Network*>* networks) const;
|
||||
void GetNetworks(std::vector<Network*>* networks) const override;
|
||||
void GetAnyAddressNetworks(NetworkList* networks) override;
|
||||
bool ipv6_enabled() const { return ipv6_enabled_; }
|
||||
void set_ipv6_enabled(bool enabled) { ipv6_enabled_ = enabled; }
|
||||
|
||||
void set_max_ipv6_networks(int networks) { max_ipv6_networks_ = networks; }
|
||||
int max_ipv6_networks() { return max_ipv6_networks_; }
|
||||
|
||||
protected:
|
||||
typedef std::map<std::string, Network*> NetworkMap;
|
||||
// Updates |networks_| with the networks listed in |list|. If
|
||||
|
@ -97,13 +122,23 @@ class NetworkManagerBase : public NetworkManager {
|
|||
// any change in the network list.
|
||||
void MergeNetworkList(const NetworkList& list, bool* changed);
|
||||
|
||||
// |stats| will be populated even if |*changed| is false.
|
||||
void MergeNetworkList(const NetworkList& list,
|
||||
bool* changed,
|
||||
NetworkManager::Stats* stats);
|
||||
|
||||
private:
|
||||
friend class NetworkTest;
|
||||
void DoUpdateNetworks();
|
||||
|
||||
NetworkList networks_;
|
||||
int max_ipv6_networks_;
|
||||
|
||||
NetworkMap networks_map_;
|
||||
bool ipv6_enabled_;
|
||||
|
||||
rtc::scoped_ptr<rtc::Network> ipv4_any_address_network_;
|
||||
rtc::scoped_ptr<rtc::Network> ipv6_any_address_network_;
|
||||
};
|
||||
|
||||
// Basic implementation of the NetworkManager interface that gets list
|
||||
|
@ -112,23 +147,36 @@ class BasicNetworkManager : public NetworkManagerBase,
|
|||
public MessageHandler {
|
||||
public:
|
||||
BasicNetworkManager();
|
||||
virtual ~BasicNetworkManager();
|
||||
~BasicNetworkManager() override;
|
||||
|
||||
virtual void StartUpdating();
|
||||
virtual void StopUpdating();
|
||||
void StartUpdating() override;
|
||||
void StopUpdating() override;
|
||||
|
||||
// Logs the available networks.
|
||||
virtual void DumpNetworks(bool include_ignored);
|
||||
void DumpNetworks(bool include_ignored) override;
|
||||
|
||||
// MessageHandler interface.
|
||||
virtual void OnMessage(Message* msg);
|
||||
void OnMessage(Message* msg) override;
|
||||
bool started() { return start_count_ > 0; }
|
||||
|
||||
// Sets the network ignore list, which is empty by default. Any network on
|
||||
// the ignore list will be filtered from network enumeration results.
|
||||
// Sets the network ignore list, which is empty by default. Any network on the
|
||||
// ignore list will be filtered from network enumeration results.
|
||||
void set_network_ignore_list(const std::vector<std::string>& list) {
|
||||
network_ignore_list_ = list;
|
||||
}
|
||||
|
||||
// Sets the network types to ignore. For instance, calling this with
|
||||
// ADAPTER_TYPE_ETHERNET | ADAPTER_TYPE_LOOPBACK will ignore Ethernet and
|
||||
// loopback interfaces. Set to kDefaultNetworkIgnoreMask by default.
|
||||
void set_network_ignore_mask(int network_ignore_mask) {
|
||||
// TODO(phoglund): implement support for other types than loopback.
|
||||
// See https://code.google.com/p/webrtc/issues/detail?id=4288.
|
||||
// Then remove set_network_ignore_list.
|
||||
network_ignore_mask_ = network_ignore_mask;
|
||||
}
|
||||
|
||||
int network_ignore_mask() const { return network_ignore_mask_; }
|
||||
|
||||
#if defined(WEBRTC_LINUX)
|
||||
// Sets the flag for ignoring non-default routes.
|
||||
void set_ignore_non_default_routes(bool value) {
|
||||
|
@ -147,7 +195,8 @@ class BasicNetworkManager : public NetworkManagerBase,
|
|||
// Creates a network object for each network available on the machine.
|
||||
bool CreateNetworks(bool include_ignored, NetworkList* networks) const;
|
||||
|
||||
// Determines if a network should be ignored.
|
||||
// Determines if a network should be ignored. This should only be determined
|
||||
// based on the network's property instead of any individual IP.
|
||||
bool IsIgnoredNetwork(const Network& network) const;
|
||||
|
||||
private:
|
||||
|
@ -159,6 +208,7 @@ class BasicNetworkManager : public NetworkManagerBase,
|
|||
bool sent_first_update_;
|
||||
int start_count_;
|
||||
std::vector<std::string> network_ignore_list_;
|
||||
int network_ignore_mask_;
|
||||
bool ignore_non_default_routes_;
|
||||
};
|
||||
|
||||
|
@ -170,6 +220,7 @@ class Network {
|
|||
|
||||
Network(const std::string& name, const std::string& description,
|
||||
const IPAddress& prefix, int prefix_length, AdapterType type);
|
||||
~Network();
|
||||
|
||||
// Returns the name of the interface this network is associated wtih.
|
||||
const std::string& name() const { return name_; }
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче