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

Side by Side Diff: chrome/browser/sync/syncable/syncable.cc

Issue 211019: Fix compiling of sync on linux. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/sync/syncable/syncable.h" 5 #include "chrome/browser/sync/syncable/syncable.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 #ifdef OS_LINUX
11 #include <sys/time.h>
12 #endif
10 #include <sys/types.h> 13 #include <sys/types.h>
11 #include <time.h> 14 #include <time.h>
12 #ifdef OS_MACOSX 15 #ifdef OS_MACOSX
13 #include <CoreFoundation/CoreFoundation.h> 16 #include <CoreFoundation/CoreFoundation.h>
14 #elif defined(OS_LINUX)
15 #include <glib.h>
16 #elif defined(OS_WIN) 17 #elif defined(OS_WIN)
17 #include <shlwapi.h> // for PathMatchSpec 18 #include <shlwapi.h> // for PathMatchSpec
18 #endif 19 #endif
19 20
20 #include <algorithm> 21 #include <algorithm>
21 #include <functional> 22 #include <functional>
22 #include <iomanip> 23 #include <iomanip>
23 #include <iterator> 24 #include <iterator>
24 #include <set> 25 #include <set>
25 #include <string> 26 #include <string>
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 const void* b) { 96 const void* b) {
96 #ifdef OS_WIN 97 #ifdef OS_WIN
97 DCHECK_EQ(0, a_bytes % 2); 98 DCHECK_EQ(0, a_bytes % 2);
98 DCHECK_EQ(0, b_bytes % 2); 99 DCHECK_EQ(0, b_bytes % 2);
99 int result = CompareString(LOCALE_INVARIANT, NORM_IGNORECASE, 100 int result = CompareString(LOCALE_INVARIANT, NORM_IGNORECASE,
100 static_cast<const PathChar*>(a), a_bytes / 2, 101 static_cast<const PathChar*>(a), a_bytes / 2,
101 static_cast<const PathChar*>(b), b_bytes / 2); 102 static_cast<const PathChar*>(b), b_bytes / 2);
102 CHECK(0 != result) << "Error comparing strings: " << GetLastError(); 103 CHECK(0 != result) << "Error comparing strings: " << GetLastError();
103 return result - 2; // Convert to -1, 0, 1 104 return result - 2; // Convert to -1, 0, 1
104 #elif defined(OS_LINUX) 105 #elif defined(OS_LINUX)
105 // misnomer for Linux. These are already utf8 bit strings. 106 int result = base::strncasecmp(reinterpret_cast<const char *>(a),
106 gchar *case_folded_a; 107 reinterpret_cast<const char *>(b),
107 gchar *case_folded_b; 108 std::min(a_bytes, b_bytes));
108 GError *err = NULL; 109 if (result != 0) {
109 case_folded_a = g_utf8_casefold(reinterpret_cast<const gchar*>(a), a_bytes); 110 return result;
110 CHECK(case_folded_a != NULL) << "g_utf8_casefold failed"; 111 } else {
111 case_folded_b = g_utf8_casefold(reinterpret_cast<const gchar*>(b), b_bytes); 112 return a_bytes > b_bytes ? 1 : b_bytes > a_bytes ? -1 : 0;
112 CHECK(case_folded_b != NULL) << "g_utf8_casefold failed"; 113 }
113 gint result = g_utf8_collate(case_folded_a, case_folded_b);
114 g_free(case_folded_a);
115 g_free(case_folded_b);
116 if (result < 0) return -1;
117 if (result > 0) return 1;
118 return 0;
119 #elif defined(OS_MACOSX) 114 #elif defined(OS_MACOSX)
120 CFStringRef a_str; 115 CFStringRef a_str;
121 CFStringRef b_str; 116 CFStringRef b_str;
122 a_str = CFStringCreateWithBytes(NULL, reinterpret_cast<const UInt8*>(a), 117 a_str = CFStringCreateWithBytes(NULL, reinterpret_cast<const UInt8*>(a),
123 a_bytes, kCFStringEncodingUTF8, FALSE); 118 a_bytes, kCFStringEncodingUTF8, FALSE);
124 b_str = CFStringCreateWithBytes(NULL, reinterpret_cast<const UInt8*>(b), 119 b_str = CFStringCreateWithBytes(NULL, reinterpret_cast<const UInt8*>(b),
125 b_bytes, kCFStringEncodingUTF8, FALSE); 120 b_bytes, kCFStringEncodingUTF8, FALSE);
126 CFComparisonResult res; 121 CFComparisonResult res;
127 res = CFStringCompare(a_str, b_str, kCFCompareCaseInsensitive); 122 res = CFStringCompare(a_str, b_str, kCFCompareCaseInsensitive);
128 CFRelease(a_str); 123 CFRelease(a_str);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 ids_index(new Directory::IdsIndex), 198 ids_index(new Directory::IdsIndex),
204 parent_id_and_names_index(new Directory::ParentIdAndNamesIndex), 199 parent_id_and_names_index(new Directory::ParentIdAndNamesIndex),
205 extended_attributes(new ExtendedAttributes), 200 extended_attributes(new ExtendedAttributes),
206 unapplied_update_metahandles(new MetahandleSet), 201 unapplied_update_metahandles(new MetahandleSet),
207 unsynced_metahandles(new MetahandleSet), 202 unsynced_metahandles(new MetahandleSet),
208 channel(new Directory::Channel(syncable::DIRECTORY_DESTROYED)), 203 channel(new Directory::Channel(syncable::DIRECTORY_DESTROYED)),
209 changes_channel(new Directory::ChangesChannel(kShutdownChangesEvent)), 204 changes_channel(new Directory::ChangesChannel(kShutdownChangesEvent)),
210 last_sync_timestamp_(info.kernel_info.last_sync_timestamp), 205 last_sync_timestamp_(info.kernel_info.last_sync_timestamp),
211 initial_sync_ended_(info.kernel_info.initial_sync_ended), 206 initial_sync_ended_(info.kernel_info.initial_sync_ended),
212 store_birthday_(info.kernel_info.store_birthday), 207 store_birthday_(info.kernel_info.store_birthday),
213 next_id(info.kernel_info.next_id),
214 cache_guid_(info.cache_guid), 208 cache_guid_(info.cache_guid),
215 next_metahandle(info.max_metahandle + 1) { 209 next_metahandle(info.max_metahandle + 1),
210 next_id(info.kernel_info.next_id) {
216 info_status_ = Directory::KERNEL_SHARE_INFO_VALID; 211 info_status_ = Directory::KERNEL_SHARE_INFO_VALID;
217 CHECK(0 == pthread_mutex_init(&mutex, NULL)); 212 CHECK(0 == pthread_mutex_init(&mutex, NULL));
218 CHECK(0 == pthread_key_create(&thread_node_key, &DestroyThreadNodeKey)); 213 CHECK(0 == pthread_key_create(&thread_node_key, &DestroyThreadNodeKey));
219 } 214 }
220 215
221 inline void DeleteEntry(EntryKernel* kernel) { 216 inline void DeleteEntry(EntryKernel* kernel) {
222 delete kernel; 217 delete kernel;
223 } 218 }
224 219
225 void Directory::Kernel::AddRef() { 220 void Directory::Kernel::AddRef() {
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 MetahandlesIndex::iterator found = 799 MetahandlesIndex::iterator found =
805 kernel_->metahandles_index->find(&kernel_->needle); 800 kernel_->metahandles_index->find(&kernel_->needle);
806 EntryKernel* entry = (found == kernel_->metahandles_index->end() ? 801 EntryKernel* entry = (found == kernel_->metahandles_index->end() ?
807 NULL : *found); 802 NULL : *found);
808 if (entry && SafeToPurgeFromMemory(entry)) { 803 if (entry && SafeToPurgeFromMemory(entry)) {
809 // We now drop deleted metahandles that are up to date on both the client 804 // We now drop deleted metahandles that are up to date on both the client
810 // and the server. 805 // and the server.
811 size_t num_erased = 0; 806 size_t num_erased = 0;
812 kernel_->flushed_metahandles_.Push(entry->ref(META_HANDLE)); 807 kernel_->flushed_metahandles_.Push(entry->ref(META_HANDLE));
813 num_erased = kernel_->ids_index->erase(entry); 808 num_erased = kernel_->ids_index->erase(entry);
814 DCHECK_EQ(1, num_erased); 809 DCHECK(1 == num_erased);
815 num_erased = kernel_->metahandles_index->erase(entry); 810 num_erased = kernel_->metahandles_index->erase(entry);
816 DCHECK_EQ(1, num_erased); 811 DCHECK(1 == num_erased);
817 delete entry; 812 delete entry;
818 } 813 }
819 } 814 }
820 815
821 ExtendedAttributes::const_iterator i = snapshot.dirty_xattrs.begin(); 816 ExtendedAttributes::const_iterator i = snapshot.dirty_xattrs.begin();
822 while (i != snapshot.dirty_xattrs.end()) { 817 while (i != snapshot.dirty_xattrs.end()) {
823 ExtendedAttributeKey key(i->first.metahandle, i->first.key); 818 ExtendedAttributeKey key(i->first.metahandle, i->first.key);
824 ExtendedAttributes::iterator found = 819 ExtendedAttributes::iterator found =
825 kernel_->extended_attributes->find(key); 820 kernel_->extended_attributes->find(key);
826 if (found == kernel_->extended_attributes->end() || 821 if (found == kernel_->extended_attributes->end() ||
(...skipping 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1995 return dump; 1990 return dump;
1996 } 1991 }
1997 1992
1998 std::ostream& operator<<(std::ostream& s, const syncable::ThreadNode& node) { 1993 std::ostream& operator<<(std::ostream& s, const syncable::ThreadNode& node) {
1999 s << "thread id: " << std::hex << node.id << "\n" 1994 s << "thread id: " << std::hex << node.id << "\n"
2000 << "file: " << node.file << "\n" 1995 << "file: " << node.file << "\n"
2001 << "line: " << std::dec << node.line << "\n" 1996 << "line: " << std::dec << node.line << "\n"
2002 << "wait_started: " << node.wait_started.ToInternalValue(); 1997 << "wait_started: " << node.wait_started.ToInternalValue();
2003 return s; 1998 return s;
2004 } 1999 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/syncable/directory_manager.cc ('k') | chrome/browser/sync/syncable/syncable_columns.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698