Skip to content

Commit

Permalink
chrome/utility: Use BUILDFLAG for OS checking
Browse files Browse the repository at this point in the history
Use BUILDFLAG(IS_XXX) instead of defined(OS_XXX).

Generated by `os_buildflag_migration.py` (https://crrev.com/c/3311983).

R=thakis@chromium.org

Bug: 1234043
Test: No functionality change
Change-Id: I55656e54e143d25dfaeaf9937bd644a94db3fcd6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3392633
Commit-Queue: Xiaohan Wang <xhwang@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
Owners-Override: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#959657}
  • Loading branch information
xhwang-chromium authored and Chromium LUCI CQ committed Jan 15, 2022
1 parent fc70089 commit b0bde57
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 58 deletions.
4 changes: 2 additions & 2 deletions chrome/utility/browser_exposed_utility_interfaces.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
#include "mojo/public/cpp/bindings/binder_map.h"
#include "printing/buildflags/buildflags.h"

#if BUILDFLAG(ENABLE_PRINTING) && defined(OS_WIN)
#if BUILDFLAG(ENABLE_PRINTING) && BUILDFLAG(IS_WIN)
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/services/printing/pdf_to_emf_converter_factory.h"
#endif

void ExposeElevatedChromeUtilityInterfacesToBrowser(mojo::BinderMap* binders) {
#if BUILDFLAG(ENABLE_PRINTING) && defined(OS_WIN)
#if BUILDFLAG(ENABLE_PRINTING) && BUILDFLAG(IS_WIN)
binders->Add(base::BindRepeating(printing::PdfToEmfConverterFactory::Create),
base::ThreadTaskRunnerHandle::Get());
#endif
Expand Down
3 changes: 2 additions & 1 deletion chrome/utility/chrome_content_utility_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "base/files/file_path.h"
#include "base/lazy_instance.h"
#include "base/path_service.h"
#include "build/build_config.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/profiler/thread_profiler.h"
#include "chrome/common/profiler/thread_profiler_configuration.h"
Expand All @@ -35,7 +36,7 @@ ChromeContentUtilityClient::~ChromeContentUtilityClient() = default;

void ChromeContentUtilityClient::ExposeInterfacesToBrowser(
mojo::BinderMap* binders) {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
auto& cmd_line = *base::CommandLine::ForCurrentProcess();
auto sandbox_type = sandbox::policy::SandboxTypeFromCommandLine(cmd_line);
utility_process_running_elevated_ =
Expand Down
2 changes: 1 addition & 1 deletion chrome/utility/image_writer/error_message_strings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const char kOperationAlreadyInProgress[] = "Operation already in progress.";
const char kReadDevice[] = "Failed to read device.";
const char kReadImage[] = "Failed to read image.";
const char kWriteImage[] = "Writing image to device failed.";
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
const char kUnmountVolumes[] = "Unable to unmount the device.";
#endif
const char kVerificationFailed[] = "Verification failed.";
Expand Down
2 changes: 1 addition & 1 deletion chrome/utility/image_writer/error_message_strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ extern const char kOperationAlreadyInProgress[];
extern const char kReadDevice[];
extern const char kReadImage[];
extern const char kWriteImage[];
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
extern const char kUnmountVolumes[];
#endif
extern const char kVerificationFailed[];
Expand Down
4 changes: 2 additions & 2 deletions chrome/utility/image_writer/image_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "chrome/utility/image_writer/image_writer_handler.h"
#include "content/public/utility/utility_thread.h"

#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
#include "chrome/utility/image_writer/disk_unmounter_mac.h"
#endif

Expand All @@ -36,7 +36,7 @@ ImageWriter::ImageWriter(ImageWriterHandler* handler,
handler_(handler) {}

ImageWriter::~ImageWriter() {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
for (std::vector<HANDLE>::const_iterator it = volume_handles_.begin();
it != volume_handles_.end();
++it) {
Expand Down
8 changes: 4 additions & 4 deletions chrome/utility/image_writer/image_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
#include "base/memory/weak_ptr.h"
#include "build/build_config.h"

#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include <windows.h>
#endif

namespace image_writer {

class ImageWriterHandler;
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
class DiskUnmounterMac;
#endif

Expand Down Expand Up @@ -83,11 +83,11 @@ class ImageWriter : public base::SupportsWeakPtr<ImageWriter> {
int64_t bytes_processed_;
bool running_;

#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
std::vector<HANDLE> volume_handles_;
#endif

#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
friend class DiskUnmounterMac;
std::unique_ptr<DiskUnmounterMac> unmounter_;
#endif
Expand Down
14 changes: 7 additions & 7 deletions chrome/utility/importer/firefox_importer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
#include "sql/statement.h"
#include "url/gurl.h"

#if !defined(OS_MAC) && !defined(OS_FUCHSIA)
#if !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_FUCHSIA)
#include "chrome/utility/importer/nss_decryptor.h"
#endif // !defined(OS_MAC) && !defined(OS_FUCHSIA)
#endif // !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_FUCHSIA)

namespace {

Expand Down Expand Up @@ -119,7 +119,7 @@ void FirefoxImporter::StartImport(const importer::SourceProfile& source_profile,
source_path_ = source_profile.source_path;
app_path_ = source_profile.app_path;

#if defined(OS_POSIX)
#if BUILDFLAG(IS_POSIX)
locale_ = source_profile.locale;
#endif

Expand Down Expand Up @@ -149,13 +149,13 @@ void FirefoxImporter::StartImport(const importer::SourceProfile& source_profile,
ImportBookmarks();
bridge_->NotifyItemEnded(importer::FAVORITES);
}
#if !defined(OS_MAC) && !defined(OS_FUCHSIA)
#if !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_FUCHSIA)
if ((items & importer::PASSWORDS) && !cancelled()) {
bridge_->NotifyItemStarted(importer::PASSWORDS);
ImportPasswords();
bridge_->NotifyItemEnded(importer::PASSWORDS);
}
#endif // !defined(OS_MAC) && !defined(OS_FUCHSIA)
#endif // !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_FUCHSIA)
if ((items & importer::AUTOFILL_FORM_DATA) && !cancelled()) {
bridge_->NotifyItemStarted(importer::AUTOFILL_FORM_DATA);
ImportAutofillFormData();
Expand Down Expand Up @@ -374,7 +374,7 @@ void FirefoxImporter::ImportBookmarks() {
}
}

#if !defined(OS_MAC) && !defined(OS_FUCHSIA)
#if !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_FUCHSIA)
void FirefoxImporter::ImportPasswords() {
// Initializes NSS3.
NSSDecryptor decryptor;
Expand All @@ -400,7 +400,7 @@ void FirefoxImporter::ImportPasswords() {
}
}
}
#endif // !defined(OS_MAC) && !defined(OS_FUCHSIA)
#endif // !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_FUCHSIA)

void FirefoxImporter::ImportHomepage() {
GURL home_page = GetHomepage(source_path_);
Expand Down
4 changes: 2 additions & 2 deletions chrome/utility/importer/firefox_importer.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class FirefoxImporter : public Importer {

FRIEND_TEST_ALL_PREFIXES(FirefoxImporterTest, ImportBookmarksV25);
void ImportBookmarks();
#if !defined(OS_MAC) && !defined(OS_FUCHSIA)
#if !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_FUCHSIA)
void ImportPasswords();
#endif
void ImportHistory();
Expand Down Expand Up @@ -116,7 +116,7 @@ class FirefoxImporter : public Importer {
base::FilePath app_path_;
base::ScopedTempDir source_path_copy_;

#if defined(OS_POSIX)
#if BUILDFLAG(IS_POSIX)
// Stored because we can only access it from the UI thread.
std::string locale_;
#endif
Expand Down
8 changes: 4 additions & 4 deletions chrome/utility/importer/importer_creator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
#include "chrome/utility/importer/bookmarks_file_importer.h"
#include "chrome/utility/importer/firefox_importer.h"

#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include "chrome/common/importer/edge_importer_utils_win.h"
#include "chrome/utility/importer/edge_importer_win.h"
#include "chrome/utility/importer/ie_importer_win.h"
#endif

#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
#include "base/mac/foundation_util.h"
#include "chrome/utility/importer/safari_importer.h"
#endif
Expand All @@ -24,7 +24,7 @@ namespace importer {

scoped_refptr<Importer> CreateImporterByType(ImporterType type) {
switch (type) {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
case TYPE_IE:
return new IEImporter();
case TYPE_EDGE:
Expand All @@ -37,7 +37,7 @@ scoped_refptr<Importer> CreateImporterByType(ImporterType type) {
return new BookmarksFileImporter();
case TYPE_FIREFOX:
return new FirefoxImporter();
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
case TYPE_SAFARI:
return new SafariImporter(base::mac::GetUserLibraryPath());
#endif
Expand Down
2 changes: 1 addition & 1 deletion chrome/utility/importer/nss_decryptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include "build/build_config.h"

#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include "chrome/utility/importer/nss_decryptor_win.h"
#elif defined(USE_NSS_CERTS)
#include "chrome/utility/importer/nss_decryptor_system_nss.h"
Expand Down
2 changes: 1 addition & 1 deletion chrome/utility/importer/profile_import_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void ProfileImportImpl::StartImport(

// Create worker thread in which importer runs.
import_thread_ = std::make_unique<base::Thread>("import_thread");
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
import_thread_->init_com_with_mta(false);
#endif
if (!import_thread_->Start()) {
Expand Down
Loading

0 comments on commit b0bde57

Please sign in to comment.