Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/offline_pages/offline_page_metadata_store_impl.h" | 5 #include "components/offline_pages/offline_page_metadata_store_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 #endif | 52 #endif |
| 53 item_proto->set_file_path(path_string); | 53 item_proto->set_file_path(path_string); |
| 54 item_proto->set_file_size(item.file_size); | 54 item_proto->set_file_size(item.file_size); |
| 55 item_proto->set_creation_time(item.creation_time.ToInternalValue()); | 55 item_proto->set_creation_time(item.creation_time.ToInternalValue()); |
| 56 item_proto->set_last_access_time(item.last_access_time.ToInternalValue()); | 56 item_proto->set_last_access_time(item.last_access_time.ToInternalValue()); |
| 57 item_proto->set_access_count(item.access_count); | 57 item_proto->set_access_count(item.access_count); |
| 58 item_proto->set_flags( | 58 item_proto->set_flags( |
| 59 static_cast<::offline_pages::OfflinePageEntry_Flags>(item.flags)); | 59 static_cast<::offline_pages::OfflinePageEntry_Flags>(item.flags)); |
| 60 item_proto->set_client_id_name_space(item.client_id.name_space); | 60 item_proto->set_client_id_name_space(item.client_id.name_space); |
| 61 item_proto->set_client_id(item.client_id.id); | 61 item_proto->set_client_id(item.client_id.id); |
| 62 item_proto->set_expiration_time(item.expiration_time.ToInternalValue()); | |
| 62 } | 63 } |
| 63 | 64 |
| 64 bool OfflinePageItemFromEntry(const offline_pages::OfflinePageEntry& item_proto, | 65 bool OfflinePageItemFromEntry(const offline_pages::OfflinePageEntry& item_proto, |
| 65 OfflinePageItem* item) { | 66 OfflinePageItem* item) { |
| 66 DCHECK(item); | 67 DCHECK(item); |
| 67 bool has_offline_id = | 68 bool has_offline_id = |
| 68 item_proto.has_offline_id() || item_proto.has_deprecated_bookmark_id(); | 69 item_proto.has_offline_id() || item_proto.has_deprecated_bookmark_id(); |
| 69 if (!item_proto.has_url() || !has_offline_id || !item_proto.has_version() || | 70 if (!item_proto.has_url() || !has_offline_id || !item_proto.has_version() || |
| 70 !item_proto.has_file_path()) { | 71 !item_proto.has_file_path()) { |
| 71 return false; | 72 return false; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 90 base::Time::FromInternalValue(item_proto.last_access_time()); | 91 base::Time::FromInternalValue(item_proto.last_access_time()); |
| 91 } | 92 } |
| 92 if (item_proto.has_access_count()) { | 93 if (item_proto.has_access_count()) { |
| 93 item->access_count = item_proto.access_count(); | 94 item->access_count = item_proto.access_count(); |
| 94 } | 95 } |
| 95 if (item_proto.has_flags()) { | 96 if (item_proto.has_flags()) { |
| 96 item->flags = static_cast<OfflinePageItem::Flags>(item_proto.flags()); | 97 item->flags = static_cast<OfflinePageItem::Flags>(item_proto.flags()); |
| 97 } | 98 } |
| 98 item->client_id.name_space = item_proto.client_id_name_space(); | 99 item->client_id.name_space = item_proto.client_id_name_space(); |
| 99 item->client_id.id = item_proto.client_id(); | 100 item->client_id.id = item_proto.client_id(); |
| 101 if (item_proto.has_expiration_time()) { | |
|
bburns
2016/05/20 18:23:27
remove curly braces for one line ifs ?
fgorski
2016/05/20 20:54:53
notice the if content does not fit in a single lin
| |
| 102 item->expiration_time = | |
| 103 base::Time::FromInternalValue(item_proto.expiration_time()); | |
| 104 } | |
| 100 | 105 |
| 101 return true; | 106 return true; |
| 102 } | 107 } |
| 103 | 108 |
| 104 } // namespace | 109 } // namespace |
| 105 | 110 |
| 106 OfflinePageMetadataStoreImpl::OfflinePageMetadataStoreImpl( | 111 OfflinePageMetadataStoreImpl::OfflinePageMetadataStoreImpl( |
| 107 scoped_refptr<base::SequencedTaskRunner> background_task_runner, | 112 scoped_refptr<base::SequencedTaskRunner> background_task_runner, |
| 108 const base::FilePath& database_dir) | 113 const base::FilePath& database_dir) |
| 109 : background_task_runner_(background_task_runner), | 114 : background_task_runner_(background_task_runner), |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 310 bool success) { | 315 bool success) { |
| 311 // If the update failed, log and keep going. We'll try to | 316 // If the update failed, log and keep going. We'll try to |
| 312 // update next time. | 317 // update next time. |
| 313 if (!success) { | 318 if (!success) { |
| 314 LOG(ERROR) << "Failed to update database"; | 319 LOG(ERROR) << "Failed to update database"; |
| 315 } | 320 } |
| 316 NotifyLoadResult(cb, status, result); | 321 NotifyLoadResult(cb, status, result); |
| 317 } | 322 } |
| 318 | 323 |
| 319 } // namespace offline_pages | 324 } // namespace offline_pages |
| OLD | NEW |