OLD | NEW |
---|---|
(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 COMPONENTS_PRINTING_BROWSER_PRINT_COMPOSITE_CLIENT_H_ | |
6 #define COMPONENTS_PRINTING_BROWSER_PRINT_COMPOSITE_CLIENT_H_ | |
7 | |
8 #include "base/memory/ref_counted_memory.h" | |
9 #include "base/memory/shared_memory.h" | |
10 #include "base/memory/shared_memory_handle.h" | |
11 #include "base/sequenced_task_runner.h" | |
12 #include "components/printing/service/public/cpp/pdf_compositor_client.h" | |
13 #include "content/public/browser/web_contents_observer.h" | |
14 #include "content/public/browser/web_contents_user_data.h" | |
15 | |
16 namespace printing { | |
17 | |
18 class PrintCompositeClient | |
19 : public PdfCompositorClient, | |
20 public content::WebContentsObserver, | |
21 public content::WebContentsUserData<PrintCompositeClient> { | |
22 public: | |
23 explicit PrintCompositeClient(content::WebContents* web_contents); | |
24 ~PrintCompositeClient() override; | |
25 | |
26 void CreateConnectorRequest(); | |
27 void DoComposite( | |
28 base::SharedMemoryHandle handle, | |
29 uint32_t data_size, | |
30 mojom::PdfCompositor::CompositePdfCallback callback, | |
31 scoped_refptr<base::SequencedTaskRunner> callback_task_runner); | |
Lei Zhang
2017/08/28 23:01:13
Is this always going to be UI thread?
Wei Li
2017/08/30 00:24:03
Yes, so far all the callers are from UI thread. Bu
Lei Zhang
2017/08/30 02:00:35
Is it reasonable to make DoComposite() just reply
Wei Li
2017/08/31 21:00:25
Sounds good, done.
| |
32 | |
33 // Utility functions. | |
34 static std::unique_ptr<base::SharedMemory> GetShmFromMojoHandle( | |
35 mojo::ScopedSharedBufferHandle handle); | |
36 static scoped_refptr<base::RefCountedBytes> GetDataFromMojoHandle( | |
37 mojo::ScopedSharedBufferHandle handle); | |
38 | |
39 private: | |
40 service_manager::mojom::ConnectorRequest connector_request_; | |
41 std::unique_ptr<service_manager::Connector> connector_; | |
42 base::WeakPtrFactory<PrintCompositeClient> weak_factory_; | |
43 | |
44 DISALLOW_COPY_AND_ASSIGN(PrintCompositeClient); | |
45 }; | |
46 | |
47 } // namespace printing | |
48 | |
49 #endif // COMPONENTS_PRINTING_BROWSER_PRINT_COMPOSITE_CLIENT_H_ | |
OLD | NEW |