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

Side by Side Diff: chrome/browser/mod_pagespeed/mod_pagespeed_metrics.cc

Issue 2465023002: Make SVN commit number an optional part of X-Mod-Pagespeed header. (Closed)
Patch Set: remove unneeded comment Created 4 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/mod_pagespeed/mod_pagespeed_metrics_unittest.cc » ('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 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 24 matching lines...) Expand all
35 PAGESPEED_UNKNOWN_SERVER = 4, 35 PAGESPEED_UNKNOWN_SERVER = 4,
36 PAGESPEED_SERVER_MAXIMUM = 5 36 PAGESPEED_SERVER_MAXIMUM = 5
37 }; 37 };
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 const char* version_string = version.c_str();
46 int num_parsed = sscanf(version_string, "%d.%d.%d.%d-%d", &unused_major,
Charlie Harrison 2016/10/31 20:29:00 I wonder if you could do sscanf(version_string, "%
46 &unused_minor, &branch, &point, &unused_commit); 47 &unused_minor, &branch, &point, &unused_commit);
48 if (num_parsed != 5) {
49 num_parsed = sscanf(version_string, "%d.%d.%d.%d", &unused_major,
50 &unused_minor, &branch, &point);
51 }
47 int output = 0; 52 int output = 0;
48 if (num_parsed == 5) { 53 if (num_parsed == 4 || num_parsed == 5) {
49 output = 2; 54 output = 2;
50 if (branch > 10) 55 if (branch > 10)
51 output += 2 * (branch - 10); 56 output += 2 * (branch - 10);
52 if (point > 1) 57 if (point > 1)
53 output++; 58 output++;
54 if (output < 2 || output > 99) 59 if (output < 2 || output > 99)
55 output = 0; 60 output = 0;
56 } 61 }
57 return output; 62 return output;
58 } 63 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 PAGESPEED_UNKNOWN_SERVER, 139 PAGESPEED_UNKNOWN_SERVER,
135 PAGESPEED_SERVER_MAXIMUM); 140 PAGESPEED_SERVER_MAXIMUM);
136 } 141 }
137 } 142 }
138 break; 143 break;
139 } 144 }
140 } 145 }
141 } 146 }
142 147
143 } // namespace mod_pagespeed 148 } // namespace mod_pagespeed
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/mod_pagespeed/mod_pagespeed_metrics_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698