OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "components/history/core/browser/delete_directive_handler.h" | 5 #include "components/history/core/browser/delete_directive_handler.h" |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 for (size_t i = 0; i < length; ++i) | 25 for (size_t i = 0; i < length; ++i) |
26 result.push_back(static_cast<char>(base::RandInt(kMin, kMax))); | 26 result.push_back(static_cast<char>(base::RandInt(kMin, kMax))); |
27 return result; | 27 return result; |
28 } | 28 } |
29 | 29 |
30 std::string DeleteDirectiveToString( | 30 std::string DeleteDirectiveToString( |
31 const sync_pb::HistoryDeleteDirectiveSpecifics& delete_directive) { | 31 const sync_pb::HistoryDeleteDirectiveSpecifics& delete_directive) { |
32 scoped_ptr<base::DictionaryValue> value( | 32 scoped_ptr<base::DictionaryValue> value( |
33 syncer::HistoryDeleteDirectiveSpecificsToValue(delete_directive)); | 33 syncer::HistoryDeleteDirectiveSpecificsToValue(delete_directive)); |
34 std::string str; | 34 std::string str; |
35 base::JSONWriter::Write(value.get(), &str); | 35 base::JSONWriter::Write(*value, &str); |
36 return str; | 36 return str; |
37 } | 37 } |
38 | 38 |
39 // Compare time range directives first by start time, then by end time. | 39 // Compare time range directives first by start time, then by end time. |
40 bool TimeRangeLessThan(const syncer::SyncData& data1, | 40 bool TimeRangeLessThan(const syncer::SyncData& data1, |
41 const syncer::SyncData& data2) { | 41 const syncer::SyncData& data2) { |
42 const sync_pb::TimeRangeDirective& range1 = | 42 const sync_pb::TimeRangeDirective& range1 = |
43 data1.GetSpecifics().history_delete_directive().time_range_directive(); | 43 data1.GetSpecifics().history_delete_directive().time_range_directive(); |
44 const sync_pb::TimeRangeDirective& range2 = | 44 const sync_pb::TimeRangeDirective& range2 = |
45 data2.GetSpecifics().history_delete_directive().time_range_directive(); | 45 data2.GetSpecifics().history_delete_directive().time_range_directive(); |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 syncer::SyncChangeList change_list; | 423 syncer::SyncChangeList change_list; |
424 for (size_t i = 0; i < delete_directives.size(); ++i) { | 424 for (size_t i = 0; i < delete_directives.size(); ++i) { |
425 change_list.push_back(syncer::SyncChange( | 425 change_list.push_back(syncer::SyncChange( |
426 FROM_HERE, syncer::SyncChange::ACTION_DELETE, delete_directives[i])); | 426 FROM_HERE, syncer::SyncChange::ACTION_DELETE, delete_directives[i])); |
427 } | 427 } |
428 sync_processor_->ProcessSyncChanges(FROM_HERE, change_list); | 428 sync_processor_->ProcessSyncChanges(FROM_HERE, change_list); |
429 } | 429 } |
430 } | 430 } |
431 | 431 |
432 } // namespace history | 432 } // namespace history |
OLD | NEW |