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