| 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 #include "chrome/browser/mod_pagespeed/mod_pagespeed_metrics.h" | 5 #include "chrome/browser/mod_pagespeed/mod_pagespeed_metrics.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 // Parse the PageSpeed version number and encodes it in buckets 2 through 99: if | 39 // Parse the PageSpeed version number and encodes it in buckets 2 through 99: if |
| 40 // it is in the format MAJOR.MINOR.BRANCH.POINT-COMMIT the bucket will be 2 + 2 | 40 // it is in the format MAJOR.MINOR.BRANCH.POINT-COMMIT the bucket will be 2 + 2 |
| 41 // * (max(BRANCH, 10) - 10) + (POINT > 1 ? 1 : 0); otherwise the bucket is | 41 // * (max(BRANCH, 10) - 10) + (POINT > 1 ? 1 : 0); otherwise the bucket is |
| 42 // zero. | 42 // zero. |
| 43 int GetXModPagespeedBucketFromVersion(const std::string& version) { | 43 int GetXModPagespeedBucketFromVersion(const std::string& version) { |
| 44 int unused_major, unused_minor, branch, point, unused_commit; | 44 int unused_major, unused_minor, branch, point, unused_commit; |
| 45 int num_parsed = sscanf(version.c_str(), "%d.%d.%d.%d-%d", &unused_major, | 45 int num_parsed = sscanf(version.c_str(), "%d.%d.%d.%d-%d", &unused_major, |
| 46 &unused_minor, &branch, &point, &unused_commit); | 46 &unused_minor, &branch, &point, &unused_commit); |
| 47 int output = 0; | 47 int output = 0; |
| 48 if (num_parsed == 5) { | 48 if (num_parsed >= 4) { |
| 49 output = 2; | 49 output = 2; |
| 50 if (branch > 10) | 50 if (branch > 10) |
| 51 output += 2 * (branch - 10); | 51 output += 2 * (branch - 10); |
| 52 if (point > 1) | 52 if (point > 1) |
| 53 output++; | 53 output++; |
| 54 if (output < 2 || output > 99) | 54 if (output < 2 || output > 99) |
| 55 output = 0; | 55 output = 0; |
| 56 } | 56 } |
| 57 return output; | 57 return output; |
| 58 } | 58 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 PAGESPEED_UNKNOWN_SERVER, | 134 PAGESPEED_UNKNOWN_SERVER, |
| 135 PAGESPEED_SERVER_MAXIMUM); | 135 PAGESPEED_SERVER_MAXIMUM); |
| 136 } | 136 } |
| 137 } | 137 } |
| 138 break; | 138 break; |
| 139 } | 139 } |
| 140 } | 140 } |
| 141 } | 141 } |
| 142 | 142 |
| 143 } // namespace mod_pagespeed | 143 } // namespace mod_pagespeed |
| OLD | NEW |