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

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

Issue 12087091: Move string tokenizer to base/strings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sort Created 7 years, 10 months 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/google_apis/fake_drive_service.h" 5 #include "chrome/browser/google_apis/fake_drive_service.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
11 #include "base/string_split.h" 11 #include "base/string_split.h"
12 #include "base/string_tokenizer.h"
13 #include "base/string_util.h" 12 #include "base/string_util.h"
14 #include "base/stringprintf.h" 13 #include "base/stringprintf.h"
14 #include "base/strings/string_tokenizer.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "chrome/browser/google_apis/drive_api_parser.h" 16 #include "chrome/browser/google_apis/drive_api_parser.h"
17 #include "chrome/browser/google_apis/gdata_wapi_parser.h" 17 #include "chrome/browser/google_apis/gdata_wapi_parser.h"
18 #include "chrome/browser/google_apis/test_util.h" 18 #include "chrome/browser/google_apis/test_util.h"
19 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
20 #include "net/base/escape.h" 20 #include "net/base/escape.h"
21 21
22 using content::BrowserThread; 22 using content::BrowserThread;
23 23
24 namespace google_apis { 24 namespace google_apis {
25 namespace { 25 namespace {
26 // Returns true if a resource entry matches with the search query. 26 // Returns true if a resource entry matches with the search query.
27 // Supports queries consist of following format. 27 // Supports queries consist of following format.
28 // - Phrases quoted by double/single quotes 28 // - Phrases quoted by double/single quotes
29 // - AND search for multiple words/phrases segmented by space 29 // - AND search for multiple words/phrases segmented by space
30 // - Limited attribute search. Only "title:" is supported. 30 // - Limited attribute search. Only "title:" is supported.
31 bool EntryMatchWithQuery(const ResourceEntry& entry, 31 bool EntryMatchWithQuery(const ResourceEntry& entry,
32 const std::string& query) { 32 const std::string& query) {
33 StringTokenizer tokenizer(query, " "); 33 base::StringTokenizer tokenizer(query, " ");
34 tokenizer.set_quote_chars("\"'"); 34 tokenizer.set_quote_chars("\"'");
35 while (tokenizer.GetNext()) { 35 while (tokenizer.GetNext()) {
36 std::string key, value; 36 std::string key, value;
37 const std::string& token = tokenizer.token(); 37 const std::string& token = tokenizer.token();
38 if (token.find(':') == std::string::npos) { 38 if (token.find(':') == std::string::npos) {
39 TrimString(token, "\"'", &value); 39 TrimString(token, "\"'", &value);
40 } else { 40 } else {
41 StringTokenizer key_value(token, ":"); 41 base::StringTokenizer key_value(token, ":");
42 key_value.set_quote_chars("\"'"); 42 key_value.set_quote_chars("\"'");
43 if (!key_value.GetNext()) 43 if (!key_value.GetNext())
44 return false; 44 return false;
45 key = key_value.token(); 45 key = key_value.token();
46 if (!key_value.GetNext()) 46 if (!key_value.GetNext())
47 return false; 47 return false;
48 TrimString(key_value.token(), "\"'", &value); 48 TrimString(key_value.token(), "\"'", &value);
49 } 49 }
50 50
51 // TODO(peria): Deal with other attributes than title. 51 // TODO(peria): Deal with other attributes than title.
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 return base::StringPrintf("resource_id_%d", resource_id_count_); 833 return base::StringPrintf("resource_id_%d", resource_id_count_);
834 } 834 }
835 835
836 void FakeDriveService::AddNewChangestamp(base::DictionaryValue* entry) { 836 void FakeDriveService::AddNewChangestamp(base::DictionaryValue* entry) {
837 ++largest_changestamp_; 837 ++largest_changestamp_;
838 entry->SetString("docs$changestamp.value", 838 entry->SetString("docs$changestamp.value",
839 base::Int64ToString(largest_changestamp_)); 839 base::Int64ToString(largest_changestamp_));
840 } 840 }
841 841
842 } // namespace google_apis 842 } // namespace google_apis
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_system.cc ('k') | chrome/browser/history/thumbnail_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698