Don't preload rarely seen large images
[chromium-blink-merge.git] / components / test_runner / mock_webrtc_peer_connection_handler.h
blob3470e1ba561e665ffaf2fe74047b18ce6268cd68
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_TEST_RUNNER_MOCK_WEBRTC_PEER_CONNECTION_HANDLER_H_
6 #define COMPONENTS_TEST_RUNNER_MOCK_WEBRTC_PEER_CONNECTION_HANDLER_H_
8 #include <map>
10 #include "base/basictypes.h"
11 #include "components/test_runner/web_task.h"
12 #include "third_party/WebKit/public/platform/WebRTCPeerConnectionHandler.h"
13 #include "third_party/WebKit/public/platform/WebRTCSessionDescription.h"
14 #include "third_party/WebKit/public/platform/WebRTCSessionDescriptionRequest.h"
15 #include "third_party/WebKit/public/platform/WebRTCStatsRequest.h"
17 namespace blink {
18 class WebRTCPeerConnectionHandlerClient;
21 namespace test_runner {
23 class TestInterfaces;
25 class MockWebRTCPeerConnectionHandler
26 : public blink::WebRTCPeerConnectionHandler {
27 public:
28 MockWebRTCPeerConnectionHandler(
29 blink::WebRTCPeerConnectionHandlerClient* client,
30 TestInterfaces* interfaces);
31 virtual ~MockWebRTCPeerConnectionHandler();
33 // WebRTCPeerConnectionHandler related methods
34 virtual bool initialize(
35 const blink::WebRTCConfiguration& configuration,
36 const blink::WebMediaConstraints& constraints) override;
38 virtual void createOffer(
39 const blink::WebRTCSessionDescriptionRequest& request,
40 const blink::WebMediaConstraints& constraints) override;
41 virtual void createOffer(
42 const blink::WebRTCSessionDescriptionRequest& request,
43 const blink::WebRTCOfferOptions& options) override;
44 virtual void createAnswer(
45 const blink::WebRTCSessionDescriptionRequest& request,
46 const blink::WebMediaConstraints& constraints) override;
47 virtual void setLocalDescription(
48 const blink::WebRTCVoidRequest& request,
49 const blink::WebRTCSessionDescription& local_description) override;
50 virtual void setRemoteDescription(
51 const blink::WebRTCVoidRequest& request,
52 const blink::WebRTCSessionDescription& remote_description) override;
53 virtual blink::WebRTCSessionDescription localDescription() override;
54 virtual blink::WebRTCSessionDescription remoteDescription() override;
55 virtual bool updateICE(
56 const blink::WebRTCConfiguration& configuration,
57 const blink::WebMediaConstraints& constraints) override;
58 virtual bool addICECandidate(
59 const blink::WebRTCICECandidate& ice_candidate) override;
60 virtual bool addICECandidate(
61 const blink::WebRTCVoidRequest& request,
62 const blink::WebRTCICECandidate& ice_candidate) override;
63 virtual bool addStream(
64 const blink::WebMediaStream& stream,
65 const blink::WebMediaConstraints& constraints) override;
66 virtual void removeStream(const blink::WebMediaStream& stream) override;
67 virtual void getStats(const blink::WebRTCStatsRequest& request) override;
68 virtual blink::WebRTCDataChannelHandler* createDataChannel(
69 const blink::WebString& label,
70 const blink::WebRTCDataChannelInit& init) override;
71 virtual blink::WebRTCDTMFSenderHandler* createDTMFSender(
72 const blink::WebMediaStreamTrack& track) override;
73 virtual void stop() override;
75 // WebTask related methods
76 WebTaskList* mutable_task_list() { return &task_list_; }
78 private:
79 MockWebRTCPeerConnectionHandler();
81 // UpdateRemoteStreams uses the collection of |local_streams_| to create
82 // remote MediaStreams with the same number of tracks and notifies |client_|
83 // about added and removed streams. It's triggered when setRemoteDescription
84 // is called.
85 void UpdateRemoteStreams();
87 blink::WebRTCPeerConnectionHandlerClient* client_;
88 bool stopped_;
89 WebTaskList task_list_;
90 blink::WebRTCSessionDescription local_description_;
91 blink::WebRTCSessionDescription remote_description_;
92 int stream_count_;
93 TestInterfaces* interfaces_;
94 typedef std::map<std::string, blink::WebMediaStream> StreamMap;
95 StreamMap local_streams_;
96 StreamMap remote_streams_;
98 DISALLOW_COPY_AND_ASSIGN(MockWebRTCPeerConnectionHandler);
101 } // namespace test_runner
103 #endif // COMPONENTS_TEST_RUNNER_MOCK_WEBRTC_PEER_CONNECTION_HANDLER_H_