Chromium Code Reviews| Index: chrome/browser/chromeos/arc/fileapi/arc_documents_provider_root_map.h |
| diff --git a/chrome/browser/chromeos/arc/fileapi/arc_documents_provider_root_map.h b/chrome/browser/chromeos/arc/fileapi/arc_documents_provider_root_map.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..02fbbe8ebeaa371bcc14c640920811824f9ec5d6 |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/arc/fileapi/arc_documents_provider_root_map.h |
| @@ -0,0 +1,54 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_DOCUMENTS_PROVIDER_ROOT_MAP_H_ |
| +#define CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_DOCUMENTS_PROVIDER_ROOT_MAP_H_ |
| + |
| +#include <map> |
| +#include <memory> |
| +#include <string> |
| +#include <utility> |
| + |
| +#include "base/files/file_path.h" |
| +#include "base/macros.h" |
| + |
| +namespace storage { |
| +class FileSystemURL; |
| +} // namespace storage |
| + |
| +namespace arc { |
| + |
| +class ArcDocumentsProviderRoot; |
| + |
| +// Container of ArcDocumentsProviderRoot instances. |
| +// |
| +// This class is thread-safe, but ArcDocumentsProviderRoot must be accessed |
| +// only on the IO thread anyway. |
| +class ArcDocumentsProviderRootMap { |
| + public: |
| + ArcDocumentsProviderRootMap(); |
| + ~ArcDocumentsProviderRootMap(); |
| + |
| + // Looks up a root corresponding to |authority| and |root_document_id|. |
| + // Returns nullptr if no such root is registered. |
| + ArcDocumentsProviderRoot* Lookup(const std::string& authority, |
| + const std::string& root_document_id); |
|
hashimoto
2016/12/15 03:53:22
const?
Shuhei Takahashi
2016/12/15 05:21:53
Done.
|
| + |
| + // Looks up a root corresponding to |url|. |
| + // |path| is set to the remaining path part of |url|. |
| + // Returns nullptr if |url| is invalid or no corresponding root is registered. |
| + ArcDocumentsProviderRoot* ParseAndLookup(const storage::FileSystemURL& url, |
| + base::FilePath* path); |
|
hashimoto
2016/12/15 03:53:22
const?
Shuhei Takahashi
2016/12/15 05:21:53
Done.
|
| + |
| + private: |
| + // Key is (authority, root_document_id). |
| + using Key = std::pair<std::string, std::string>; |
| + std::map<Key, std::unique_ptr<ArcDocumentsProviderRoot>> map_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ArcDocumentsProviderRootMap); |
| +}; |
| + |
| +} // namespace arc |
| + |
| +#endif // CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_DOCUMENTS_PROVIDER_ROOT_MAP_H_ |