 Chromium Code Reviews
 Chromium Code Reviews Issue 2920013002:
  Use pdf compositor service for printing when OOPIF is enabled
    
  
    Issue 2920013002:
  Use pdf compositor service for printing when OOPIF is enabled 
  | Index: components/printing/browser/print_composite_client.h | 
| diff --git a/components/printing/browser/print_composite_client.h b/components/printing/browser/print_composite_client.h | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..3bf4c8dfd6732caf97dc3addfd2fa885eb120585 | 
| --- /dev/null | 
| +++ b/components/printing/browser/print_composite_client.h | 
| @@ -0,0 +1,49 @@ | 
| +// Copyright 2017 The Chromium Authors. All rights reserved. | 
| +// Use of this source code is governed by a BSD-style license that can be | 
| +// found in the LICENSE file. | 
| + | 
| +#ifndef COMPONENTS_PRINTING_BROWSER_PRINT_COMPOSITE_CLIENT_H_ | 
| +#define COMPONENTS_PRINTING_BROWSER_PRINT_COMPOSITE_CLIENT_H_ | 
| + | 
| +#include "base/memory/ref_counted_memory.h" | 
| +#include "base/memory/shared_memory.h" | 
| +#include "base/memory/shared_memory_handle.h" | 
| +#include "base/sequenced_task_runner.h" | 
| +#include "components/printing/service/public/cpp/pdf_compositor_client.h" | 
| +#include "content/public/browser/web_contents_observer.h" | 
| +#include "content/public/browser/web_contents_user_data.h" | 
| + | 
| +namespace printing { | 
| + | 
| +class PrintCompositeClient | 
| + : public PdfCompositorClient, | 
| + public content::WebContentsObserver, | 
| + public content::WebContentsUserData<PrintCompositeClient> { | 
| + public: | 
| + explicit PrintCompositeClient(content::WebContents* web_contents); | 
| + ~PrintCompositeClient() override; | 
| + | 
| + void CreateConnectorRequest(); | 
| + void DoComposite( | 
| + base::SharedMemoryHandle handle, | 
| + uint32_t data_size, | 
| + mojom::PdfCompositor::CompositePdfCallback callback, | 
| + 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.
 | 
| + | 
| + // Utility functions. | 
| + static std::unique_ptr<base::SharedMemory> GetShmFromMojoHandle( | 
| + mojo::ScopedSharedBufferHandle handle); | 
| + static scoped_refptr<base::RefCountedBytes> GetDataFromMojoHandle( | 
| + mojo::ScopedSharedBufferHandle handle); | 
| + | 
| + private: | 
| + service_manager::mojom::ConnectorRequest connector_request_; | 
| + std::unique_ptr<service_manager::Connector> connector_; | 
| + base::WeakPtrFactory<PrintCompositeClient> weak_factory_; | 
| + | 
| + DISALLOW_COPY_AND_ASSIGN(PrintCompositeClient); | 
| +}; | 
| + | 
| +} // namespace printing | 
| + | 
| +#endif // COMPONENTS_PRINTING_BROWSER_PRINT_COMPOSITE_CLIENT_H_ |