| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_UTILITY_IMPORTER_IMPORTER_H_ | 5 #ifndef CHROME_UTILITY_IMPORTER_IMPORTER_H_ |
| 6 #define CHROME_UTILITY_IMPORTER_IMPORTER_H_ | 6 #define CHROME_UTILITY_IMPORTER_IMPORTER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include <stdint.h> |
| 9 |
| 10 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 10 | 12 |
| 11 class ImporterBridge; | 13 class ImporterBridge; |
| 12 | 14 |
| 13 namespace importer { | 15 namespace importer { |
| 14 struct SourceProfile; | 16 struct SourceProfile; |
| 15 } | 17 } |
| 16 | 18 |
| 17 // The base class of all importers. | 19 // The base class of all importers. |
| 18 class Importer : public base::RefCountedThreadSafe<Importer> { | 20 class Importer : public base::RefCountedThreadSafe<Importer> { |
| 19 public: | 21 public: |
| 20 // All importers should implement this method by adding their import logic. | 22 // All importers should implement this method by adding their import logic. |
| 21 // And it will be run in file thread by ImporterHost. Since we do async | 23 // And it will be run in file thread by ImporterHost. Since we do async |
| 22 // import, the importer should invoke ImporterHost::NotifyImportEnded() to | 24 // import, the importer should invoke ImporterHost::NotifyImportEnded() to |
| 23 // notify its host that import stuff have been finished. | 25 // notify its host that import stuff have been finished. |
| 24 virtual void StartImport(const importer::SourceProfile& source_profile, | 26 virtual void StartImport(const importer::SourceProfile& source_profile, |
| 25 uint16 items, | 27 uint16_t items, |
| 26 ImporterBridge* bridge) = 0; | 28 ImporterBridge* bridge) = 0; |
| 27 | 29 |
| 28 // Cancels the import process. | 30 // Cancels the import process. |
| 29 virtual void Cancel(); | 31 virtual void Cancel(); |
| 30 | 32 |
| 31 bool cancelled() const { return cancelled_; } | 33 bool cancelled() const { return cancelled_; } |
| 32 | 34 |
| 33 protected: | 35 protected: |
| 34 friend class base::RefCountedThreadSafe<Importer>; | 36 friend class base::RefCountedThreadSafe<Importer>; |
| 35 | 37 |
| 36 Importer(); | 38 Importer(); |
| 37 virtual ~Importer(); | 39 virtual ~Importer(); |
| 38 | 40 |
| 39 scoped_refptr<ImporterBridge> bridge_; | 41 scoped_refptr<ImporterBridge> bridge_; |
| 40 | 42 |
| 41 private: | 43 private: |
| 42 // True if the caller cancels the import process. | 44 // True if the caller cancels the import process. |
| 43 bool cancelled_; | 45 bool cancelled_; |
| 44 | 46 |
| 45 DISALLOW_COPY_AND_ASSIGN(Importer); | 47 DISALLOW_COPY_AND_ASSIGN(Importer); |
| 46 }; | 48 }; |
| 47 | 49 |
| 48 #endif // CHROME_UTILITY_IMPORTER_IMPORTER_H_ | 50 #endif // CHROME_UTILITY_IMPORTER_IMPORTER_H_ |
| OLD | NEW |