| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #import "ios/chrome/common/physical_web/physical_web_device.h" | 5 #import "ios/chrome/common/physical_web/physical_web_device.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/mac/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
| 9 #include "ios/chrome/common/physical_web/physical_web_types.h" | 9 #include "ios/chrome/common/physical_web/physical_web_types.h" |
| 10 | 10 |
| 11 @implementation PhysicalWebDevice { | 11 @implementation PhysicalWebDevice { |
| 12 base::scoped_nsobject<NSURL> url_; | 12 base::scoped_nsobject<NSURL> url_; |
| 13 base::scoped_nsobject<NSURL> requestURL_; | 13 base::scoped_nsobject<NSURL> requestURL_; |
| 14 base::scoped_nsobject<NSURL> icon_; | 14 base::scoped_nsobject<NSURL> icon_; |
| 15 base::scoped_nsobject<NSString> title_; | 15 base::scoped_nsobject<NSString> title_; |
| 16 base::scoped_nsobject<NSString> description_; | 16 base::scoped_nsobject<NSString> description_; |
| 17 int rssi_; | 17 int rssi_; |
| 18 int transmitPower_; | 18 int transmitPower_; |
| 19 double rank_; | 19 double rank_; |
| 20 base::scoped_nsobject<NSDate> scanTimestamp_; |
| 20 } | 21 } |
| 21 | 22 |
| 22 @synthesize rssi = rssi_; | 23 @synthesize rssi = rssi_; |
| 23 @synthesize transmitPower = transmitPower_; | 24 @synthesize transmitPower = transmitPower_; |
| 24 @synthesize rank = rank_; | 25 @synthesize rank = rank_; |
| 25 | 26 |
| 26 - (instancetype)initWithURL:(NSURL*)url | 27 - (instancetype)initWithURL:(NSURL*)url |
| 27 requestURL:(NSURL*)requestURL | 28 requestURL:(NSURL*)requestURL |
| 28 icon:(NSURL*)icon | 29 icon:(NSURL*)icon |
| 29 title:(NSString*)title | 30 title:(NSString*)title |
| 30 description:(NSString*)description | 31 description:(NSString*)description |
| 31 transmitPower:(int)transmitPower | 32 transmitPower:(int)transmitPower |
| 32 rssi:(int)rssi | 33 rssi:(int)rssi |
| 33 rank:(double)rank { | 34 rank:(double)rank |
| 35 scanTimestamp:(NSDate*)scanTimestamp { |
| 34 self = [super init]; | 36 self = [super init]; |
| 35 if (self) { | 37 if (self) { |
| 36 url_.reset([url retain]); | 38 url_.reset([url retain]); |
| 37 requestURL_.reset([requestURL retain]); | 39 requestURL_.reset([requestURL retain]); |
| 38 icon_.reset([icon retain]); | 40 icon_.reset([icon retain]); |
| 39 title_.reset([title copy]); | 41 title_.reset([title copy]); |
| 40 description_.reset([description copy]); | 42 description_.reset([description copy]); |
| 41 transmitPower_ = transmitPower; | 43 transmitPower_ = transmitPower; |
| 42 rssi_ = rssi; | 44 rssi_ = rssi; |
| 43 rank_ = rank > physical_web::kMaxRank ? physical_web::kMaxRank : rank; | 45 rank_ = rank > physical_web::kMaxRank ? physical_web::kMaxRank : rank; |
| 46 scanTimestamp_.reset([scanTimestamp retain]); |
| 44 } | 47 } |
| 45 return self; | 48 return self; |
| 46 } | 49 } |
| 47 | 50 |
| 48 - (instancetype)init { | 51 - (instancetype)init { |
| 49 NOTREACHED(); | 52 NOTREACHED(); |
| 50 return nil; | 53 return nil; |
| 51 } | 54 } |
| 52 | 55 |
| 53 - (NSURL*)url { | 56 - (NSURL*)url { |
| 54 return url_; | 57 return url_; |
| 55 } | 58 } |
| 56 | 59 |
| 57 - (NSURL*)requestURL { | 60 - (NSURL*)requestURL { |
| 58 return requestURL_; | 61 return requestURL_; |
| 59 } | 62 } |
| 60 | 63 |
| 61 - (NSURL*)icon { | 64 - (NSURL*)icon { |
| 62 return icon_; | 65 return icon_; |
| 63 } | 66 } |
| 64 | 67 |
| 65 - (NSString*)title { | 68 - (NSString*)title { |
| 66 return title_; | 69 return title_; |
| 67 } | 70 } |
| 68 | 71 |
| 69 - (NSString*)description { | 72 - (NSString*)description { |
| 70 return description_; | 73 return description_; |
| 71 } | 74 } |
| 72 | 75 |
| 76 - (NSDate*)scanTimestamp { |
| 77 return scanTimestamp_; |
| 78 } |
| 79 |
| 80 - (void)setScanTimestamp:(NSDate*)value { |
| 81 scanTimestamp_.reset([value retain]); |
| 82 } |
| 83 |
| 73 @end | 84 @end |
| OLD | NEW |