offline_store_utils.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright 2017 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef COMPONENTS_OFFLINE_PAGES_CORE_OFFLINE_STORE_UTILS_H_
  5. #define COMPONENTS_OFFLINE_PAGES_CORE_OFFLINE_STORE_UTILS_H_
  6. #include <stdint.h>
  7. #include <string>
  8. namespace base {
  9. class Time;
  10. class FilePath;
  11. } // namespace base
  12. namespace offline_pages {
  13. // The store_utils namespace within offline_pages namespace contains helper
  14. // methods that are common and shared among all Offline Pages projects.
  15. namespace store_utils {
  16. // Time format conversion methods between base::Time and an int64_t, which is
  17. // used by database storage indicating the elapsed time in microseconds since
  18. // the Windows epoch.
  19. int64_t ToDatabaseTime(base::Time time);
  20. base::Time FromDatabaseTime(int64_t serialized_time);
  21. // File path conversion methods between base::FilePath and UTF8 string formats
  22. // for storing paths in the database.
  23. std::string ToDatabaseFilePath(const base::FilePath& file_path);
  24. base::FilePath FromDatabaseFilePath(const std::string& file_path_string);
  25. // Generates a positive random int64_t, generally used for offline ids.
  26. int64_t GenerateOfflineId();
  27. } // namespace store_utils
  28. } // namespace offline_pages
  29. #endif // COMPONENTS_OFFLINE_PAGES_CORE_OFFLINE_STORE_UTILS_H_