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

Side by Side Diff: chrome/utility/image_decoder_impl.cc

Issue 2326913003: Privatize StrongBinding lifetime management (Closed)
Patch Set: rebase Created 4 years, 3 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 | « chrome/utility/image_decoder_impl.h ('k') | chrome/utility/shell_handler_impl_win.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "chrome/utility/image_decoder_impl.h" 5 #include "chrome/utility/image_decoder_impl.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "content/public/child/image_decoder_utils.h" 12 #include "content/public/child/image_decoder_utils.h"
13 #include "ipc/ipc_channel.h" 13 #include "ipc/ipc_channel.h"
14 #include "mojo/public/cpp/bindings/strong_binding.h"
14 #include "skia/ext/image_operations.h" 15 #include "skia/ext/image_operations.h"
15 #include "third_party/skia/include/core/SkBitmap.h" 16 #include "third_party/skia/include/core/SkBitmap.h"
16 #include "ui/gfx/geometry/size.h" 17 #include "ui/gfx/geometry/size.h"
17 18
18 #if defined(OS_CHROMEOS) 19 #if defined(OS_CHROMEOS)
19 #include "ui/gfx/chromeos/codec/jpeg_codec_robust_slow.h" 20 #include "ui/gfx/chromeos/codec/jpeg_codec_robust_slow.h"
20 #include "ui/gfx/codec/png_codec.h" 21 #include "ui/gfx/codec/png_codec.h"
21 #endif 22 #endif
22 23
23 namespace { 24 namespace {
24 int64_t kMaxMessageSize = IPC::Channel::kMaximumMessageSize; 25 int64_t kMaxMessageSize = IPC::Channel::kMaximumMessageSize;
25 int64_t kPadding = 64; 26 int64_t kPadding = 64;
26 } 27 }
27 28
29 ImageDecoderImpl::ImageDecoderImpl() : ImageDecoderImpl(kMaxMessageSize) {}
30
28 ImageDecoderImpl::ImageDecoderImpl(int64_t max_message_size) 31 ImageDecoderImpl::ImageDecoderImpl(int64_t max_message_size)
29 : max_message_size_(max_message_size), binding_(this) { 32 : max_message_size_(max_message_size) {}
30 }
31
32 ImageDecoderImpl::ImageDecoderImpl(
33 mojo::InterfaceRequest<mojom::ImageDecoder> request)
34 : max_message_size_(kMaxMessageSize), binding_(this, std::move(request)) {
35 }
36 33
37 ImageDecoderImpl::~ImageDecoderImpl() { 34 ImageDecoderImpl::~ImageDecoderImpl() {
38 } 35 }
39 36
40 void ImageDecoderImpl::DecodeImage( 37 void ImageDecoderImpl::DecodeImage(
41 mojo::Array<uint8_t> encoded_data, 38 mojo::Array<uint8_t> encoded_data,
42 mojom::ImageCodec codec, 39 mojom::ImageCodec codec,
43 bool shrink_to_fit, 40 bool shrink_to_fit,
44 const DecodeImageCallback& callback) { 41 const DecodeImageCallback& callback) {
45 if (encoded_data.size() == 0) { 42 if (encoded_data.size() == 0) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 decoded_image, skia::ImageOperations::RESIZE_LANCZOS3, 90 decoded_image, skia::ImageOperations::RESIZE_LANCZOS3,
94 decoded_image.width() >> halves, decoded_image.height() >> halves); 91 decoded_image.width() >> halves, decoded_image.height() >> halves);
95 } else { 92 } else {
96 decoded_image.reset(); 93 decoded_image.reset();
97 } 94 }
98 } 95 }
99 } 96 }
100 97
101 callback.Run(decoded_image); 98 callback.Run(decoded_image);
102 } 99 }
OLDNEW
« no previous file with comments | « chrome/utility/image_decoder_impl.h ('k') | chrome/utility/shell_handler_impl_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698