Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(622)

Side by Side Diff: content/browser/devtools/protocol/frame_recorder.h

Issue 888573002: DevTools: FrameRecorder: add cancelRecordingFrames command (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_FRAME_RECORDER_H_ 5 #ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_FRAME_RECORDER_H_
6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_FRAME_RECORDER_H_ 6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_FRAME_RECORDER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <utility>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/cancelable_callback.h"
12 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
14 #include "base/time/time.h" 16 #include "base/time/time.h"
15 #include "content/browser/devtools/protocol/devtools_protocol_handler.h" 17 #include "content/browser/devtools/protocol/devtools_protocol_handler.h"
16 #include "content/public/browser/readback_types.h" 18 #include "content/public/browser/readback_types.h"
17 19
18 class SkBitmap; 20 class SkBitmap;
19 21
20 namespace content { 22 namespace content {
21 23
22 class RenderViewHostImpl; 24 class RenderViewHostImpl;
23 25
24 namespace devtools { 26 namespace devtools {
25 namespace page { 27 namespace page {
26 28
27 class FrameRecorder { 29 class FrameRecorder {
28 public: 30 public:
29 using Response = DevToolsProtocolClient::Response; 31 using Response = DevToolsProtocolClient::Response;
30 using StopRecordingFramesCallback = 32 using StopRecordingFramesCallback =
31 base::Callback<void(scoped_refptr<StopRecordingFramesResponse>)>; 33 base::Callback<void(scoped_refptr<StopRecordingFramesResponse>)>;
32 34
33 explicit FrameRecorder(); 35 explicit FrameRecorder();
34 virtual ~FrameRecorder(); 36 virtual ~FrameRecorder();
35 37
36 Response StartRecordingFrames(int max_frame_count); 38 Response StartRecordingFrames(int max_frame_count);
37 Response StopRecordingFrames(StopRecordingFramesCallback callback); 39 Response StopRecordingFrames(
40 StopRecordingFramesCallback callback, bool cancel);
38 41
39 void SetRenderViewHost(RenderViewHostImpl* host); 42 void SetRenderViewHost(RenderViewHostImpl* host);
40 void OnSwapCompositorFrame(); 43 void OnSwapCompositorFrame();
41 44
42 private: 45 private:
43 enum State { 46 enum State {
44 Ready, 47 Ready,
45 Recording, 48 Recording,
46 Encoding 49 Encoding
47 }; 50 };
48 51
49 void FrameCaptured(const SkBitmap& bitmap, ReadbackResponse response); 52 void FrameCaptured(const SkBitmap& bitmap, ReadbackResponse response);
50 void FrameEncoded(double timestamp, const std::string& encoded_frame); 53 void FrameEncoded(const std::pair<std::string, double>& encoded_frame);
51 void MaybeSendResponse(); 54 void MaybeSendResponse();
52 55
53 RenderViewHostImpl* host_; 56 RenderViewHostImpl* host_;
54 State state_; 57 State state_;
55 StopRecordingFramesCallback callback_; 58 StopRecordingFramesCallback callback_;
56 size_t inflight_requests_count_; 59 size_t inflight_requests_count_;
57 size_t max_frame_count_; 60 size_t max_frame_count_;
58 size_t captured_frames_count_; 61 size_t captured_frames_count_;
59 base::Time last_captured_frame_timestamp_; 62 base::Time last_captured_frame_timestamp_;
60 std::vector<scoped_refptr<devtools::page::RecordedFrame>> frames_; 63 std::vector<scoped_refptr<devtools::page::RecordedFrame>> frames_;
61 64
65 base::CancelableCallback<void(const std::pair<std::string, double>&)>
66 frame_encoded_callback_;
62 base::WeakPtrFactory<FrameRecorder> weak_factory_; 67 base::WeakPtrFactory<FrameRecorder> weak_factory_;
63 68
64 DISALLOW_COPY_AND_ASSIGN(FrameRecorder); 69 DISALLOW_COPY_AND_ASSIGN(FrameRecorder);
65 }; 70 };
66 71
67 } // namespace page 72 } // namespace page
68 } // namespace devtools 73 } // namespace devtools
69 } // namespace content 74 } // namespace content
70 75
71 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_FRAME_RECORDER_H_ 76 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_FRAME_RECORDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698