Enable cpplint and fix cpplint errors in webrtc/api Adding 'explicit' to these constructors has a low risk of causing compatibility problems: explicit RTCConfiguration(RTCConfigurationType type) explicit IdBase(StatsType type) BUG=webrtc:5267 TESTED=Fixed issues reported by: find webrtc/api -type f -name *.cc -o -name *.h | xargs cpplint.py followed by 'git cl presubmit'. Review-Url: https://codereview.webrtc.org/2663063003 Cr-Commit-Position: refs/heads/master@{#16392}
diff --git a/PRESUBMIT.py b/PRESUBMIT.py index 46be5ff..6e5fb59 100755 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py
@@ -15,6 +15,7 @@ # Directories that will be scanned by cpplint by the presubmit script. CPPLINT_DIRS = [ + 'webrtc/api', 'webrtc/audio', 'webrtc/call', 'webrtc/common_video',
diff --git a/webrtc/api/datachannelinterface.h b/webrtc/api/datachannelinterface.h index 8b788c0..5fa657d 100644 --- a/webrtc/api/datachannelinterface.h +++ b/webrtc/api/datachannelinterface.h
@@ -75,7 +75,7 @@ // A data buffer was successfully received. virtual void OnMessage(const DataBuffer& buffer) = 0; // The data channel's buffered_amount has changed. - virtual void OnBufferedAmountChange(uint64_t previous_amount){}; + virtual void OnBufferedAmountChange(uint64_t previous_amount) {} protected: virtual ~DataChannelObserver() {}
diff --git a/webrtc/api/fakemetricsobserver.h b/webrtc/api/fakemetricsobserver.h index baac0ca..90046c9 100644 --- a/webrtc/api/fakemetricsobserver.h +++ b/webrtc/api/fakemetricsobserver.h
@@ -13,6 +13,7 @@ #include <map> #include <string> +#include <vector> #include "webrtc/api/peerconnectioninterface.h" #include "webrtc/base/thread_checker.h"
diff --git a/webrtc/api/jsepicecandidate.h b/webrtc/api/jsepicecandidate.h index 7e9500b..af06431 100644 --- a/webrtc/api/jsepicecandidate.h +++ b/webrtc/api/jsepicecandidate.h
@@ -14,6 +14,8 @@ #define WEBRTC_API_JSEPICECANDIDATE_H_ #include <string> +#include <utility> +#include <vector> #include "webrtc/api/jsep.h" #include "webrtc/base/constructormagic.h"
diff --git a/webrtc/api/mediaconstraintsinterface.cc b/webrtc/api/mediaconstraintsinterface.cc index 5361a28..f393a2e 100644 --- a/webrtc/api/mediaconstraintsinterface.cc +++ b/webrtc/api/mediaconstraintsinterface.cc
@@ -70,7 +70,7 @@ *value_out = rtc::Optional<T>(value); } } -} +} // namespace namespace webrtc {
diff --git a/webrtc/api/mediastreamproxy.h b/webrtc/api/mediastreamproxy.h index 4253a09..fe11300 100644 --- a/webrtc/api/mediastreamproxy.h +++ b/webrtc/api/mediastreamproxy.h
@@ -11,6 +11,8 @@ #ifndef WEBRTC_API_MEDIASTREAMPROXY_H_ #define WEBRTC_API_MEDIASTREAMPROXY_H_ +#include <string> + #include "webrtc/api/mediastreaminterface.h" #include "webrtc/api/proxy.h"
diff --git a/webrtc/api/mediastreamtrackproxy.h b/webrtc/api/mediastreamtrackproxy.h index da371f8..9a3cb42 100644 --- a/webrtc/api/mediastreamtrackproxy.h +++ b/webrtc/api/mediastreamtrackproxy.h
@@ -14,6 +14,8 @@ #ifndef WEBRTC_API_MEDIASTREAMTRACKPROXY_H_ #define WEBRTC_API_MEDIASTREAMTRACKPROXY_H_ +#include <string> + #include "webrtc/api/mediastreaminterface.h" #include "webrtc/api/proxy.h"
diff --git a/webrtc/api/peerconnectioninterface.h b/webrtc/api/peerconnectioninterface.h index b1b996f..0280c18 100644 --- a/webrtc/api/peerconnectioninterface.h +++ b/webrtc/api/peerconnectioninterface.h
@@ -288,7 +288,7 @@ // Chrome in particular. RTCConfiguration() = default; - RTCConfiguration(RTCConfigurationType type) { + explicit RTCConfiguration(RTCConfigurationType type) { if (type == RTCConfigurationType::kAggressive) { // These parameters are also defined in Java and IOS configurations, // so their values may be overwritten by the Java or IOS configuration. @@ -669,7 +669,7 @@ // Triggered when a remote peer opens a data channel. virtual void OnDataChannel( - rtc::scoped_refptr<DataChannelInterface> data_channel){}; + rtc::scoped_refptr<DataChannelInterface> data_channel) {} // Deprecated; please use the version that uses a scoped_refptr. virtual void OnDataChannel(DataChannelInterface* data_channel) {}
diff --git a/webrtc/api/peerconnectionproxy.h b/webrtc/api/peerconnectionproxy.h index ed707b3..76b45d6 100644 --- a/webrtc/api/peerconnectionproxy.h +++ b/webrtc/api/peerconnectionproxy.h
@@ -11,6 +11,9 @@ #ifndef WEBRTC_API_PEERCONNECTIONPROXY_H_ #define WEBRTC_API_PEERCONNECTIONPROXY_H_ +#include <string> +#include <vector> + #include "webrtc/api/peerconnectioninterface.h" #include "webrtc/api/proxy.h"
diff --git a/webrtc/api/proxy.h b/webrtc/api/proxy.h index 51cdd29..f834790 100644 --- a/webrtc/api/proxy.h +++ b/webrtc/api/proxy.h
@@ -52,6 +52,7 @@ #define WEBRTC_API_PROXY_H_ #include <memory> +#include <utility> #include "webrtc/base/event.h" #include "webrtc/base/thread.h" @@ -349,6 +350,7 @@ T5 a5_; }; + // Helper macros to reduce code duplication. #define PROXY_MAP_BOILERPLATE(c) \ template <class INTERNAL_CLASS> \ @@ -363,6 +365,9 @@ const INTERNAL_CLASS* internal() const { return c_.get(); } \ INTERNAL_CLASS* internal() { return c_.get(); } +#define END_PROXY_MAP() \ + }; + #define SIGNALING_PROXY_MAP_BOILERPLATE(c) \ protected: \ c##ProxyWithInternal(rtc::Thread* signaling_thread, INTERNAL_CLASS* c) \ @@ -448,13 +453,13 @@ private: \ rtc::Thread* destructor_thread() const { return signaling_thread_; } \ \ - public: + public: // NOLINTNEXTLINE #define PROXY_WORKER_THREAD_DESTRUCTOR() \ private: \ rtc::Thread* destructor_thread() const { return worker_thread_; } \ \ - public: + public: // NOLINTNEXTLINE #define PROXY_METHOD0(r, method) \ r method() override { \ @@ -549,10 +554,6 @@ return call.Marshal(RTC_FROM_HERE, worker_thread_); \ } -#define END_PROXY_MAP() \ - } \ - ; - } // namespace webrtc #endif // WEBRTC_API_PROXY_H_
diff --git a/webrtc/api/stats/rtcstats_objects.h b/webrtc/api/stats/rtcstats_objects.h index c5277e7..ac00386 100644 --- a/webrtc/api/stats/rtcstats_objects.h +++ b/webrtc/api/stats/rtcstats_objects.h
@@ -12,6 +12,7 @@ #define WEBRTC_API_STATS_RTCSTATS_OBJECTS_H_ #include <string> +#include <vector> #include "webrtc/api/stats/rtcstats.h"
diff --git a/webrtc/api/statstypes.h b/webrtc/api/statstypes.h index 8f90c88..40d26ab 100644 --- a/webrtc/api/statstypes.h +++ b/webrtc/api/statstypes.h
@@ -18,6 +18,7 @@ #include <list> #include <map> #include <string> +#include <vector> #include "webrtc/base/basictypes.h" #include "webrtc/base/constructormagic.h" @@ -234,7 +235,7 @@ // Protected since users of the IdBase type will be using the Id typedef. virtual bool Equals(const IdBase& other) const; - IdBase(StatsType type); // Only meant for derived classes. + explicit IdBase(StatsType type); // Only meant for derived classes. const StatsType type_; static const char kSeparator = '_';
diff --git a/webrtc/api/umametrics.h b/webrtc/api/umametrics.h index 3e92bac..8999447 100644 --- a/webrtc/api/umametrics.h +++ b/webrtc/api/umametrics.h
@@ -113,7 +113,6 @@ class MetricsObserverInterface : public rtc::RefCountInterface { public: - // |type| is the type of the enum counter to be incremented. |counter| // is the particular counter in that type. |counter_max| is the next sequence // number after the highest counter.