OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BROWSER_EXTENSIONS_PACK_EXTENSION_JOB_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_PACK_EXTENSION_JOB_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_PACK_EXTENSION_JOB_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_PACK_EXTENSION_JOB_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/string16.h" | 12 #include "base/string16.h" |
13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
14 #include "chrome/browser/extensions/extension_creator.h" | 14 #include "chrome/browser/extensions/extension_creator.h" |
15 | 15 |
| 16 namespace extensions { |
16 | 17 |
17 // Manages packing an extension on the file thread and reporting the result | 18 // Manages packing an extension on the file thread and reporting the result |
18 // back to the UI. | 19 // back to the UI. |
19 class PackExtensionJob : public base::RefCountedThreadSafe<PackExtensionJob> { | 20 class PackExtensionJob : public base::RefCountedThreadSafe<PackExtensionJob> { |
20 public: | 21 public: |
21 // Interface for people who want to use PackExtensionJob to implement. | 22 // Interface for people who want to use PackExtensionJob to implement. |
22 class Client { | 23 class Client { |
23 public: | 24 public: |
24 virtual void OnPackSuccess(const FilePath& crx_file, | 25 virtual void OnPackSuccess(const FilePath& crx_file, |
25 const FilePath& key_file) = 0; | 26 const FilePath& key_file) = 0; |
26 virtual void OnPackFailure( | 27 virtual void OnPackFailure(const std::string& message, |
27 const std::string& message, | 28 ExtensionCreator::ErrorType error_type) = 0; |
28 extensions::ExtensionCreator::ErrorType error_type) = 0; | |
29 | 29 |
30 protected: | 30 protected: |
31 virtual ~Client() {} | 31 virtual ~Client() {} |
32 }; | 32 }; |
33 | 33 |
34 PackExtensionJob(Client* client, | 34 PackExtensionJob(Client* client, |
35 const FilePath& root_directory, | 35 const FilePath& root_directory, |
36 const FilePath& key_file, | 36 const FilePath& key_file, |
37 int run_flags); | 37 int run_flags); |
38 | 38 |
(...skipping 11 matching lines...) Expand all Loading... |
50 void set_asynchronous(bool async) { asynchronous_ = async; } | 50 void set_asynchronous(bool async) { asynchronous_ = async; } |
51 | 51 |
52 private: | 52 private: |
53 friend class base::RefCountedThreadSafe<PackExtensionJob>; | 53 friend class base::RefCountedThreadSafe<PackExtensionJob>; |
54 | 54 |
55 virtual ~PackExtensionJob(); | 55 virtual ~PackExtensionJob(); |
56 | 56 |
57 // If |asynchronous_| is false, this is run on whichever thread calls it. | 57 // If |asynchronous_| is false, this is run on whichever thread calls it. |
58 void Run(); | 58 void Run(); |
59 void ReportSuccessOnClientThread(); | 59 void ReportSuccessOnClientThread(); |
60 void ReportFailureOnClientThread( | 60 void ReportFailureOnClientThread(const std::string& error, |
61 const std::string& error, | 61 ExtensionCreator::ErrorType error_type); |
62 extensions::ExtensionCreator::ErrorType error_type); | |
63 | 62 |
64 content::BrowserThread::ID client_thread_id_; | 63 content::BrowserThread::ID client_thread_id_; |
65 Client* client_; | 64 Client* client_; |
66 FilePath root_directory_; | 65 FilePath root_directory_; |
67 FilePath key_file_; | 66 FilePath key_file_; |
68 FilePath crx_file_out_; | 67 FilePath crx_file_out_; |
69 FilePath key_file_out_; | 68 FilePath key_file_out_; |
70 bool asynchronous_; | 69 bool asynchronous_; |
71 int run_flags_; // Bitset of ExtensionCreator::RunFlags values | 70 int run_flags_; // Bitset of ExtensionCreator::RunFlags values |
72 | 71 |
73 DISALLOW_COPY_AND_ASSIGN(PackExtensionJob); | 72 DISALLOW_COPY_AND_ASSIGN(PackExtensionJob); |
74 }; | 73 }; |
75 | 74 |
| 75 } // namespace extensions |
| 76 |
76 #endif // CHROME_BROWSER_EXTENSIONS_PACK_EXTENSION_JOB_H_ | 77 #endif // CHROME_BROWSER_EXTENSIONS_PACK_EXTENSION_JOB_H_ |
OLD | NEW |