| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 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 |
| 5 #ifndef MOJO_SERVICES_FLOG_FLOG_DIRECTORY_H_ |
| 6 #define MOJO_SERVICES_FLOG_FLOG_DIRECTORY_H_ |
| 7 |
| 8 #include <map> |
| 9 |
| 10 #include "mojo/public/cpp/application/connect.h" |
| 11 #include "mojo/services/files/interfaces/directory.mojom.h" |
| 12 #include "mojo/services/files/interfaces/file.mojom.h" |
| 13 #include "mojo/services/files/interfaces/files.mojom.h" |
| 14 |
| 15 namespace mojo { |
| 16 namespace flog { |
| 17 |
| 18 // Flog directory management. |
| 19 class FlogDirectory { |
| 20 public: |
| 21 using GetExistingFilesCallback = |
| 22 std::function<void(std::unique_ptr<std::map<uint32_t, std::string>>)>; |
| 23 |
| 24 FlogDirectory(Shell* shell); |
| 25 |
| 26 ~FlogDirectory(); |
| 27 |
| 28 // Calls back with a map (id -> label) of existing files. |
| 29 void GetExistingFiles(GetExistingFilesCallback callback); |
| 30 |
| 31 // Gets a FilePtr for the indicated file. |
| 32 files::FilePtr GetFile(uint32_t id, const std::string& label, bool create); |
| 33 |
| 34 private: |
| 35 static const size_t kLogIdWidth = 8; |
| 36 |
| 37 // Returns a log file name given the id and label of the log. |
| 38 std::string LogFileName(uint32_t id, const std::string& label); |
| 39 |
| 40 // Parses a log file name. |
| 41 bool ParseLogFileName(const std::string& name, |
| 42 uint32_t* id_out, |
| 43 std::string* label_out); |
| 44 |
| 45 files::FilesPtr files_; |
| 46 files::DirectoryPtr file_system_; |
| 47 }; |
| 48 |
| 49 } // namespace flog |
| 50 } // namespace mojo |
| 51 |
| 52 #endif // MOJO_SERVICES_FLOG_FLOG_DIRECTORY_H_ |
| OLD | NEW |