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

Side by Side Diff: components/cloud_devices/description_items.h

Issue 171683020: Use to base::checked_cast. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | components/cloud_devices/description_items_inl.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 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 #ifndef COMPONENTS_CLOUD_DEVICES_CAPABILITY_INTERFACES_H_ 5 #ifndef COMPONENTS_CLOUD_DEVICES_CAPABILITY_INTERFACES_H_
6 #define COMPONENTS_CLOUD_DEVICES_CAPABILITY_INTERFACES_H_ 6 #define COMPONENTS_CLOUD_DEVICES_CAPABILITY_INTERFACES_H_
7 7
8 // Defines common templates that could be used to create device specific 8 // Defines common templates that could be used to create device specific
9 // capabilities and print tickets. 9 // capabilities and print tickets.
10 10
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/logging.h" 13 #include "base/logging.h"
14 14 #include "base/numerics/safe_conversions.h"
15 #include "components/cloud_devices/cloud_device_description.h" 15 #include "components/cloud_devices/cloud_device_description.h"
16 16
17 namespace base { 17 namespace base {
18 class DictionaryValue; 18 class DictionaryValue;
19 } 19 }
20 20
21 namespace cloud_devices { 21 namespace cloud_devices {
22 22
23 // All traits below specify how to serialize and validate capabilities and 23 // All traits below specify how to serialize and validate capabilities and
24 // ticket items. 24 // ticket items.
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 } 126 }
127 127
128 void AddOption(const Option& option) { 128 void AddOption(const Option& option) {
129 AddDefaultOption(option, false); 129 AddDefaultOption(option, false);
130 } 130 }
131 131
132 void AddDefaultOption(const Option& option, bool is_default) { 132 void AddDefaultOption(const Option& option, bool is_default) {
133 if (is_default) { 133 if (is_default) {
134 DCHECK_EQ(default_idx_, -1); 134 DCHECK_EQ(default_idx_, -1);
135 // Point to the last element. 135 // Point to the last element.
136 default_idx_ = static_cast<int>(size()); 136 default_idx_ = base::checked_cast<int>(size());
137 } 137 }
138 options_.push_back(option); 138 options_.push_back(option);
139 } 139 }
140 140
141 private: 141 private:
142 typedef std::vector<Option> OptionVector; 142 typedef std::vector<Option> OptionVector;
143 143
144 OptionVector options_; 144 OptionVector options_;
145 int default_idx_; 145 int default_idx_;
146 146
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 222
223 private: 223 private:
224 Option value_; 224 Option value_;
225 225
226 DISALLOW_COPY_AND_ASSIGN(TicketItem); 226 DISALLOW_COPY_AND_ASSIGN(TicketItem);
227 }; 227 };
228 228
229 } // namespace cloud_devices 229 } // namespace cloud_devices
230 230
231 #endif // COMPONENTS_CLOUD_DEVICES_CAPABILITY_INTERFACES_H_ 231 #endif // COMPONENTS_CLOUD_DEVICES_CAPABILITY_INTERFACES_H_
OLDNEW
« no previous file with comments | « no previous file | components/cloud_devices/description_items_inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698