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

Side by Side Diff: rlz/lib/rlz_lib.cc

Issue 11226060: RLZ: remove hard-coded Win || Mac conditions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge Created 8 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 | Annotate | Revision Log
« no previous file with comments | « rlz/lib/rlz_lib.h ('k') | rlz/lib/rlz_value_store.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // A library to manage RLZ information for access-points shared 5 // A library to manage RLZ information for access-points shared
6 // across different client applications. 6 // across different client applications.
7 7
8 #include "rlz/lib/rlz_lib.h" 8 #include "rlz/lib/rlz_lib.h"
9 9
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 return true; 77 return true;
78 } 78 }
79 79
80 return false; 80 return false;
81 } 81 }
82 82
83 // This function will remove bad rlz chars and also limit the max rlz to some 83 // This function will remove bad rlz chars and also limit the max rlz to some
84 // reasonable size. It also assumes that normalized_rlz is at least 84 // reasonable size. It also assumes that normalized_rlz is at least
85 // kMaxRlzLength+1 long. 85 // kMaxRlzLength+1 long.
86 void NormalizeRlz(const char* raw_rlz, char* normalized_rlz) { 86 void NormalizeRlz(const char* raw_rlz, char* normalized_rlz) {
87 int index = 0; 87 size_t index = 0;
88 for (; raw_rlz[index] != 0 && index < rlz_lib::kMaxRlzLength; ++index) { 88 for (; raw_rlz[index] != 0 && index < rlz_lib::kMaxRlzLength; ++index) {
89 char current = raw_rlz[index]; 89 char current = raw_rlz[index];
90 if (IsGoodRlzChar(current)) { 90 if (IsGoodRlzChar(current)) {
91 normalized_rlz[index] = current; 91 normalized_rlz[index] = current;
92 } else { 92 } else {
93 normalized_rlz[index] = '.'; 93 normalized_rlz[index] = '.';
94 } 94 }
95 } 95 }
96 96
97 normalized_rlz[index] = 0; 97 normalized_rlz[index] = 0;
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 response_line.substr(3, separator_index - rlz_cgi_length); 544 response_line.substr(3, separator_index - rlz_cgi_length);
545 AccessPoint point = NO_ACCESS_POINT; 545 AccessPoint point = NO_ACCESS_POINT;
546 if (!GetAccessPointFromName(point_name.c_str(), &point) || 546 if (!GetAccessPointFromName(point_name.c_str(), &point) ||
547 point == NO_ACCESS_POINT) 547 point == NO_ACCESS_POINT)
548 continue; // Not a valid access point. 548 continue; // Not a valid access point.
549 549
550 // Get the new RLZ. 550 // Get the new RLZ.
551 std::string rlz_value(response_line.substr(separator_index + 2)); 551 std::string rlz_value(response_line.substr(separator_index + 2));
552 TrimWhitespaceASCII(rlz_value, TRIM_LEADING, &rlz_value); 552 TrimWhitespaceASCII(rlz_value, TRIM_LEADING, &rlz_value);
553 553
554 int rlz_length = rlz_value.find_first_of("\r\n "); 554 size_t rlz_length = rlz_value.find_first_of("\r\n ");
555 if (rlz_length < 0) 555 if (rlz_length == std::string::npos)
556 rlz_length = rlz_value.size(); 556 rlz_length = rlz_value.size();
557 557
558 if (rlz_length > kMaxRlzLength) 558 if (rlz_length > kMaxRlzLength)
559 continue; // Too long. 559 continue; // Too long.
560 560
561 if (IsAccessPointSupported(point)) 561 if (IsAccessPointSupported(point))
562 SetAccessPointRlz(point, rlz_value.substr(0, rlz_length).c_str()); 562 SetAccessPointRlz(point, rlz_value.substr(0, rlz_length).c_str());
563 } else if (StartsWithASCII(response_line, events_variable, true)) { 563 } else if (StartsWithASCII(response_line, events_variable, true)) {
564 // Clear events which server parsed. 564 // Clear events which server parsed.
565 std::vector<ReturnedEvent> event_array; 565 std::vector<ReturnedEvent> event_array;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 if (cgi_string.size() >= cgi_size) 642 if (cgi_string.size() >= cgi_size)
643 return false; 643 return false;
644 644
645 strncpy(cgi, cgi_string.c_str(), cgi_size); 645 strncpy(cgi, cgi_string.c_str(), cgi_size);
646 cgi[cgi_size - 1] = 0; 646 cgi[cgi_size - 1] = 0;
647 647
648 return true; 648 return true;
649 } 649 }
650 650
651 } // namespace rlz_lib 651 } // namespace rlz_lib
OLDNEW
« no previous file with comments | « rlz/lib/rlz_lib.h ('k') | rlz/lib/rlz_value_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698