OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_UI_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_PACK_EXTENSION_JOB_UI_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_PACK_EXTENSION_JOB_UI_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_PACK_EXTENSION_JOB_UI_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/ref_counted.h" | 11 #include "base/ref_counted.h" |
12 | 12 |
13 class MessageLoop; | 13 class MessageLoop; |
14 | 14 |
15 // Manages packing an extension on the file thread and reporting the result | 15 // Manages packing an extension on the file thread and reporting the result |
16 // back to the UI. | 16 // back to the UI. |
17 class PackExtensionJob : public base::RefCountedThreadSafe<PackExtensionJob> { | 17 class PackExtensionJob : public base::RefCountedThreadSafe<PackExtensionJob> { |
18 public: | 18 public: |
19 | 19 |
20 // Interface for people who want to use PackExtensionJob to implement. | 20 // Interface for people who want to use PackExtensionJob to implement. |
21 class Client { | 21 class Client { |
22 public: | 22 public: |
23 virtual void OnPackSuccess(const FilePath& crx_file, | 23 virtual void OnPackSuccess(const FilePath& crx_file, |
24 const FilePath& key_file) = 0; | 24 const FilePath& key_file) = 0; |
25 virtual void OnPackFailure(const std::wstring& message) = 0; | 25 virtual void OnPackFailure(const std::wstring& message) = 0; |
26 }; | 26 }; |
27 | 27 |
28 PackExtensionJob(Client* client, | 28 PackExtensionJob(Client* client, |
29 const FilePath& root_directory, | 29 const FilePath& root_directory, |
30 const FilePath& key_file, | 30 const FilePath& key_file); |
31 MessageLoop* file_loop); | |
32 | 31 |
33 // The client should call this when it is destroyed to prevent | 32 // The client should call this when it is destroyed to prevent |
34 // PackExtensionJob from attempting to access it. | 33 // PackExtensionJob from attempting to access it. |
35 void ClearClient(); | 34 void ClearClient(); |
36 | 35 |
37 private: | 36 private: |
38 void RunOnFileThread(); | 37 void RunOnFileThread(); |
39 void ReportSuccessOnUIThread(); | 38 void ReportSuccessOnUIThread(); |
40 void ReportFailureOnUIThread(const std::string& error); | 39 void ReportFailureOnUIThread(const std::string& error); |
41 | 40 |
42 MessageLoop* ui_loop_; | 41 MessageLoop* ui_loop_; |
43 MessageLoop* file_loop_; | |
44 Client* client_; | 42 Client* client_; |
45 FilePath root_directory_; | 43 FilePath root_directory_; |
46 FilePath key_file_; | 44 FilePath key_file_; |
47 FilePath crx_file_out_; | 45 FilePath crx_file_out_; |
48 FilePath key_file_out_; | 46 FilePath key_file_out_; |
49 | 47 |
50 DISALLOW_COPY_AND_ASSIGN(PackExtensionJob); | 48 DISALLOW_COPY_AND_ASSIGN(PackExtensionJob); |
51 }; | 49 }; |
52 | 50 |
53 #endif // CHROME_BROWSER_EXTENSIONS_PACK_EXTENSION_JOB_UI_H_ | 51 #endif // CHROME_BROWSER_EXTENSIONS_PACK_EXTENSION_JOB_UI_H_ |
54 | 52 |
OLD | NEW |