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

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

Issue 2697463002: Convert utility process extension Unpacker IPC to mojo (Closed)
Patch Set: Use MakeUnique when creating the utility mojo client. Created 3 years, 10 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_ZIPFILE_INSTALLER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_ZIPFILE_INSTALLER_H_
6 #define CHROME_BROWSER_EXTENSIONS_ZIPFILE_INSTALLER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_ZIPFILE_INSTALLER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/callback.h"
12 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
13 #include "base/macros.h" 12 #include "base/macros.h"
14 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
15 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
16 #include "content/public/browser/utility_process_host_client.h" 15 #include "content/public/browser/utility_process_mojo_client.h"
16 #include "extensions/common/extension_unpacker.mojom.h"
Devlin 2017/02/14 17:24:59 Could this just be a forward declaration?
Noel Gordon 2017/02/15 17:28:08 Possible, but not something we've conventionally d
Devlin 2017/02/17 15:53:56 Sorry, I don't follow - what's wrong with namespa
Noel Gordon 2017/02/27 11:47:50 OK done.
17 17
18 class ExtensionService; 18 class ExtensionService;
19 19
20 namespace IPC {
21 class Message;
22 }
23
24 namespace extensions { 20 namespace extensions {
25 21
26 // ZipFileInstaller unzips an extension that is zipped up via a utility process. 22 // ZipFileInstaller unzips an extension in a utility process. On success, the
27 // The contents are then loaded via UnpackedInstaller. 23 // extension content is loaded by an extensions::UnpackedInstaller.
28 class ZipFileInstaller : public content::UtilityProcessHostClient { 24 class ZipFileInstaller : public base::RefCountedThreadSafe<ZipFileInstaller> {
29 public: 25 public:
30 static scoped_refptr<ZipFileInstaller> Create( 26 static scoped_refptr<ZipFileInstaller> Create(ExtensionService* service);
31 ExtensionService* extension_service);
32 27
33 void LoadFromZipFile(const base::FilePath& path); 28 void LoadFromZipFile(const base::FilePath& zip_file);
34 29
35 void set_be_noisy_on_failure(bool value) { be_noisy_on_failure_ = value; } 30 void set_be_noisy_on_failure(bool value) { be_noisy_on_failure_ = value; }
36 31
37 // UtilityProcessHostClient 32 private:
38 bool OnMessageReceived(const IPC::Message& message) override; 33 friend class base::RefCountedThreadSafe<ZipFileInstaller>;
39 34
40 private: 35 explicit ZipFileInstaller(ExtensionService* service);
41 explicit ZipFileInstaller(ExtensionService* extension_service); 36 ~ZipFileInstaller();
42 ~ZipFileInstaller() override;
43 37
44 void PrepareTempDir(); 38 void PrepareTempDir(const base::FilePath& zip_file);
45 void StartWorkOnIOThread(const base::FilePath& temp_dir); 39 void UnzipOnUIThread(const base::FilePath& temp_dir);
46 void ReportSuccessOnUIThread(const base::FilePath& unzipped_path); 40 void UnzipDone(bool success);
47 void ReportErrorOnUIThread(const std::string& error); 41 void ReportErrorOnUIThread(const std::string& error);
48 42
49 void OnUnzipSucceeded(const base::FilePath& unzipped_path);
50 void OnUnzipFailed(const std::string& error);
51
52 bool be_noisy_on_failure_; 43 bool be_noisy_on_failure_;
53 base::WeakPtr<ExtensionService> extension_service_weak_; 44 base::WeakPtr<ExtensionService> extension_service_weak_;
54 base::FilePath zip_path_; 45 base::FilePath zip_file_;
46 base::FilePath temp_dir_;
Devlin 2017/02/14 17:24:59 Add member comments
Noel Gordon 2017/02/15 17:28:08 When adding mojo to other folks code that we are n
47
48 std::unique_ptr<
49 content::UtilityProcessMojoClient<extensions::mojom::ExtensionUnpacker>>
50 utility_process_mojo_client_;
55 51
56 DISALLOW_COPY_AND_ASSIGN(ZipFileInstaller); 52 DISALLOW_COPY_AND_ASSIGN(ZipFileInstaller);
57 }; 53 };
58 54
59 } // namespace extensions 55 } // namespace extensions
60 56
61 #endif // CHROME_BROWSER_EXTENSIONS_ZIPFILE_INSTALLER_H_ 57 #endif // CHROME_BROWSER_EXTENSIONS_ZIPFILE_INSTALLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698