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

Side by Side Diff: base/version.cc

Issue 5783005: PluginList: Unit tests and bugfixes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments; rebase Created 10 years 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "base/version.h" 5 #include "base/version.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/string_split.h" 9 #include "base/string_split.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 14 matching lines...) Expand all
25 return vers; 25 return vers;
26 } 26 }
27 delete vers; 27 delete vers;
28 return NULL; 28 return NULL;
29 } 29 }
30 30
31 Version::Version() : is_valid_(false) {} 31 Version::Version() : is_valid_(false) {}
32 32
33 Version::~Version() {} 33 Version::~Version() {}
34 34
35 Version* Version::Clone() const {
36 DCHECK(is_valid_);
37 Version* copy = new Version();
38 copy->components_ = components_;
39 copy->is_valid_ = true;
40 return copy;
41 }
42
35 bool Version::Equals(const Version& that) const { 43 bool Version::Equals(const Version& that) const {
36 DCHECK(is_valid_); 44 DCHECK(is_valid_);
37 DCHECK(that.is_valid_); 45 DCHECK(that.is_valid_);
38 return CompareTo(that) == 0; 46 return CompareTo(that) == 0;
39 } 47 }
40 48
41 int Version::CompareTo(const Version& other) const { 49 int Version::CompareTo(const Version& other) const {
42 DCHECK(is_valid_); 50 DCHECK(is_valid_);
43 DCHECK(other.is_valid_); 51 DCHECK(other.is_valid_);
44 size_t count = std::min(components_.size(), other.components_.size()); 52 size_t count = std::min(components_.size(), other.components_.size());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 return false; 98 return false;
91 // This throws out things like +3, or 032. 99 // This throws out things like +3, or 032.
92 if (base::IntToString(num) != *i) 100 if (base::IntToString(num) != *i)
93 return false; 101 return false;
94 uint16 component = static_cast<uint16>(num); 102 uint16 component = static_cast<uint16>(num);
95 components_.push_back(component); 103 components_.push_back(component);
96 } 104 }
97 is_valid_ = true; 105 is_valid_ = true;
98 return true; 106 return true;
99 } 107 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698