Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef COMPONENTS_DOWNLOAD_INTERNAL_MODEL_H_ | 5 #ifndef COMPONENTS_DOWNLOAD_INTERNAL_MODEL_H_ |
| 6 #define COMPONENTS_DOWNLOAD_INTERNAL_MODEL_H_ | 6 #define COMPONENTS_DOWNLOAD_INTERNAL_MODEL_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 // The Client which is responsible for handling all relevant messages from the | 23 // The Client which is responsible for handling all relevant messages from the |
| 24 // model. | 24 // model. |
| 25 class Client { | 25 class Client { |
| 26 public: | 26 public: |
| 27 virtual ~Client() = default; | 27 virtual ~Client() = default; |
| 28 | 28 |
| 29 // Called asynchronously in response to a Model::Initialize call. If | 29 // Called asynchronously in response to a Model::Initialize call. If |
| 30 // |success| is |false|, initialization of the Model and/or the underlying | 30 // |success| is |false|, initialization of the Model and/or the underlying |
| 31 // Store failed. Initialization of the Model is complete after this | 31 // Store failed. Initialization of the Model is complete after this |
| 32 // callback. If |success| is true it can be accessed now. | 32 // callback. If |success| is true it can be accessed now. |
| 33 virtual void OnInitialized(bool success) = 0; | 33 virtual void OnModelReady(bool success) = 0; |
| 34 | 34 |
| 35 // Called asynchronously in response to a Model::Destroy call. If |success| | 35 // Called asynchronously in response to a Model::Destroy call. If |success| |
| 36 // is |false|, destruction of the Model and/or the underlying Store failed. | 36 // is |false|, destruction of the Model and/or the underlying Store failed. |
| 37 // Destruction of the Model is effectively complete after this callback. | 37 // Destruction of the Model is effectively complete after this callback. |
| 38 virtual void OnDestroyed(bool success) = 0; | 38 virtual void OnModelDestroyed(bool success) = 0; |
|
xingliu
2017/05/27 00:25:32
fyi: Destroy call probably will be removed in rece
David Trainor- moved to gerrit
2017/05/30 18:55:23
Yeah. Will remove this. Will wait for that CL to
| |
| 39 | 39 |
| 40 // Called when an Entry addition is complete. |success| determines whether | 40 // Called when an Entry addition is complete. |success| determines whether |
| 41 // or not the entry has been successfully persisted to the Store. | 41 // or not the entry has been successfully persisted to the Store. |
| 42 virtual void OnItemAdded(bool success, | 42 virtual void OnItemAdded(bool success, |
| 43 DownloadClient client, | 43 DownloadClient client, |
| 44 const std::string& guid) = 0; | 44 const std::string& guid) = 0; |
| 45 | 45 |
| 46 // Called when an Entry update is complete. |success| determines whether or | 46 // Called when an Entry update is complete. |success| determines whether or |
| 47 // not the update has been successfully persisted to the Store. | 47 // not the update has been successfully persisted to the Store. |
| 48 virtual void OnItemUpdated(bool success, | 48 virtual void OnItemUpdated(bool success, |
| 49 DownloadClient client, | 49 DownloadClient client, |
| 50 const std::string& guid) = 0; | 50 const std::string& guid) = 0; |
| 51 | 51 |
| 52 // Called when an Entry removal is complete. |success| determines whether | 52 // Called when an Entry removal is complete. |success| determines whether |
| 53 // or not the entry has been successfully removed from the Store. | 53 // or not the entry has been successfully removed from the Store. |
| 54 virtual void OnItemRemoved(bool success, | 54 virtual void OnItemRemoved(bool success, |
| 55 DownloadClient client, | 55 DownloadClient client, |
| 56 const std::string& guid) = 0; | 56 const std::string& guid) = 0; |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 using EntryList = std::vector<Entry*>; | 59 using EntryList = std::vector<Entry*>; |
| 60 | 60 |
| 61 virtual ~Model() = default; | 61 virtual ~Model() = default; |
| 62 | 62 |
| 63 // Initializes the Model. Client::OnInitialized() will be called in response. | 63 // Initializes the Model. Client::OnInitialized() will be called in response. |
| 64 // The Model can be used after that call. | 64 // The Model can be used after that call. |
| 65 virtual void Initialize() = 0; | 65 virtual void Initialize(Client* client) = 0; |
| 66 | 66 |
| 67 // Destroys the Model. Client::OnDestroyed() will be called in response. | 67 // Destroys the Model. Client::OnDestroyed() will be called in response. |
| 68 virtual void Destroy() = 0; | 68 virtual void Destroy() = 0; |
| 69 | 69 |
| 70 // Adds |entry| to this Model and attempts to write |entry| to the Store. | 70 // Adds |entry| to this Model and attempts to write |entry| to the Store. |
| 71 // Client::OnItemAdded() will be called in response asynchronously. | 71 // Client::OnItemAdded() will be called in response asynchronously. |
| 72 virtual void Add(const Entry& entry) = 0; | 72 virtual void Add(const Entry& entry) = 0; |
| 73 | 73 |
| 74 // Updates |entry| in this Model and attempts to write |entry| to the Store. | 74 // Updates |entry| in this Model and attempts to write |entry| to the Store. |
| 75 // Client::OnItemUpdated() will be called in response asynchronously. | 75 // Client::OnItemUpdated() will be called in response asynchronously. |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 89 // Returns a temporary list of Entry objects that this Model stores. | 89 // Returns a temporary list of Entry objects that this Model stores. |
| 90 // IMPORTANT NOTE: Like Get(), the result of this method should be used | 90 // IMPORTANT NOTE: Like Get(), the result of this method should be used |
| 91 // immediately and NOT stored. The underlying data may get updated or removed | 91 // immediately and NOT stored. The underlying data may get updated or removed |
| 92 // by any other modifications to this model. | 92 // by any other modifications to this model. |
| 93 virtual EntryList PeekEntries() = 0; | 93 virtual EntryList PeekEntries() = 0; |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 } // namespace download | 96 } // namespace download |
| 97 | 97 |
| 98 #endif // COMPONENTS_DOWNLOAD_INTERNAL_MODEL_H_ | 98 #endif // COMPONENTS_DOWNLOAD_INTERNAL_MODEL_H_ |
| OLD | NEW |