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

Side by Side Diff: content/renderer/input/frame_input_handler_impl.h

Issue 2884243003: Add a mojo channel for frame messages. (Closed)
Patch Set: Fix presubmit warning I ignored Created 3 years, 6 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
« no previous file with comments | « content/renderer/BUILD.gn ('k') | content/renderer/input/frame_input_handler_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 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.
4
5 #ifndef CONTENT_RENDERER_INPUT_FRAME_INPUT_HANDLER_IMPL_H_
6 #define CONTENT_RENDERER_INPUT_FRAME_INPUT_HANDLER_IMPL_H_
7
8 #include "base/memory/ref_counted.h"
9 #include "content/common/input/input_handler.mojom.h"
10 #include "content/renderer/render_frame_impl.h"
11 #include "mojo/public/cpp/bindings/binding.h"
12
13 namespace content {
14 class MainThreadEventQueue;
15
16 // This class provides an implementation of FrameInputHandler mojo interface.
17 // When a compositor thread is being used in the renderer the mojo channel
18 // is bound on the compositor thread. Method calls, and events received on the
19 // compositor thread are then placed in the MainThreadEventQueue for
20 // the associated RenderWidget. This is done as to ensure that input related
21 // messages and events that are handled on the compositor thread aren't
22 // executed before other input events that need to be processed on the
23 // main thread. ie. Since some messages flow to the compositor thread
24 // all input needs to flow there so the ordering of events is kept in sequence.
25 //
26 // eg. (B = Browser, CT = Compositor Thread, MT = Main Thread)
27 // B sends MouseEvent
28 // B sends Copy message
29 // CT receives MouseEvent (CT might do something with the MouseEvent)
30 // CT places MouseEvent in MainThreadEventQueue
31 // CT receives Copy message (CT has no use for the Copy message)
32 // CT places Copy message in MainThreadEventQueue
33 // MT receives MouseEvent
34 // MT receives Copy message
35 //
36 // When a compositor thread isn't used the mojo channel is just bound
37 // on the main thread and messages are handled right away.
38 class FrameInputHandlerImpl : public mojom::FrameInputHandler {
39 public:
40 static void CreateMojoService(
41 base::WeakPtr<RenderFrameImpl> render_frame,
42 const service_manager::BindSourceInfo& source_info,
43 mojom::FrameInputHandlerRequest request);
44
45 void SetCompositionFromExistingText(
46 int32_t start,
47 int32_t end,
48 const std::vector<ui::CompositionUnderline>& underlines) override;
49 void ExtendSelectionAndDelete(int32_t before, int32_t after) override;
50 void DeleteSurroundingText(int32_t before, int32_t after) override;
51 void DeleteSurroundingTextInCodePoints(int32_t before,
52 int32_t after) override;
53 void SetEditableSelectionOffsets(int32_t start, int32_t end) override;
54 void ExecuteEditCommand(const std::string& command,
55 const base::Optional<base::string16>& value) override;
56 void Undo() override;
57 void Redo() override;
58 void Cut() override;
59 void Copy() override;
60 void CopyToFindPboard() override;
61 void Paste() override;
62 void PasteAndMatchStyle() override;
63 void Replace(const base::string16& word) override;
64 void ReplaceMisspelling(const base::string16& word) override;
65 void Delete() override;
66 void SelectAll() override;
67 void CollapseSelection() override;
68 void SelectRange(const gfx::Point& base, const gfx::Point& extent) override;
69 void AdjustSelectionByCharacterOffset(int32_t start, int32_t end) override;
70 void MoveRangeSelectionExtent(const gfx::Point& extent) override;
71
72 private:
73 ~FrameInputHandlerImpl() override;
74 enum class UpdateState { kNone, kIsPasting, kIsSelectingRange };
75
76 class HandlingState {
77 public:
78 HandlingState(RenderFrameImpl* render_frame, UpdateState state);
79 ~HandlingState();
80
81 private:
82 RenderFrameImpl* render_frame_;
83 bool original_select_range_value_;
84 bool original_pasting_value_;
85 };
86
87 FrameInputHandlerImpl(base::WeakPtr<RenderFrameImpl> render_frame,
88 mojom::FrameInputHandlerRequest request);
89
90 void RunOnMainThread(const base::Closure& closure);
91 void BindNow(mojom::FrameInputHandlerRequest request);
92 void ExecuteCommandOnMainThread(const std::string& command,
93 UpdateState state);
94 void Release();
95
96 mojo::Binding<mojom::FrameInputHandler> binding_;
97
98 // |render_frame_| should only be accessed on the main thread. Use
99 // GetRenderFrame so that it will DCHECK this for you.
100 base::WeakPtr<RenderFrameImpl> render_frame_;
101
102 scoped_refptr<MainThreadEventQueue> input_event_queue_;
103 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
104
105 base::WeakPtr<FrameInputHandlerImpl> weak_this_;
106 base::WeakPtrFactory<FrameInputHandlerImpl> weak_ptr_factory_;
107
108 DISALLOW_COPY_AND_ASSIGN(FrameInputHandlerImpl);
109 };
110
111 } // namespace content
112
113 #endif // CONTENT_RENDERER_INPUT_FRAME_INPUT_HANDLER_IMPL_H_
OLDNEW
« no previous file with comments | « content/renderer/BUILD.gn ('k') | content/renderer/input/frame_input_handler_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698