Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(965)

Side by Side Diff: chrome/browser/extensions/pack_extension_job.h

Issue 3077022: Extension package creation cleanup (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Now with proper threading Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_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/ref_counted.h" 12 #include "base/ref_counted.h"
13 #include "chrome/browser/chrome_thread.h" 13 #include "chrome/browser/chrome_thread.h"
14 14
15 15
16 // Manages packing an extension on the file thread and reporting the result 16 // Manages packing an extension on the file thread and reporting the result
17 // back to the UI. 17 // back to the UI.
18 class PackExtensionJob : public base::RefCountedThreadSafe<PackExtensionJob> { 18 class PackExtensionJob : public base::RefCountedThreadSafe<PackExtensionJob> {
19 public: 19 public:
20 20
21 // Interface for people who want to use PackExtensionJob to implement. 21 // Interface for people who want to use PackExtensionJob to implement.
22 class Client { 22 class Client {
23 public: 23 public:
24 virtual void OnPackSuccess(const FilePath& crx_file, 24 virtual void OnPackSuccess(const FilePath& crx_file,
25 const FilePath& key_file) = 0; 25 const FilePath& key_file) = 0;
26 virtual void OnPackFailure(const std::wstring& message) = 0; 26 virtual void OnPackFailure(const std::string& message) = 0;
27 27
28 protected: 28 protected:
29 virtual ~Client() {} 29 virtual ~Client() {}
30 }; 30 };
31 31
32 PackExtensionJob(Client* client, 32 PackExtensionJob(Client* client,
33 const FilePath& root_directory, 33 const FilePath& root_directory,
34 const FilePath& key_file); 34 const FilePath& key_file);
35 35
36 // Starts the packing thread job. See http://crbug.com/27944 for more details 36 // Starts the packing thread job. See http://crbug.com/27944 for more details
37 // on why this function is needed. 37 // on why this function is needed.
38 void Start(); 38 void Start();
39 39
40 // The client should call this when it is destroyed to prevent 40 // The client should call this when it is destroyed to prevent
41 // PackExtensionJob from attempting to access it. 41 // PackExtensionJob from attempting to access it.
42 void ClearClient(); 42 void ClearClient();
43 43
44 private: 44 private:
45 friend class base::RefCountedThreadSafe<PackExtensionJob>; 45 friend class base::RefCountedThreadSafe<PackExtensionJob>;
46 46
47 ~PackExtensionJob() {} 47 ~PackExtensionJob() {}
48 48
49 void RunOnFileThread(); 49 void RunOnFileThread();
50 void ReportSuccessOnUIThread(); 50 void ReportSuccessOnClientThread();
51 void ReportFailureOnUIThread(const std::string& error); 51 void ReportFailureOnClientThread(const std::string& error);
52 52
53 ChromeThread::ID client_thread_id_; 53 ChromeThread::ID client_thread_id_;
54 Client* client_; 54 Client* client_;
55 FilePath root_directory_; 55 FilePath root_directory_;
56 FilePath key_file_; 56 FilePath key_file_;
57 FilePath crx_file_out_; 57 FilePath crx_file_out_;
58 FilePath key_file_out_; 58 FilePath key_file_out_;
59 59
60 DISALLOW_COPY_AND_ASSIGN(PackExtensionJob); 60 DISALLOW_COPY_AND_ASSIGN(PackExtensionJob);
61 }; 61 };
62 62
63 #endif // CHROME_BROWSER_EXTENSIONS_PACK_EXTENSION_JOB_H_ 63 #endif // CHROME_BROWSER_EXTENSIONS_PACK_EXTENSION_JOB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698