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

Side by Side Diff: base/version.cc

Issue 5918003: Bugfixes for recent PluginGroup refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
« no previous file with comments | « base/version.h ('k') | webkit/glue/plugins/plugin_group.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 (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 <algorithm>
8
7 #include "base/logging.h" 9 #include "base/logging.h"
8 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
9 #include "base/string_split.h" 11 #include "base/string_split.h"
10 #include "base/string_util.h" 12 #include "base/string_util.h"
11 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
12 14
13 // static 15 // static
14 Version* Version::GetVersionFromString(const std::wstring& version_str) { 16 Version* Version::GetVersionFromString(const std::wstring& version_str) {
15 if (!IsStringASCII(version_str)) 17 if (!IsStringASCII(version_str))
16 return NULL; 18 return NULL;
17 return GetVersionFromString(WideToUTF8(version_str)); 19 return GetVersionFromString(WideToUTF8(version_str));
18 } 20 }
19 21
20 // static 22 // static
21 Version* Version::GetVersionFromString(const std::string& version_str) { 23 Version* Version::GetVersionFromString(const std::string& version_str) {
22 Version* vers = new Version(); 24 Version* vers = new Version();
23 if (vers->InitFromString(version_str)) { 25 if (vers->InitFromString(version_str)) {
24 DCHECK(vers->is_valid_); 26 DCHECK(vers->is_valid_);
25 return vers; 27 return vers;
26 } 28 }
27 delete vers; 29 delete vers;
28 return NULL; 30 return NULL;
29 } 31 }
30 32
31 Version::Version() : is_valid_(false) {} 33 Version::Version() : is_valid_(false) {}
32 34
33 Version::~Version() {} 35 Version::~Version() {}
34 36
37 Version* Version::Clone() const {
38 DCHECK(is_valid_);
39 Version* copy = new Version();
40 copy->components_ = components_;
41 copy->is_valid_ = true;
42 return copy;
43 }
44
35 bool Version::Equals(const Version& that) const { 45 bool Version::Equals(const Version& that) const {
36 DCHECK(is_valid_); 46 DCHECK(is_valid_);
37 DCHECK(that.is_valid_); 47 DCHECK(that.is_valid_);
38 return CompareTo(that) == 0; 48 return CompareTo(that) == 0;
39 } 49 }
40 50
41 int Version::CompareTo(const Version& other) const { 51 int Version::CompareTo(const Version& other) const {
42 DCHECK(is_valid_); 52 DCHECK(is_valid_);
43 DCHECK(other.is_valid_); 53 DCHECK(other.is_valid_);
44 size_t count = std::min(components_.size(), other.components_.size()); 54 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; 100 return false;
91 // This throws out things like +3, or 032. 101 // This throws out things like +3, or 032.
92 if (base::IntToString(num) != *i) 102 if (base::IntToString(num) != *i)
93 return false; 103 return false;
94 uint16 component = static_cast<uint16>(num); 104 uint16 component = static_cast<uint16>(num);
95 components_.push_back(component); 105 components_.push_back(component);
96 } 106 }
97 is_valid_ = true; 107 is_valid_ = true;
98 return true; 108 return true;
99 } 109 }
OLDNEW
« no previous file with comments | « base/version.h ('k') | webkit/glue/plugins/plugin_group.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698