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

Side by Side Diff: chrome/browser/drive/fake_drive_service.cc

Issue 102843002: Move RemoveChars, ReplaceChars, TrimString, and TruncateUTF8ToByteSize to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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) 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 #include "chrome/browser/drive/fake_drive_service.h" 5 #include "chrome/browser/drive/fake_drive_service.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 // - AND search for multiple words/phrases segmented by space 76 // - AND search for multiple words/phrases segmented by space
77 // - Limited attribute search. Only "title:" is supported. 77 // - Limited attribute search. Only "title:" is supported.
78 bool EntryMatchWithQuery(const ResourceEntry& entry, 78 bool EntryMatchWithQuery(const ResourceEntry& entry,
79 const std::string& query) { 79 const std::string& query) {
80 base::StringTokenizer tokenizer(query, " "); 80 base::StringTokenizer tokenizer(query, " ");
81 tokenizer.set_quote_chars("\"'"); 81 tokenizer.set_quote_chars("\"'");
82 while (tokenizer.GetNext()) { 82 while (tokenizer.GetNext()) {
83 std::string key, value; 83 std::string key, value;
84 const std::string& token = tokenizer.token(); 84 const std::string& token = tokenizer.token();
85 if (token.find(':') == std::string::npos) { 85 if (token.find(':') == std::string::npos) {
86 TrimString(token, "\"'", &value); 86 base::TrimString(token, "\"'", &value);
87 } else { 87 } else {
88 base::StringTokenizer key_value(token, ":"); 88 base::StringTokenizer key_value(token, ":");
89 key_value.set_quote_chars("\"'"); 89 key_value.set_quote_chars("\"'");
90 if (!key_value.GetNext()) 90 if (!key_value.GetNext())
91 return false; 91 return false;
92 key = key_value.token(); 92 key = key_value.token();
93 if (!key_value.GetNext()) 93 if (!key_value.GetNext())
94 return false; 94 return false;
95 TrimString(key_value.token(), "\"'", &value); 95 base::TrimString(key_value.token(), "\"'", &value);
96 } 96 }
97 97
98 // TODO(peria): Deal with other attributes than title. 98 // TODO(peria): Deal with other attributes than title.
99 if (!key.empty() && key != "title") 99 if (!key.empty() && key != "title")
100 return false; 100 return false;
101 // Search query in the title. 101 // Search query in the title.
102 if (entry.title().find(value) == std::string::npos) 102 if (entry.title().find(value) == std::string::npos)
103 return false; 103 return false;
104 } 104 }
105 return true; 105 return true;
(...skipping 1528 matching lines...) Expand 10 before | Expand all | Expand 10 after
1634 FROM_HERE, 1634 FROM_HERE,
1635 base::Bind(callback, HTTP_SUCCESS, base::Passed(&resource_list))); 1635 base::Bind(callback, HTTP_SUCCESS, base::Passed(&resource_list)));
1636 } 1636 }
1637 1637
1638 GURL FakeDriveService::GetNewUploadSessionUrl() { 1638 GURL FakeDriveService::GetNewUploadSessionUrl() {
1639 return GURL("https://upload_session_url/" + 1639 return GURL("https://upload_session_url/" +
1640 base::Int64ToString(next_upload_sequence_number_++)); 1640 base::Int64ToString(next_upload_sequence_number_++));
1641 } 1641 }
1642 1642
1643 } // namespace drive 1643 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698