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

Side by Side Diff: components/enhanced_bookmarks/image_store_util_ios.mm

Issue 623133002: replace OVERRIDE and FINAL with override and final in components/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 #include "components/enhanced_bookmarks/image_store_util.h" 5 #include "components/enhanced_bookmarks/image_store_util.h"
6 6
7 #import <UIKit/UIKit.h> 7 #import <UIKit/UIKit.h>
8 8
9 #include "base/mac/scoped_cftyperef.h" 9 #include "base/mac/scoped_cftyperef.h"
10 #include "base/mac/scoped_nsobject.h" 10 #include "base/mac/scoped_nsobject.h"
11 11
12 namespace { 12 namespace {
13 // An implementation of RefCountedMemory, where the bytes are stored in a 13 // An implementation of RefCountedMemory, where the bytes are stored in a
14 // NSData. This class assumes the NSData is non mutable to avoid a copy. 14 // NSData. This class assumes the NSData is non mutable to avoid a copy.
15 class RefCountedNSDataMemory : public base::RefCountedMemory { 15 class RefCountedNSDataMemory : public base::RefCountedMemory {
16 public: 16 public:
17 explicit RefCountedNSDataMemory(NSData* memory) : data_([memory retain]) {} 17 explicit RefCountedNSDataMemory(NSData* memory) : data_([memory retain]) {}
18 18
19 virtual const unsigned char* front() const OVERRIDE { 19 virtual const unsigned char* front() const override {
20 return reinterpret_cast<const unsigned char*>([data_ bytes]); 20 return reinterpret_cast<const unsigned char*>([data_ bytes]);
21 } 21 }
22 22
23 virtual size_t size() const OVERRIDE { 23 virtual size_t size() const override {
24 return [data_ length]; 24 return [data_ length];
25 } 25 }
26 26
27 private: 27 private:
28 virtual ~RefCountedNSDataMemory() {} 28 virtual ~RefCountedNSDataMemory() {}
29 29
30 base::scoped_nsobject<NSData> data_; 30 base::scoped_nsobject<NSData> data_;
31 DISALLOW_COPY_AND_ASSIGN(RefCountedNSDataMemory); 31 DISALLOW_COPY_AND_ASSIGN(RefCountedNSDataMemory);
32 }; 32 };
33 } // namespace 33 } // namespace
34 34
35 namespace enhanced_bookmarks { 35 namespace enhanced_bookmarks {
36 36
37 // Encodes the UIImage representation of a gfx::Image. 37 // Encodes the UIImage representation of a gfx::Image.
38 scoped_refptr<base::RefCountedMemory> BytesForImage(const gfx::Image& image) { 38 scoped_refptr<base::RefCountedMemory> BytesForImage(const gfx::Image& image) {
39 DCHECK(image.HasRepresentation(gfx::Image::kImageRepCocoaTouch)); 39 DCHECK(image.HasRepresentation(gfx::Image::kImageRepCocoaTouch));
40 return scoped_refptr<RefCountedNSDataMemory>(new RefCountedNSDataMemory( 40 return scoped_refptr<RefCountedNSDataMemory>(new RefCountedNSDataMemory(
41 [NSKeyedArchiver archivedDataWithRootObject:image.ToUIImage()])); 41 [NSKeyedArchiver archivedDataWithRootObject:image.ToUIImage()]));
42 } 42 }
43 43
44 // Decodes the UIImage in the bytes and returns a gfx::Image. 44 // Decodes the UIImage in the bytes and returns a gfx::Image.
45 gfx::Image ImageForBytes(const scoped_refptr<base::RefCountedMemory>& data) { 45 gfx::Image ImageForBytes(const scoped_refptr<base::RefCountedMemory>& data) {
46 return gfx::Image([[NSKeyedUnarchiver unarchiveObjectWithData: 46 return gfx::Image([[NSKeyedUnarchiver unarchiveObjectWithData:
47 [NSData dataWithBytes:data->front() length:data->size()]] retain]); 47 [NSData dataWithBytes:data->front() length:data->size()]] retain]);
48 } 48 }
49 49
50 } // namespace enhanced_bookmarks 50 } // namespace enhanced_bookmarks
OLDNEW
« no previous file with comments | « components/enhanced_bookmarks/image_store_unittest.cc ('k') | components/enhanced_bookmarks/persistent_image_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698