Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / public / platform / WebRTCStatsRequest.h
blobd74d4dde56c32027e2c3d3fa937bccbb2c2e3c2e
1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #ifndef WebRTCStatsRequest_h
32 #define WebRTCStatsRequest_h
34 #include "WebCommon.h"
35 #include "WebPrivatePtr.h"
36 #include "WebString.h"
38 namespace blink {
40 class RTCStatsRequest;
41 class WebMediaStreamTrack;
42 class WebMediaStream;
43 class WebRTCStatsResponse;
45 // The WebRTCStatsRequest class represents a JavaScript call on
46 // RTCPeerConnection.getStats(). The user of this API will use
47 // the calls on this class and WebRTCStatsResponse to fill in the
48 // data that will be returned via a callback to the user in an
49 // RTCStatsResponse structure.
51 // The typical usage pattern is:
52 // WebRTCStatsRequest request = <from somewhere>
53 // WebRTCStatsResponse response = request.createResponse();
55 // For each item on which statistics are going to be reported:
56 // size_t reportIndex = response.addReport();
57 // Add local information:
58 // size_t elementIndex = response.addElement(reportIndex, true, dateNow());
59 // For each statistic being reported on:
60 // response.addStatistic(reportIndex, true, elementIndex,
61 // "name of statistic", "statistic value");
62 // Remote information (typically RTCP-derived) is added in the same way.
63 // When finished adding information:
64 // request.requestSucceeded(response);
66 class WebRTCStatsRequest {
67 public:
68 WebRTCStatsRequest() { }
69 WebRTCStatsRequest(const WebRTCStatsRequest& other) { assign(other); }
70 ~WebRTCStatsRequest() { reset(); }
72 WebRTCStatsRequest& operator=(const WebRTCStatsRequest& other)
74 assign(other);
75 return *this;
78 BLINK_PLATFORM_EXPORT void assign(const WebRTCStatsRequest&);
80 BLINK_PLATFORM_EXPORT void reset();
82 // This function returns true if a selector argument was given to getStats.
83 BLINK_PLATFORM_EXPORT bool hasSelector() const;
85 // The component() accessor give the information
86 // required to look up a MediaStreamTrack implementation.
87 // It is only useful to call it when hasSelector() returns true.
88 BLINK_PLATFORM_EXPORT const WebMediaStreamTrack component() const;
90 BLINK_PLATFORM_EXPORT void requestSucceeded(const WebRTCStatsResponse&) const;
92 BLINK_PLATFORM_EXPORT WebRTCStatsResponse createResponse() const;
94 #if INSIDE_BLINK
95 BLINK_PLATFORM_EXPORT WebRTCStatsRequest(RTCStatsRequest*);
96 #endif
98 private:
99 WebPrivatePtr<RTCStatsRequest> m_private;
102 } // namespace blink
104 #endif // WebRTCStatsRequest_h