diff --git a/cc/BUILD.gn b/cc/BUILD.gn index 7995d39..f6ff571b 100644 --- a/cc/BUILD.gn +++ b/cc/BUILD.gn
@@ -562,8 +562,6 @@ "test/fake_scrollbar.h", "test/fake_surface_observer.cc", "test/fake_surface_observer.h", - "test/fake_surface_resource_holder_client.cc", - "test/fake_surface_resource_holder_client.h", "test/fake_tile_manager.cc", "test/fake_tile_manager.h", "test/fake_tile_manager_client.cc",
diff --git a/cc/surfaces/BUILD.gn b/cc/surfaces/BUILD.gn index cf42dc053..76013e7 100644 --- a/cc/surfaces/BUILD.gn +++ b/cc/surfaces/BUILD.gn
@@ -28,9 +28,6 @@ "surface_manager.h", "surface_reference.cc", "surface_reference.h", - "surface_resource_holder.cc", - "surface_resource_holder.h", - "surface_resource_holder_client.h", "surfaces_export.h", ]
diff --git a/cc/surfaces/DEPS b/cc/surfaces/DEPS index d0a78f5..d2568d7 100644 --- a/cc/surfaces/DEPS +++ b/cc/surfaces/DEPS
@@ -1,6 +1,7 @@ include_rules = [ "+components/viz/common", "+components/viz/service/display", + "+components/viz/service/frame_sinks", "+mojo/public/cpp/bindings/struct_traits.h", ]
diff --git a/cc/surfaces/surface.cc b/cc/surfaces/surface.cc index 6e1b1aa2..d2273ac 100644 --- a/cc/surfaces/surface.cc +++ b/cc/surfaces/surface.cc
@@ -11,9 +11,10 @@ #include "base/stl_util.h" #include "cc/output/copy_output_request.h" +#include "cc/resources/returned_resource.h" +#include "cc/resources/transferable_resource.h" #include "cc/surfaces/surface_client.h" #include "cc/surfaces/surface_manager.h" -#include "cc/surfaces/surface_resource_holder_client.h" #include "components/viz/common/surfaces/local_surface_id_allocator.h" namespace cc {
diff --git a/cc/surfaces/surface_resource_holder_client.h b/cc/surfaces/surface_resource_holder_client.h deleted file mode 100644 index 3cb1518..0000000 --- a/cc/surfaces/surface_resource_holder_client.h +++ /dev/null
@@ -1,24 +0,0 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -#ifndef CC_SURFACES_SURFACE_RESOURCE_HOLDER_CLIENT_H_ -#define CC_SURFACES_SURFACE_RESOURCE_HOLDER_CLIENT_H_ - -#include "cc/resources/returned_resource.h" -#include "cc/surfaces/surfaces_export.h" - -namespace cc { - -class CC_SURFACES_EXPORT SurfaceResourceHolderClient { - public: - virtual ~SurfaceResourceHolderClient() = default; - - // ReturnResources gets called when the display compositor is done using the - // resources so that the client can use them. - virtual void ReturnResources( - const std::vector<ReturnedResource>& resources) = 0; -}; - -} // namespace cc - -#endif // CC_SURFACES_SURFACE_RESOURCE_HOLDER_CLIENT_H_
diff --git a/cc/test/fake_surface_resource_holder_client.cc b/cc/test/fake_surface_resource_holder_client.cc deleted file mode 100644 index 43c3ae0..0000000 --- a/cc/test/fake_surface_resource_holder_client.cc +++ /dev/null
@@ -1,19 +0,0 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "cc/test/fake_surface_resource_holder_client.h" - -namespace cc { - -FakeSurfaceResourceHolderClient::FakeSurfaceResourceHolderClient() = default; - -FakeSurfaceResourceHolderClient::~FakeSurfaceResourceHolderClient() = default; - -void FakeSurfaceResourceHolderClient::ReturnResources( - const std::vector<ReturnedResource>& resources) { - returned_resources_.insert(returned_resources_.end(), resources.begin(), - resources.end()); -} - -} // namespace cc
diff --git a/cc/test/fake_surface_resource_holder_client.h b/cc/test/fake_surface_resource_holder_client.h deleted file mode 100644 index c79ce6a..0000000 --- a/cc/test/fake_surface_resource_holder_client.h +++ /dev/null
@@ -1,31 +0,0 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CC_TEST_FAKE_SURFACE_RESOURCE_HOLDER_CLIENT_H_ -#define CC_TEST_FAKE_SURFACE_RESOURCE_HOLDER_CLIENT_H_ - -#include "cc/surfaces/surface_resource_holder_client.h" - -namespace cc { - -class FakeSurfaceResourceHolderClient : public SurfaceResourceHolderClient { - public: - FakeSurfaceResourceHolderClient(); - ~FakeSurfaceResourceHolderClient() override; - - // SurfaceResourceHolderClient implementation. - void ReturnResources(const std::vector<ReturnedResource>& resources) override; - - void clear_returned_resources() { returned_resources_.clear(); } - const std::vector<ReturnedResource>& returned_resources() { - return returned_resources_; - } - - private: - std::vector<ReturnedResource> returned_resources_; -}; - -} // namespace cc - -#endif // CC_TEST_FAKE_SURFACE_RESOURCE_HOLDER_CLIENT_H_
diff --git a/chrome/browser/chromeos/arc/arc_service_launcher.cc b/chrome/browser/chromeos/arc/arc_service_launcher.cc index 7cc9d0a..2b03d8c 100644 --- a/chrome/browser/chromeos/arc/arc_service_launcher.cc +++ b/chrome/browser/chromeos/arc/arc_service_launcher.cc
@@ -95,12 +95,6 @@ // List in lexicographical order. arc_service_manager_->AddService( - base::MakeUnique<ArcBluetoothBridge>(arc_bridge_service)); - arc_service_manager_->AddService( - base::MakeUnique<ArcBootErrorNotification>(arc_bridge_service)); - arc_service_manager_->AddService( - base::MakeUnique<ArcClipboardBridge>(arc_bridge_service)); - arc_service_manager_->AddService( base::MakeUnique<ArcCrashCollectorBridge>(arc_bridge_service)); arc_service_manager_->AddService( base::MakeUnique<ArcDownloadsWatcherService>(arc_bridge_service)); @@ -201,6 +195,9 @@ ArcAccessibilityHelperBridge::GetForBrowserContext(profile); ArcAudioBridge::GetForBrowserContext(profile); ArcAuthService::GetForBrowserContext(profile); + ArcBluetoothBridge::GetForBrowserContext(profile); + ArcBootErrorNotification::GetForBrowserContext(profile); + ArcClipboardBridge::GetForBrowserContext(profile); arc_service_manager_->AddService(base::MakeUnique<ArcBootPhaseMonitorBridge>( arc_service_manager_->arc_bridge_service(),
diff --git a/chrome/browser/chromeos/arc/notification/arc_boot_error_notification.cc b/chrome/browser/chromeos/arc/notification/arc_boot_error_notification.cc index 87d3e8a38..82f9275c 100644 --- a/chrome/browser/chromeos/arc/notification/arc_boot_error_notification.cc +++ b/chrome/browser/chromeos/arc/notification/arc_boot_error_notification.cc
@@ -9,11 +9,12 @@ #include "base/strings/utf_string_conversions.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" -#include "chrome/browser/profiles/profile_manager.h" +#include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/chrome_pages.h" #include "chrome/grit/generated_resources.h" -#include "components/arc/arc_bridge_service.h" +#include "components/arc/arc_browser_context_keyed_service_factory_base.h" #include "components/user_manager/user_manager.h" +#include "content/public/browser/browser_thread.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" #include "ui/chromeos/resources/grit/ui_chromeos_resources.h" @@ -34,21 +35,28 @@ class LowDiskSpaceErrorNotificationDelegate : public message_center::NotificationDelegate { public: - LowDiskSpaceErrorNotificationDelegate() = default; + explicit LowDiskSpaceErrorNotificationDelegate( + content::BrowserContext* context) + : context_(context) {} // message_center::NotificationDelegate void ButtonClick(int button_index) override { - chrome::ShowSettingsSubPageForProfile( - ProfileManager::GetActiveUserProfile(), kStoragePage); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + chrome::ShowSettingsSubPageForProfile(Profile::FromBrowserContext(context_), + kStoragePage); } private: ~LowDiskSpaceErrorNotificationDelegate() override = default; + // Passed from ArcBootErrorNotification, so owned by ProfileManager. + // Thus, touching this on UI thread while the message loop is running + // should be safe. + content::BrowserContext* const context_; DISALLOW_COPY_AND_ASSIGN(LowDiskSpaceErrorNotificationDelegate); }; -void ShowLowDiskSpaceErrorNotification() { +void ShowLowDiskSpaceErrorNotification(content::BrowserContext* context) { // We suppress the low-disk notification when there are multiple users on an // enterprise managed device. crbug.com/656788. if (g_browser_process->platform_part() @@ -82,24 +90,54 @@ gfx::Image(ui::ResourceBundle::GetSharedInstance().GetImageNamed( IDR_DISK_SPACE_NOTIFICATION_CRITICAL)), base::UTF8ToUTF16(kDisplaySource), GURL(), notifier_id, - optional_fields, new LowDiskSpaceErrorNotificationDelegate())); + optional_fields, new LowDiskSpaceErrorNotificationDelegate(context))); } +// Singleton factory for ArcBootErrorNotificationFactory. +class ArcBootErrorNotificationFactory + : public internal::ArcBrowserContextKeyedServiceFactoryBase< + ArcBootErrorNotification, + ArcBootErrorNotificationFactory> { + public: + // Factory name used by ArcBrowserContextKeyedServiceFactoryBase. + static constexpr const char* kName = "ArcBootErrorNotificationFactory"; + + static ArcBootErrorNotificationFactory* GetInstance() { + return base::Singleton<ArcBootErrorNotificationFactory>::get(); + } + + private: + friend base::DefaultSingletonTraits<ArcBootErrorNotificationFactory>; + ArcBootErrorNotificationFactory() = default; + ~ArcBootErrorNotificationFactory() override = default; +}; + } // namespace +// static +ArcBootErrorNotification* ArcBootErrorNotification::GetForBrowserContext( + content::BrowserContext* context) { + return ArcBootErrorNotificationFactory::GetForBrowserContext(context); +} + ArcBootErrorNotification::ArcBootErrorNotification( + content::BrowserContext* context, ArcBridgeService* bridge_service) - : ArcService(bridge_service) { + : context_(context) { ArcSessionManager::Get()->AddObserver(this); } ArcBootErrorNotification::~ArcBootErrorNotification() { - ArcSessionManager::Get()->RemoveObserver(this); + // TODO(hidehiko): Currently, the lifetime of ArcSessionManager and + // BrowserContextKeyedService is not nested. Remove if statement. + auto* arc_session_manager = ArcSessionManager::Get(); + if (arc_session_manager) + arc_session_manager->RemoveObserver(this); } void ArcBootErrorNotification::OnArcSessionStopped(ArcStopReason reason) { if (reason == ArcStopReason::LOW_DISK_SPACE) - ShowLowDiskSpaceErrorNotification(); + ShowLowDiskSpaceErrorNotification(context_); } } // namespace arc
diff --git a/chrome/browser/chromeos/arc/notification/arc_boot_error_notification.h b/chrome/browser/chromeos/arc/notification/arc_boot_error_notification.h index 1fe6e06..cdeb72b 100644 --- a/chrome/browser/chromeos/arc/notification/arc_boot_error_notification.h +++ b/chrome/browser/chromeos/arc/notification/arc_boot_error_notification.h
@@ -8,20 +8,33 @@ #include "base/macros.h" #include "chrome/browser/chromeos/arc/arc_session_manager.h" #include "components/arc/arc_service.h" +#include "components/keyed_service/core/keyed_service.h" + +namespace content { +class BrowserContext; +} // namespace content namespace arc { // Watches for ARC boot errors and show notifications. -class ArcBootErrorNotification : public ArcService, +class ArcBootErrorNotification : public KeyedService, public ArcSessionManager::Observer { public: - explicit ArcBootErrorNotification(ArcBridgeService* bridge_service); + // Returns singleton instance for the given BrowserContext, + // or nullptr if the browser |context| is not allowed to use ARC. + static ArcBootErrorNotification* GetForBrowserContext( + content::BrowserContext* context); + + ArcBootErrorNotification(content::BrowserContext* context, + ArcBridgeService* bridge_service); ~ArcBootErrorNotification() override; // ArcSessionManager::Observer: void OnArcSessionStopped(ArcStopReason reason) override; private: + content::BrowserContext* const context_; + DISALLOW_COPY_AND_ASSIGN(ArcBootErrorNotification); };
diff --git a/chrome/browser/extensions/api/sync_file_system/sync_file_system_browsertest.cc b/chrome/browser/extensions/api/sync_file_system/sync_file_system_browsertest.cc index c472eaa..eba03820 100644 --- a/chrome/browser/extensions/api/sync_file_system/sync_file_system_browsertest.cc +++ b/chrome/browser/extensions/api/sync_file_system/sync_file_system_browsertest.cc
@@ -90,7 +90,7 @@ remote_service_ = new drive_backend::SyncEngine( base::ThreadTaskRunnerHandle::Get(), // ui_task_runner MakeSequencedTaskRunner(), MakeSequencedTaskRunner(), - content::BrowserThread::GetBlockingPool(), base_dir_.GetPath(), + base_dir_.GetPath(), NULL, // task_logger NULL, // notification_manager extension_service,
diff --git a/chrome/browser/profiling_host/profiling_process_host.cc b/chrome/browser/profiling_host/profiling_process_host.cc index 4a43658c..f4786167 100644 --- a/chrome/browser/profiling_host/profiling_process_host.cc +++ b/chrome/browser/profiling_host/profiling_process_host.cc
@@ -16,6 +16,7 @@ #include "content/public/common/content_switches.h" #include "mojo/edk/embedder/outgoing_broker_client_invitation.h" #include "mojo/edk/embedder/platform_channel_pair.h" +#include "mojo/public/cpp/system/platform_handle.h" #if defined(OS_LINUX) #include <fcntl.h> @@ -30,7 +31,6 @@ #include "base/third_party/valgrind/valgrind.h" #include "chrome/common/profiling/profiling_constants.h" #include "content/public/browser/file_descriptor_info.h" -#include "mojo/public/cpp/system/platform_handle.h" #endif namespace profiling { @@ -154,6 +154,7 @@ #if defined(OS_WIN) base::Process process = base::Process::Current(); pipe_id_ = base::IntToString(static_cast<int>(process.Pid())); + base::CommandLine profiling_cmd = MakeProfilingCommandLine(pipe_id_); #else // Create the socketpair for the low level memlog pipe. @@ -169,9 +170,9 @@ pipe_id_ = base::IntToString(memlog_fds[0]); handle_passing_info.emplace_back(child_end.get(), child_end.get()); -#endif base::CommandLine profiling_cmd = MakeProfilingCommandLine(base::IntToString(child_end.get())); +#endif // Keep the server handle, pass the client handle to the child. pending_control_connection_ = control_channel.PassServerHandle();
diff --git a/chrome/browser/sync_file_system/drive_backend/conflict_resolver_unittest.cc b/chrome/browser/sync_file_system/drive_backend/conflict_resolver_unittest.cc index e9582e3..0420f3b1 100644 --- a/chrome/browser/sync_file_system/drive_backend/conflict_resolver_unittest.cc +++ b/chrome/browser/sync_file_system/drive_backend/conflict_resolver_unittest.cc
@@ -74,16 +74,14 @@ context_.reset(new SyncEngineContext( std::move(fake_drive_service), std::move(drive_uploader), nullptr /* task_logger */, base::ThreadTaskRunnerHandle::Get(), - base::ThreadTaskRunnerHandle::Get(), nullptr /* worker_pool */)); + base::ThreadTaskRunnerHandle::Get())); context_->SetRemoteChangeProcessor(remote_change_processor_.get()); RegisterSyncableFileSystem(); sync_task_manager_.reset(new SyncTaskManager( base::WeakPtr<SyncTaskManager::Client>(), - 10 /* maximum_background_task */, - base::ThreadTaskRunnerHandle::Get(), - nullptr /* worker_pool */)); + 10 /* maximum_background_task */, base::ThreadTaskRunnerHandle::Get())); sync_task_manager_->Initialize(SYNC_STATUS_OK); }
diff --git a/chrome/browser/sync_file_system/drive_backend/drive_backend_sync_unittest.cc b/chrome/browser/sync_file_system/drive_backend/drive_backend_sync_unittest.cc index fa439fb..bb6f33f8 100644 --- a/chrome/browser/sync_file_system/drive_backend/drive_backend_sync_unittest.cc +++ b/chrome/browser/sync_file_system/drive_backend/drive_backend_sync_unittest.cc
@@ -15,6 +15,7 @@ #include "base/sequenced_task_runner.h" #include "base/stl_util.h" #include "base/task_scheduler/post_task.h" +#include "base/task_scheduler/task_scheduler.h" #include "base/threading/thread_task_runner_handle.h" #include "chrome/browser/sync_file_system/drive_backend/callback_helper.h" #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants.h" @@ -118,8 +119,7 @@ remote_sync_service_.reset(new SyncEngine( base::ThreadTaskRunnerHandle::Get(), // ui_task_runner - worker_task_runner_.get(), drive_task_runner.get(), - content::BrowserThread::GetBlockingPool(), base_dir_.GetPath(), + worker_task_runner_.get(), drive_task_runner.get(), base_dir_.GetPath(), nullptr, // task_logger nullptr, // notification_manager nullptr, // extension_service @@ -153,7 +153,7 @@ local_sync_service_.reset(); remote_sync_service_.reset(); - content::RunAllBlockingPoolTasksUntilIdle(); + base::TaskScheduler::GetInstance()->FlushForTesting(); RevokeSyncableFileSystem(); }
diff --git a/chrome/browser/sync_file_system/drive_backend/fake_drive_service_helper.cc b/chrome/browser/sync_file_system/drive_backend/fake_drive_service_helper.cc index 6975d04..5f9339ec 100644 --- a/chrome/browser/sync_file_system/drive_backend/fake_drive_service_helper.cc +++ b/chrome/browser/sync_file_system/drive_backend/fake_drive_service_helper.cc
@@ -10,7 +10,6 @@ #include "base/files/file_util.h" #include "base/message_loop/message_loop.h" #include "base/run_loop.h" -#include "base/threading/sequenced_worker_pool.h" #include "chrome/browser/sync_file_system/sync_file_system_test_util.h" #include "chrome/browser/sync_file_system/sync_status_code.h" #include "google_apis/drive/drive_api_parser.h"
diff --git a/chrome/browser/sync_file_system/drive_backend/list_changes_task_unittest.cc b/chrome/browser/sync_file_system/drive_backend/list_changes_task_unittest.cc index f68bbdd..4fa2c2d 100644 --- a/chrome/browser/sync_file_system/drive_backend/list_changes_task_unittest.cc +++ b/chrome/browser/sync_file_system/drive_backend/list_changes_task_unittest.cc
@@ -61,15 +61,13 @@ sync_task_manager_.reset(new SyncTaskManager( base::WeakPtr<SyncTaskManager::Client>(), - 10 /* maximum_background_task */, - base::ThreadTaskRunnerHandle::Get(), - nullptr /* worker_pool */)); + 10 /* maximum_background_task */, base::ThreadTaskRunnerHandle::Get())); sync_task_manager_->Initialize(SYNC_STATUS_OK); context_.reset(new SyncEngineContext( std::move(fake_drive_service), std::move(drive_uploader), nullptr /* task_logger */, base::ThreadTaskRunnerHandle::Get(), - base::ThreadTaskRunnerHandle::Get(), nullptr /* worker_pool */)); + base::ThreadTaskRunnerHandle::Get())); SetUpRemoteFolders();
diff --git a/chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer_unittest.cc b/chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer_unittest.cc index bb9ce1d..71a6495 100644 --- a/chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer_unittest.cc +++ b/chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer_unittest.cc
@@ -75,16 +75,14 @@ context_.reset(new SyncEngineContext( std::move(fake_drive_service), std::move(drive_uploader), nullptr /* task_logger */, base::ThreadTaskRunnerHandle::Get(), - base::ThreadTaskRunnerHandle::Get(), nullptr /* worker_pool */)); + base::ThreadTaskRunnerHandle::Get())); context_->SetRemoteChangeProcessor(remote_change_processor_.get()); RegisterSyncableFileSystem(); sync_task_manager_.reset(new SyncTaskManager( base::WeakPtr<SyncTaskManager::Client>(), - 10 /* maximum_background_task */, - base::ThreadTaskRunnerHandle::Get(), - nullptr /* worker_pool */)); + 10 /* maximum_background_task */, base::ThreadTaskRunnerHandle::Get())); sync_task_manager_->Initialize(SYNC_STATUS_OK); }
diff --git a/chrome/browser/sync_file_system/drive_backend/register_app_task_unittest.cc b/chrome/browser/sync_file_system/drive_backend/register_app_task_unittest.cc index 54f4e55..c782eac0 100644 --- a/chrome/browser/sync_file_system/drive_backend/register_app_task_unittest.cc +++ b/chrome/browser/sync_file_system/drive_backend/register_app_task_unittest.cc
@@ -17,7 +17,6 @@ #include "base/run_loop.h" #include "base/strings/string_number_conversions.h" #include "base/strings/stringprintf.h" -#include "base/threading/sequenced_worker_pool.h" #include "base/threading/thread_task_runner_handle.h" #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants.h" #include "chrome/browser/sync_file_system/drive_backend/drive_backend_util.h" @@ -67,7 +66,7 @@ context_.reset(new SyncEngineContext( std::move(fake_drive_service), std::move(drive_uploader), nullptr /* task_logger */, base::ThreadTaskRunnerHandle::Get(), - base::ThreadTaskRunnerHandle::Get(), nullptr /* worker_pool */)); + base::ThreadTaskRunnerHandle::Get())); ASSERT_EQ(google_apis::HTTP_CREATED, fake_drive_service_helper_->AddOrphanedFolder(
diff --git a/chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer_unittest.cc b/chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer_unittest.cc index 0ee321f6..8b8d4b7b 100644 --- a/chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer_unittest.cc +++ b/chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer_unittest.cc
@@ -74,16 +74,14 @@ context_.reset(new SyncEngineContext( std::move(fake_drive_service), std::move(drive_uploader), nullptr /* task_logger */, base::ThreadTaskRunnerHandle::Get(), - base::ThreadTaskRunnerHandle::Get(), nullptr /* worker_pool*/)); + base::ThreadTaskRunnerHandle::Get())); context_->SetRemoteChangeProcessor(remote_change_processor_.get()); RegisterSyncableFileSystem(); sync_task_manager_.reset(new SyncTaskManager( - base::WeakPtr<SyncTaskManager::Client>(), - 10 /* max_parallel_task */, - base::ThreadTaskRunnerHandle::Get(), - nullptr /* worker_pool */)); + base::WeakPtr<SyncTaskManager::Client>(), 10 /* max_parallel_task */, + base::ThreadTaskRunnerHandle::Get())); sync_task_manager_->Initialize(SYNC_STATUS_OK); }
diff --git a/chrome/browser/sync_file_system/drive_backend/sync_engine.cc b/chrome/browser/sync_file_system/drive_backend/sync_engine.cc index 7d6266c0..f709416 100644 --- a/chrome/browser/sync_file_system/drive_backend/sync_engine.cc +++ b/chrome/browser/sync_file_system/drive_backend/sync_engine.cc
@@ -12,7 +12,6 @@ #include "base/memory/ptr_util.h" #include "base/metrics/histogram_macros.h" #include "base/task_scheduler/post_task.h" -#include "base/threading/sequenced_worker_pool.h" #include "base/threading/thread_task_runner_handle.h" #include "base/time/time.h" #include "base/values.h" @@ -223,7 +222,6 @@ std::unique_ptr<drive_backend::SyncEngine> sync_engine(new SyncEngine( ui_task_runner.get(), worker_task_runner.get(), drive_task_runner.get(), - content::BrowserThread::GetBlockingPool(), GetSyncFileSystemDir(context->GetPath()), task_logger, notification_manager, extension_service, signin_manager, token_service, request_context.get(), base::MakeUnique<DriveServiceFactory>(), @@ -334,8 +332,7 @@ worker_task_runner_.get())); std::unique_ptr<SyncEngineContext> sync_engine_context(new SyncEngineContext( std::move(drive_service_on_worker), std::move(drive_uploader_on_worker), - task_logger_, ui_task_runner_.get(), worker_task_runner_.get(), - worker_pool_.get())); + task_logger_, ui_task_runner_.get(), worker_task_runner_.get())); worker_observer_.reset(new WorkerObserver(ui_task_runner_.get(), weak_ptr_factory_.GetWeakPtr())); @@ -721,7 +718,6 @@ const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner, const scoped_refptr<base::SequencedTaskRunner>& worker_task_runner, const scoped_refptr<base::SequencedTaskRunner>& drive_task_runner, - const scoped_refptr<base::SequencedWorkerPool>& worker_pool, const base::FilePath& sync_file_system_dir, TaskLogger* task_logger, drive::DriveNotificationManager* notification_manager, @@ -734,7 +730,6 @@ : ui_task_runner_(ui_task_runner), worker_task_runner_(worker_task_runner), drive_task_runner_(drive_task_runner), - worker_pool_(worker_pool), sync_file_system_dir_(sync_file_system_dir), task_logger_(task_logger), notification_manager_(notification_manager),
diff --git a/chrome/browser/sync_file_system/drive_backend/sync_engine.h b/chrome/browser/sync_file_system/drive_backend/sync_engine.h index bc1759c..3721b8a4 100644 --- a/chrome/browser/sync_file_system/drive_backend/sync_engine.h +++ b/chrome/browser/sync_file_system/drive_backend/sync_engine.h
@@ -27,7 +27,6 @@ namespace base { class SequencedTaskRunner; -class SequencedWorkerPool; } namespace drive { @@ -158,7 +157,6 @@ SyncEngine(const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner, const scoped_refptr<base::SequencedTaskRunner>& worker_task_runner, const scoped_refptr<base::SequencedTaskRunner>& drive_task_runner, - const scoped_refptr<base::SequencedWorkerPool>& worker_pool, const base::FilePath& sync_file_system_dir, TaskLogger* task_logger, drive::DriveNotificationManager* notification_manager, @@ -184,7 +182,6 @@ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; scoped_refptr<base::SequencedTaskRunner> worker_task_runner_; scoped_refptr<base::SequencedTaskRunner> drive_task_runner_; - scoped_refptr<base::SequencedWorkerPool> worker_pool_; const base::FilePath sync_file_system_dir_; TaskLogger* task_logger_;
diff --git a/chrome/browser/sync_file_system/drive_backend/sync_engine_context.cc b/chrome/browser/sync_file_system/drive_backend/sync_engine_context.cc index 76a16150..5e6c465 100644 --- a/chrome/browser/sync_file_system/drive_backend/sync_engine_context.cc +++ b/chrome/browser/sync_file_system/drive_backend/sync_engine_context.cc
@@ -10,7 +10,6 @@ #include "base/memory/ref_counted.h" #include "base/sequenced_task_runner.h" #include "base/single_thread_task_runner.h" -#include "base/threading/sequenced_worker_pool.h" #include "chrome/browser/sync_file_system/drive_backend/metadata_database.h" #include "chrome/browser/sync_file_system/remote_change_processor.h" #include "chrome/browser/sync_file_system/task_logger.h" @@ -25,16 +24,14 @@ std::unique_ptr<drive::DriveUploaderInterface> drive_uploader, TaskLogger* task_logger, const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner, - const scoped_refptr<base::SequencedTaskRunner>& worker_task_runner, - const scoped_refptr<base::SequencedWorkerPool>& worker_pool) + const scoped_refptr<base::SequencedTaskRunner>& worker_task_runner) : drive_service_(std::move(drive_service)), drive_uploader_(std::move(drive_uploader)), task_logger_(task_logger ? task_logger->AsWeakPtr() : base::WeakPtr<TaskLogger>()), remote_change_processor_(nullptr), ui_task_runner_(ui_task_runner), - worker_task_runner_(worker_task_runner), - worker_pool_(worker_pool) { + worker_task_runner_(worker_task_runner) { sequence_checker_.DetachFromSequence(); } @@ -82,11 +79,6 @@ return worker_task_runner_.get(); } -base::SequencedWorkerPool* SyncEngineContext::GetWorkerPool() { - DCHECK(sequence_checker_.CalledOnValidSequence()); - return worker_pool_.get(); -} - void SyncEngineContext::SetMetadataDatabase( std::unique_ptr<MetadataDatabase> metadata_database) { DCHECK(sequence_checker_.CalledOnValidSequence());
diff --git a/chrome/browser/sync_file_system/drive_backend/sync_engine_context.h b/chrome/browser/sync_file_system/drive_backend/sync_engine_context.h index febfb76..3d80a11 100644 --- a/chrome/browser/sync_file_system/drive_backend/sync_engine_context.h +++ b/chrome/browser/sync_file_system/drive_backend/sync_engine_context.h
@@ -14,7 +14,6 @@ namespace base { class SequencedTaskRunner; -class SequencedWorkerPool; class SingleThreadTaskRunner; } @@ -39,8 +38,7 @@ std::unique_ptr<drive::DriveUploaderInterface> drive_uploader, TaskLogger* task_logger, const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner, - const scoped_refptr<base::SequencedTaskRunner>& worker_task_runner, - const scoped_refptr<base::SequencedWorkerPool>& worker_pool); + const scoped_refptr<base::SequencedTaskRunner>& worker_task_runner); ~SyncEngineContext(); void SetMetadataDatabase(std::unique_ptr<MetadataDatabase> metadata_database); @@ -54,7 +52,6 @@ RemoteChangeProcessor* GetRemoteChangeProcessor(); base::SingleThreadTaskRunner* GetUITaskRunner(); base::SequencedTaskRunner* GetWorkerTaskRunner(); - base::SequencedWorkerPool* GetWorkerPool(); std::unique_ptr<MetadataDatabase> PassMetadataDatabase(); @@ -71,7 +68,6 @@ std::unique_ptr<MetadataDatabase> metadata_database_; scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; scoped_refptr<base::SequencedTaskRunner> worker_task_runner_; - scoped_refptr<base::SequencedWorkerPool> worker_pool_; base::SequenceChecker sequence_checker_;
diff --git a/chrome/browser/sync_file_system/drive_backend/sync_engine_initializer_unittest.cc b/chrome/browser/sync_file_system/drive_backend/sync_engine_initializer_unittest.cc index 38d9d48..47902a5 100644 --- a/chrome/browser/sync_file_system/drive_backend/sync_engine_initializer_unittest.cc +++ b/chrome/browser/sync_file_system/drive_backend/sync_engine_initializer_unittest.cc
@@ -63,13 +63,11 @@ std::move(fake_drive_service), std::unique_ptr<drive::DriveUploaderInterface>(), nullptr /* task_logger */, base::ThreadTaskRunnerHandle::Get(), - base::ThreadTaskRunnerHandle::Get(), nullptr /* worker_pool */)); + base::ThreadTaskRunnerHandle::Get())); sync_task_manager_.reset(new SyncTaskManager( - base::WeakPtr<SyncTaskManager::Client>(), - 1 /* maximum_parallel_task */, - base::ThreadTaskRunnerHandle::Get(), - nullptr /* worker_pool */)); + base::WeakPtr<SyncTaskManager::Client>(), 1 /* maximum_parallel_task */, + base::ThreadTaskRunnerHandle::Get())); sync_task_manager_->Initialize(SYNC_STATUS_OK); }
diff --git a/chrome/browser/sync_file_system/drive_backend/sync_engine_unittest.cc b/chrome/browser/sync_file_system/drive_backend/sync_engine_unittest.cc index 4e7dc093..57020f9d 100644 --- a/chrome/browser/sync_file_system/drive_backend/sync_engine_unittest.cc +++ b/chrome/browser/sync_file_system/drive_backend/sync_engine_unittest.cc
@@ -12,7 +12,6 @@ #include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/task_scheduler/post_task.h" -#include "base/test/sequenced_worker_pool_owner.h" #include "base/threading/thread_task_runner_handle.h" #include "chrome/browser/sync_file_system/drive_backend/callback_helper.h" #include "chrome/browser/sync_file_system/drive_backend/fake_sync_worker.h" @@ -34,7 +33,7 @@ public: typedef RemoteFileSyncService::OriginStatusMap RemoteOriginStatusMap; - SyncEngineTest() : worker_pool_owner_(2, "Worker") {} + SyncEngineTest() {} ~SyncEngineTest() override {} void SetUp() override { @@ -51,7 +50,7 @@ sync_engine_.reset(new drive_backend::SyncEngine( ui_task_runner.get(), worker_task_runner_.get(), nullptr, // drive_task_runner - worker_pool_owner_.pool().get(), profile_dir_.GetPath(), + profile_dir_.GetPath(), nullptr, // task_logger nullptr, // notification_manager nullptr, // extension_service @@ -126,7 +125,6 @@ base::ScopedTempDir profile_dir_; std::unique_ptr<drive_backend::SyncEngine> sync_engine_; - base::SequencedWorkerPoolOwner worker_pool_owner_; scoped_refptr<base::SequencedTaskRunner> worker_task_runner_; DISALLOW_COPY_AND_ASSIGN(SyncEngineTest);
diff --git a/chrome/browser/sync_file_system/drive_backend/sync_task_manager.cc b/chrome/browser/sync_file_system/drive_backend/sync_task_manager.cc index 08cc59d..7ec188ea 100644 --- a/chrome/browser/sync_file_system/drive_backend/sync_task_manager.cc +++ b/chrome/browser/sync_file_system/drive_backend/sync_task_manager.cc
@@ -60,16 +60,13 @@ SyncTaskManager::SyncTaskManager( base::WeakPtr<Client> client, size_t maximum_background_task, - const scoped_refptr<base::SequencedTaskRunner>& task_runner, - const scoped_refptr<base::SequencedWorkerPool>& worker_pool) + const scoped_refptr<base::SequencedTaskRunner>& task_runner) : client_(client), maximum_background_task_(maximum_background_task), pending_task_seq_(0), task_token_seq_(SyncTaskToken::kMinimumBackgroundTaskTokenID), task_runner_(task_runner), - worker_pool_(worker_pool), - weak_ptr_factory_(this) { -} + weak_ptr_factory_(this) {} SyncTaskManager::~SyncTaskManager() { weak_ptr_factory_.InvalidateWeakPtrs(); @@ -209,10 +206,6 @@ sequence_checker_.DetachFromSequence(); } -bool SyncTaskManager::ShouldTrackTaskToken() const { - return !worker_pool_ || !worker_pool_->IsShutdownInProgress(); -} - void SyncTaskManager::NotifyTaskDoneBody(std::unique_ptr<SyncTaskToken> token, SyncStatusCode status) { DCHECK(sequence_checker_.CalledOnValidSequence());
diff --git a/chrome/browser/sync_file_system/drive_backend/sync_task_manager.h b/chrome/browser/sync_file_system/drive_backend/sync_task_manager.h index 7531682..ec3c9e69 100644 --- a/chrome/browser/sync_file_system/drive_backend/sync_task_manager.h +++ b/chrome/browser/sync_file_system/drive_backend/sync_task_manager.h
@@ -17,7 +17,6 @@ #include "base/macros.h" #include "base/memory/weak_ptr.h" #include "base/sequence_checker.h" -#include "base/threading/sequenced_worker_pool.h" #include "chrome/browser/sync_file_system/drive_backend/task_dependency_manager.h" #include "chrome/browser/sync_file_system/sync_callbacks.h" #include "chrome/browser/sync_file_system/sync_status_code.h" @@ -77,8 +76,7 @@ // If |maximum_background_tasks| is zero, all task runs as foreground task. SyncTaskManager(base::WeakPtr<Client> client, size_t maximum_background_task, - const scoped_refptr<base::SequencedTaskRunner>& task_runner, - const scoped_refptr<base::SequencedWorkerPool>& worker_pool); + const scoped_refptr<base::SequencedTaskRunner>& task_runner); virtual ~SyncTaskManager(); // This needs to be called to start task scheduling. @@ -129,7 +127,6 @@ bool IsRunningTask(int64_t task_token_id) const; void DetachFromSequence(); - bool ShouldTrackTaskToken() const; private: struct PendingTask { @@ -209,7 +206,6 @@ TaskDependencyManager dependency_manager_; scoped_refptr<base::SequencedTaskRunner> task_runner_; - scoped_refptr<base::SequencedWorkerPool> worker_pool_; base::SequenceChecker sequence_checker_; base::WeakPtrFactory<SyncTaskManager> weak_ptr_factory_;
diff --git a/chrome/browser/sync_file_system/drive_backend/sync_task_manager_unittest.cc b/chrome/browser/sync_file_system/drive_backend/sync_task_manager_unittest.cc index f6f22e8..660dcb06 100644 --- a/chrome/browser/sync_file_system/drive_backend/sync_task_manager_unittest.cc +++ b/chrome/browser/sync_file_system/drive_backend/sync_task_manager_unittest.cc
@@ -56,10 +56,9 @@ task_scheduled_count_(0), idle_task_scheduled_count_(0), last_operation_status_(SYNC_STATUS_OK) { - task_manager_.reset(new SyncTaskManager( - AsWeakPtr(), maximum_background_task, - base::ThreadTaskRunnerHandle::Get(), - nullptr /* worker_pool */)); + task_manager_.reset( + new SyncTaskManager(AsWeakPtr(), maximum_background_task, + base::ThreadTaskRunnerHandle::Get())); task_manager_->Initialize(SYNC_STATUS_OK); base::RunLoop().RunUntilIdle(); maybe_schedule_next_task_count_ = 0; @@ -387,8 +386,7 @@ { SyncTaskManager task_manager(base::WeakPtr<SyncTaskManager::Client>(), 0 /* maximum_background_task */, - base::ThreadTaskRunnerHandle::Get(), - nullptr /* worker_pool */); + base::ThreadTaskRunnerHandle::Get()); task_manager.Initialize(SYNC_STATUS_OK); base::RunLoop().RunUntilIdle(); task_manager.ScheduleSyncTask( @@ -409,8 +407,7 @@ base::MessageLoop message_loop; SyncTaskManager task_manager(base::WeakPtr<SyncTaskManager::Client>(), 0 /* maximum_background_task */, - base::ThreadTaskRunnerHandle::Get(), - nullptr /* worker_pool */); + base::ThreadTaskRunnerHandle::Get()); task_manager.Initialize(SYNC_STATUS_OK); base::RunLoop().RunUntilIdle(); @@ -471,8 +468,7 @@ base::MessageLoop message_loop; SyncTaskManager task_manager(base::WeakPtr<SyncTaskManager::Client>(), 10 /* maximum_background_task */, - base::ThreadTaskRunnerHandle::Get(), - nullptr /* worker_pool */); + base::ThreadTaskRunnerHandle::Get()); task_manager.Initialize(SYNC_STATUS_OK); SyncStatusCode status = SYNC_STATUS_FAILED; @@ -504,8 +500,7 @@ base::MessageLoop message_loop; SyncTaskManager task_manager(base::WeakPtr<SyncTaskManager::Client>(), 10 /* maximum_background_task */, - base::ThreadTaskRunnerHandle::Get(), - nullptr /* worker_pool */); + base::ThreadTaskRunnerHandle::Get()); task_manager.Initialize(SYNC_STATUS_OK); SyncStatusCode status = SYNC_STATUS_FAILED; @@ -537,8 +532,7 @@ base::MessageLoop message_loop; SyncTaskManager task_manager(base::WeakPtr<SyncTaskManager::Client>(), 2 /* maximum_background_task */, - base::ThreadTaskRunnerHandle::Get(), - nullptr /* worker_pool */); + base::ThreadTaskRunnerHandle::Get()); task_manager.Initialize(SYNC_STATUS_OK); SyncStatusCode status = SYNC_STATUS_FAILED; @@ -570,8 +564,7 @@ base::MessageLoop message_loop; SyncTaskManager task_manager(base::WeakPtr<SyncTaskManager::Client>(), 10 /* maximum_background_task */, - base::ThreadTaskRunnerHandle::Get(), - nullptr /* worker_pool */); + base::ThreadTaskRunnerHandle::Get()); task_manager.Initialize(SYNC_STATUS_OK); SyncStatusCode status1 = SYNC_STATUS_FAILED;
diff --git a/chrome/browser/sync_file_system/drive_backend/sync_task_token.cc b/chrome/browser/sync_file_system/drive_backend/sync_task_token.cc index d53f78e5..b701de4 100644 --- a/chrome/browser/sync_file_system/drive_backend/sync_task_token.cc +++ b/chrome/browser/sync_file_system/drive_backend/sync_task_token.cc
@@ -67,9 +67,6 @@ // dropped by a task without returning. if (task_runner_.get() && task_runner_->RunsTasksInCurrentSequence() && manager_ && manager_->IsRunningTask(token_id_)) { - if (!manager_->ShouldTrackTaskToken()) - return; - NOTREACHED() << "Unexpected TaskToken deletion from: " << location_.ToString();
diff --git a/chrome/browser/sync_file_system/drive_backend/sync_worker.cc b/chrome/browser/sync_file_system/drive_backend/sync_worker.cc index 31716e3d7..8fdeb31e 100644 --- a/chrome/browser/sync_file_system/drive_backend/sync_worker.cc +++ b/chrome/browser/sync_file_system/drive_backend/sync_worker.cc
@@ -72,10 +72,9 @@ context_ = std::move(context); - task_manager_.reset(new SyncTaskManager( - weak_ptr_factory_.GetWeakPtr(), 0 /* maximum_background_task */, - context_->GetWorkerTaskRunner(), - context_->GetWorkerPool())); + task_manager_.reset(new SyncTaskManager(weak_ptr_factory_.GetWeakPtr(), + 0 /* maximum_background_task */, + context_->GetWorkerTaskRunner())); task_manager_->Initialize(SYNC_STATUS_OK); PostInitializeTask();
diff --git a/chrome/browser/sync_file_system/drive_backend/sync_worker_unittest.cc b/chrome/browser/sync_file_system/drive_backend/sync_worker_unittest.cc index 8c9e2b1..6b337fc5 100644 --- a/chrome/browser/sync_file_system/drive_backend/sync_worker_unittest.cc +++ b/chrome/browser/sync_file_system/drive_backend/sync_worker_unittest.cc
@@ -117,8 +117,7 @@ std::move(fake_drive_service), nullptr /* drive_uploader */, nullptr /* task_logger */, base::ThreadTaskRunnerHandle::Get() /* ui_task_runner */, - base::ThreadTaskRunnerHandle::Get() /* worker_task_runner */, - nullptr /* worker_pool */)); + base::ThreadTaskRunnerHandle::Get() /* worker_task_runner */)); sync_worker_.reset(new SyncWorker(profile_dir_.GetPath(), extension_service_->AsWeakPtr(),
diff --git a/chrome/profiling/memlog_receiver_pipe_server_posix.h b/chrome/profiling/memlog_receiver_pipe_server_posix.h index a12c297a..066d4f3e 100644 --- a/chrome/profiling/memlog_receiver_pipe_server_posix.h +++ b/chrome/profiling/memlog_receiver_pipe_server_posix.h
@@ -9,7 +9,7 @@ #include "base/callback_forward.h" #include "base/containers/flat_map.h" -#include "base/files/scoped_file.h" +#include "base/files/file.h" #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/message_loop/message_pump_libevent.h" @@ -47,7 +47,7 @@ // Runs on IO Thread. // TODO(ajwong): Make private once the correct separation of responsibilities // is worked out between MemlogReceiverPipeServer and ProfilingProcess. - void OnNewPipe(base::ScopedFD pipe, int sender_pid); + void OnNewPipe(base::ScopedPlatformFile pipe, int sender_pid); private: friend class base::RefCountedThreadSafe<MemlogReceiverPipeServer>;
diff --git a/chrome/profiling/memlog_receiver_pipe_server_win.cc b/chrome/profiling/memlog_receiver_pipe_server_win.cc index 780b873..44aa4430 100644 --- a/chrome/profiling/memlog_receiver_pipe_server_win.cc +++ b/chrome/profiling/memlog_receiver_pipe_server_win.cc
@@ -42,6 +42,19 @@ base::Bind(&MemlogReceiverPipeServer::ScheduleNewConnection, this, true)); } +void MemlogReceiverPipeServer::OnNewPipe(base::ScopedPlatformFile pipe, + int sender_pid) { + MemlogReceiverPipe::CompletionThunk::Callback cb; + std::unique_ptr<MemlogReceiverPipe::CompletionThunk> ct( + new MemlogReceiverPipe::CompletionThunk(pipe.Take(), std::move(cb))); + scoped_refptr<MemlogReceiverPipe> receiver_pipe( + new MemlogReceiverPipe(std::move(ct))); + + if (!on_new_connection_.is_null()) + on_new_connection_.Run(std::move(receiver_pipe), sender_pid); + receiver_pipe->StartReadingOnIOThread(); +} + base::string16 MemlogReceiverPipeServer::GetPipeName() const { base::string16 pipe_name(kWindowsPipePrefix); pipe_name.append(pipe_id_); @@ -78,7 +91,7 @@ // TODO(ajwong): Why should there be a null-check here? if (!on_new_connection_.is_null()) - on_new_connection_.Run(pipe); + on_new_connection_.Run(std::move(pipe), pipe->GetRemoteProcessID()); pipe->StartReadingOnIOThread(); }
diff --git a/chrome/profiling/memlog_receiver_pipe_server_win.h b/chrome/profiling/memlog_receiver_pipe_server_win.h index 8f12a7f..e546c409 100644 --- a/chrome/profiling/memlog_receiver_pipe_server_win.h +++ b/chrome/profiling/memlog_receiver_pipe_server_win.h
@@ -8,6 +8,7 @@ #include <memory> #include "base/callback_forward.h" +#include "base/files/file.h" #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/message_loop/message_pump_win.h" @@ -28,7 +29,7 @@ : public base::RefCountedThreadSafe<MemlogReceiverPipeServer> { public: using NewConnectionCallback = - base::RepeatingCallback<void(scoped_refptr<MemlogReceiverPipe>)>; + base::RepeatingCallback<void(scoped_refptr<MemlogReceiverPipe>, int)>; // |io_runner| is the task runner for the I/O thread. When a new connection is // established, the |on_new_conn| callback is called with the pipe. @@ -44,6 +45,8 @@ // Starts the server which opens the pipe and begins accepting connections. void Start(); + void OnNewPipe(base::ScopedPlatformFile pipe, int sender_pid); + private: base::string16 GetPipeName() const;
diff --git a/chrome/profiling/profiling_process.cc b/chrome/profiling/profiling_process.cc index fa8accdc8..d4361a192 100644 --- a/chrome/profiling/profiling_process.cc +++ b/chrome/profiling/profiling_process.cc
@@ -5,7 +5,7 @@ #include "chrome/profiling/profiling_process.h" #include "base/bind.h" -#include "base/files/scoped_platform_handle.h" +#include "base/files/platform_file.h" #include "chrome/common/profiling/profiling_constants.h" #include "chrome/profiling/profiling_globals.h" #include "mojo/public/cpp/system/platform_handle.h" @@ -40,7 +40,7 @@ MojoResult result = mojo::UnwrapPlatformFile(std::move(sender_pipe), &sender_file); CHECK_EQ(result, MOJO_RESULT_OK); - server_->OnNewPipe(base::ScopedFD(sender_file), sender_pid); + server_->OnNewPipe(base::ScopedPlatformFile(sender_file), sender_pid); } } // namespace profiling
diff --git a/components/arc/arc_browser_context_keyed_service_factory_base.h b/components/arc/arc_browser_context_keyed_service_factory_base.h index f0152a42..3ebf5fb 100644 --- a/components/arc/arc_browser_context_keyed_service_factory_base.h +++ b/components/arc/arc_browser_context_keyed_service_factory_base.h
@@ -70,6 +70,9 @@ // subclasses. // // This header is intended to be included only from the .cc file directly. +// +// TODO(hidehiko): Make ArcFooService constructor (and maybe destructor) +// private with declaring appropriate friend. template <typename Service, typename Factory> class ArcBrowserContextKeyedServiceFactoryBase : public BrowserContextKeyedServiceFactory {
diff --git a/components/arc/bluetooth/arc_bluetooth_bridge.cc b/components/arc/bluetooth/arc_bluetooth_bridge.cc index 02f86e3..8bff813 100644 --- a/components/arc/bluetooth/arc_bluetooth_bridge.cc +++ b/components/arc/bluetooth/arc_bluetooth_bridge.cc
@@ -16,12 +16,14 @@ #include "base/bind.h" #include "base/logging.h" #include "base/memory/ptr_util.h" +#include "base/memory/singleton.h" #include "base/posix/eintr_wrapper.h" #include "base/strings/string_number_conversions.h" #include "base/strings/utf_string_conversions.h" #include "base/threading/thread_task_runner_handle.h" #include "base/time/time.h" #include "components/arc/arc_bridge_service.h" +#include "components/arc/arc_browser_context_keyed_service_factory_base.h" #include "components/arc/bluetooth/bluetooth_type_converters.h" #include "device/bluetooth/bluetooth_common.h" #include "device/bluetooth/bluetooth_device.h" @@ -248,9 +250,40 @@ } // namespace namespace arc { +namespace { -ArcBluetoothBridge::ArcBluetoothBridge(ArcBridgeService* bridge_service) - : ArcService(bridge_service), binding_(this), weak_factory_(this) { +// Singleton factory for ArcAccessibilityHelperBridge. +class ArcBluetoothBridgeFactory + : public internal::ArcBrowserContextKeyedServiceFactoryBase< + ArcBluetoothBridge, + ArcBluetoothBridgeFactory> { + public: + // Factory name used by ArcBrowserContextKeyedServiceFactoryBase. + static constexpr const char* kName = "ArcBluetoothBridgeFactory"; + + static ArcBluetoothBridgeFactory* GetInstance() { + return base::Singleton<ArcBluetoothBridgeFactory>::get(); + } + + private: + friend base::DefaultSingletonTraits<ArcBluetoothBridgeFactory>; + ArcBluetoothBridgeFactory() = default; + ~ArcBluetoothBridgeFactory() override = default; +}; + +} // namespace + +// static +ArcBluetoothBridge* ArcBluetoothBridge::GetForBrowserContext( + content::BrowserContext* context) { + return ArcBluetoothBridgeFactory::GetForBrowserContext(context); +} + +ArcBluetoothBridge::ArcBluetoothBridge(content::BrowserContext* context, + ArcBridgeService* bridge_service) + : arc_bridge_service_(bridge_service), binding_(this), weak_factory_(this) { + arc_bridge_service_->bluetooth()->AddObserver(this); + if (BluetoothAdapterFactory::IsBluetoothSupported()) { VLOG(1) << "Registering bluetooth adapter."; BluetoothAdapterFactory::GetAdapter(base::Bind( @@ -258,16 +291,20 @@ } else { VLOG(1) << "Bluetooth not supported."; } - arc_bridge_service()->bluetooth()->AddObserver(this); } ArcBluetoothBridge::~ArcBluetoothBridge() { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); - arc_bridge_service()->bluetooth()->RemoveObserver(this); - if (bluetooth_adapter_) bluetooth_adapter_->RemoveObserver(this); + + // TODO(hidehiko): Currently, the lifetime of ArcBridgeService and + // BrowserContextKeyedService is not nested. + // If ArcServiceManager::Get() returns nullptr, it is already destructed, + // so do not touch it. + if (ArcServiceManager::Get()) + arc_bridge_service_->bluetooth()->RemoveObserver(this); } void ArcBluetoothBridge::OnAdapterInitialized( @@ -283,14 +320,14 @@ // register ourselves as an observer with it then. Since our adapter is // ready, we should register it now. if (!bluetooth_adapter_->HasObserver(this) && - arc_bridge_service()->bluetooth()->has_instance()) { + arc_bridge_service_->bluetooth()->has_instance()) { bluetooth_adapter_->AddObserver(this); } } void ArcBluetoothBridge::OnInstanceReady() { mojom::BluetoothInstance* bluetooth_instance = - ARC_GET_INSTANCE_FOR_METHOD(arc_bridge_service()->bluetooth(), Init); + ARC_GET_INSTANCE_FOR_METHOD(arc_bridge_service_->bluetooth(), Init); DCHECK(bluetooth_instance); mojom::BluetoothHostPtr host_proxy; @@ -311,7 +348,7 @@ void ArcBluetoothBridge::SendDevice(const BluetoothDevice* device) const { auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD( - arc_bridge_service()->bluetooth(), OnDeviceFound); + arc_bridge_service_->bluetooth(), OnDeviceFound); if (!bluetooth_instance) return; @@ -333,7 +370,7 @@ // 1) Cached found device and 2) rssi became invalid when we stop scanning. if (rssi.has_value()) { auto* btle_instance = ARC_GET_INSTANCE_FOR_METHOD( - arc_bridge_service()->bluetooth(), OnLEDeviceFound); + arc_bridge_service_->bluetooth(), OnLEDeviceFound); if (!btle_instance) return; std::vector<mojom::BluetoothAdvertisingDataPtr> adv_data = @@ -396,7 +433,7 @@ gatt_connection_cache_.insert(device->GetAddress()); auto* btle_instance = ARC_GET_INSTANCE_FOR_METHOD( - arc_bridge_service()->bluetooth(), OnLEDeviceAddressChange); + arc_bridge_service_->bluetooth(), OnLEDeviceAddressChange); if (!btle_instance) return; @@ -463,7 +500,7 @@ void ArcBluetoothBridge::GattServicesDiscovered(BluetoothAdapter* adapter, BluetoothDevice* device) { auto* btle_instance = ARC_GET_INSTANCE_FOR_METHOD( - arc_bridge_service()->bluetooth(), OnSearchComplete); + arc_bridge_service_->bluetooth(), OnSearchComplete); if (!btle_instance) return; @@ -515,7 +552,7 @@ BluetoothRemoteGattCharacteristic* characteristic, const std::vector<uint8_t>& value) { auto* btle_instance = ARC_GET_INSTANCE_FOR_METHOD( - arc_bridge_service()->bluetooth(), OnGattNotify); + arc_bridge_service_->bluetooth(), OnGattNotify); if (!btle_instance) return; @@ -554,7 +591,7 @@ const ErrorCallback& error_callback) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD( - arc_bridge_service()->bluetooth(), RequestGattRead); + arc_bridge_service_->bluetooth(), RequestGattRead); if (!bluetooth_instance || !IsGattOffsetValid(offset)) { error_callback.Run(); return; @@ -578,7 +615,7 @@ const ErrorCallback& error_callback) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD( - arc_bridge_service()->bluetooth(), RequestGattWrite); + arc_bridge_service_->bluetooth(), RequestGattWrite); if (!bluetooth_instance || !IsGattOffsetValid(offset)) { error_callback.Run(); return; @@ -669,7 +706,7 @@ void ArcBluetoothBridge::GetAdapterProperty(mojom::BluetoothPropertyType type) { DCHECK(bluetooth_adapter_); auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD( - arc_bridge_service()->bluetooth(), OnAdapterProperties); + arc_bridge_service_->bluetooth(), OnAdapterProperties); if (!bluetooth_instance) return; @@ -734,7 +771,7 @@ mojom::BluetoothStatus status, mojom::BluetoothPropertyPtr property) { auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD( - arc_bridge_service()->bluetooth(), OnAdapterProperties); + arc_bridge_service_->bluetooth(), OnAdapterProperties); DCHECK(bluetooth_instance); std::vector<arc::mojom::BluetoothPropertyPtr> properties; @@ -787,7 +824,7 @@ mojom::BluetoothPropertyType type) { DCHECK(bluetooth_adapter_); auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD( - arc_bridge_service()->bluetooth(), OnRemoteDeviceProperties); + arc_bridge_service_->bluetooth(), OnRemoteDeviceProperties); if (!bluetooth_instance) return; @@ -812,7 +849,7 @@ mojom::BluetoothPropertyPtr property) { DCHECK(bluetooth_adapter_); auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD( - arc_bridge_service()->bluetooth(), OnRemoteDeviceProperties); + arc_bridge_service_->bluetooth(), OnRemoteDeviceProperties); if (!bluetooth_instance) return; @@ -890,7 +927,7 @@ DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD( - arc_bridge_service()->bluetooth(), OnDiscoveryStateChanged); + arc_bridge_service_->bluetooth(), OnDiscoveryStateChanged); if (!bluetooth_instance) return; @@ -911,7 +948,7 @@ void ArcBluetoothBridge::OnDiscoveryStopped() { auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD( - arc_bridge_service()->bluetooth(), OnDiscoveryStateChanged); + arc_bridge_service_->bluetooth(), OnDiscoveryStateChanged); if (!bluetooth_instance) return; @@ -1025,7 +1062,7 @@ mojom::BluetoothAddressPtr addr, bool connected) const { auto* btle_instance = ARC_GET_INSTANCE_FOR_METHOD( - arc_bridge_service()->bluetooth(), OnLEConnectionStateChange); + arc_bridge_service_->bluetooth(), OnLEConnectionStateChange); if (!btle_instance) return; @@ -1065,7 +1102,7 @@ void ArcBluetoothBridge::ConnectLEDevice( mojom::BluetoothAddressPtr remote_addr) { auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD( - arc_bridge_service()->bluetooth(), OnLEConnectionStateChange); + arc_bridge_service_->bluetooth(), OnLEConnectionStateChange); if (!bluetooth_instance) return; @@ -1097,7 +1134,7 @@ void ArcBluetoothBridge::DisconnectLEDevice( mojom::BluetoothAddressPtr remote_addr) { auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD( - arc_bridge_service()->bluetooth(), OnLEConnectionStateChange); + arc_bridge_service_->bluetooth(), OnLEConnectionStateChange); if (!bluetooth_instance) return; @@ -1120,7 +1157,7 @@ void ArcBluetoothBridge::SearchService(mojom::BluetoothAddressPtr remote_addr) { auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD( - arc_bridge_service()->bluetooth(), OnSearchComplete); + arc_bridge_service_->bluetooth(), OnSearchComplete); if (!bluetooth_instance) return; @@ -1202,7 +1239,7 @@ void ArcBluetoothBridge::GetGattDB(mojom::BluetoothAddressPtr remote_addr) { auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD( - arc_bridge_service()->bluetooth(), OnGetGattDB); + arc_bridge_service_->bluetooth(), OnGetGattDB); if (!bluetooth_instance) return; @@ -1786,7 +1823,7 @@ void ArcBluetoothBridge::OnPairing(mojom::BluetoothAddressPtr addr) const { auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD( - arc_bridge_service()->bluetooth(), OnBondStateChanged); + arc_bridge_service_->bluetooth(), OnBondStateChanged); if (!bluetooth_instance) return; @@ -1797,7 +1834,7 @@ void ArcBluetoothBridge::OnPairedDone(mojom::BluetoothAddressPtr addr) const { auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD( - arc_bridge_service()->bluetooth(), OnBondStateChanged); + arc_bridge_service_->bluetooth(), OnBondStateChanged); if (!bluetooth_instance) return; @@ -1810,7 +1847,7 @@ mojom::BluetoothAddressPtr addr, BluetoothDevice::ConnectErrorCode error_code) const { auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD( - arc_bridge_service()->bluetooth(), OnBondStateChanged); + arc_bridge_service_->bluetooth(), OnBondStateChanged); if (!bluetooth_instance) return; @@ -1821,7 +1858,7 @@ void ArcBluetoothBridge::OnForgetDone(mojom::BluetoothAddressPtr addr) const { auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD( - arc_bridge_service()->bluetooth(), OnBondStateChanged); + arc_bridge_service_->bluetooth(), OnBondStateChanged); if (!bluetooth_instance) return; @@ -1832,7 +1869,7 @@ void ArcBluetoothBridge::OnForgetError(mojom::BluetoothAddressPtr addr) const { auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD( - arc_bridge_service()->bluetooth(), OnBondStateChanged); + arc_bridge_service_->bluetooth(), OnBondStateChanged); if (!bluetooth_instance) return; @@ -2127,7 +2164,7 @@ const BluetoothUUID& target_uuid, const std::vector<bluez::BluetoothServiceRecordBlueZ>& records_bluez) { auto* sdp_bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD( - arc_bridge_service()->bluetooth(), OnGetSdpRecords); + arc_bridge_service_->bluetooth(), OnGetSdpRecords); if (!sdp_bluetooth_instance) return; @@ -2145,7 +2182,7 @@ const BluetoothUUID& target_uuid, bluez::BluetoothServiceRecordBlueZ::ErrorCode error_code) { auto* sdp_bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD( - arc_bridge_service()->bluetooth(), OnGetSdpRecords); + arc_bridge_service_->bluetooth(), OnGetSdpRecords); if (!sdp_bluetooth_instance) return;
diff --git a/components/arc/bluetooth/arc_bluetooth_bridge.h b/components/arc/bluetooth/arc_bluetooth_bridge.h index 2ca3f152..68936c0 100644 --- a/components/arc/bluetooth/arc_bluetooth_bridge.h +++ b/components/arc/bluetooth/arc_bluetooth_bridge.h
@@ -16,9 +16,9 @@ #include "base/callback.h" #include "base/timer/timer.h" -#include "components/arc/arc_service.h" #include "components/arc/common/bluetooth.mojom.h" #include "components/arc/instance_holder.h" +#include "components/keyed_service/core/keyed_service.h" #include "device/bluetooth/bluetooth_adapter.h" #include "device/bluetooth/bluetooth_adapter_factory.h" #include "device/bluetooth/bluetooth_advertisement.h" @@ -31,19 +31,29 @@ #include "device/bluetooth/bluez/bluetooth_adapter_bluez.h" #include "mojo/public/cpp/bindings/binding.h" +namespace content { +class BrowserContext; +} // namespace content + namespace arc { class ArcBridgeService; class ArcBluetoothBridge - : public ArcService, + : public KeyedService, public InstanceHolder<mojom::BluetoothInstance>::Observer, public device::BluetoothAdapter::Observer, public device::BluetoothAdapterFactory::AdapterCallback, public device::BluetoothLocalGattService::Delegate, public mojom::BluetoothHost { public: - explicit ArcBluetoothBridge(ArcBridgeService* bridge_service); + // Returns singleton instance for the given BrowserContext, + // or nullptr if the browser |context| is not allowed to use ARC. + static ArcBluetoothBridge* GetForBrowserContext( + content::BrowserContext* context); + + ArcBluetoothBridge(content::BrowserContext* context, + ArcBridgeService* bridge_service); ~ArcBluetoothBridge() override; // Overridden from InstanceHolder<mojom::BluetoothInstance>::Observer: @@ -430,6 +440,8 @@ void SendDevice(const device::BluetoothDevice* device) const; + ArcBridgeService* const arc_bridge_service_; // Owned by ArcServiceManager. + mojo::Binding<mojom::BluetoothHost> binding_; scoped_refptr<bluez::BluetoothAdapterBlueZ> bluetooth_adapter_;
diff --git a/components/arc/bluetooth/arc_bluetooth_bridge_unittest.cc b/components/arc/bluetooth/arc_bluetooth_bridge_unittest.cc index 400eaa8..492541c5 100644 --- a/components/arc/bluetooth/arc_bluetooth_bridge_unittest.cc +++ b/components/arc/bluetooth/arc_bluetooth_bridge_unittest.cc
@@ -93,8 +93,9 @@ fake_bluetooth_instance_ = base::MakeUnique<FakeBluetoothInstance>(); arc_bridge_service_->bluetooth()->SetInstance( fake_bluetooth_instance_.get(), 2); - arc_bluetooth_bridge_ = - base::MakeUnique<ArcBluetoothBridge>(arc_bridge_service_.get()); + // TODO(hidehiko): Use Singleton instance tied to BrowserContext. + arc_bluetooth_bridge_ = base::MakeUnique<ArcBluetoothBridge>( + nullptr, arc_bridge_service_.get()); device::BluetoothAdapterFactory::GetAdapter(base::Bind( &ArcBluetoothBridgeTest::OnAdapterInitialized, base::Unretained(this)));
diff --git a/components/arc/clipboard/arc_clipboard_bridge.cc b/components/arc/clipboard/arc_clipboard_bridge.cc index 807e033..40f5932a 100644 --- a/components/arc/clipboard/arc_clipboard_bridge.cc +++ b/components/arc/clipboard/arc_clipboard_bridge.cc
@@ -4,29 +4,68 @@ #include "components/arc/clipboard/arc_clipboard_bridge.h" +#include <utility> + #include "base/logging.h" +#include "base/memory/singleton.h" #include "base/strings/utf_string_conversions.h" #include "base/threading/thread_checker.h" #include "components/arc/arc_bridge_service.h" +#include "components/arc/arc_browser_context_keyed_service_factory_base.h" #include "ui/base/clipboard/clipboard.h" #include "ui/base/clipboard/clipboard_types.h" #include "ui/base/clipboard/scoped_clipboard_writer.h" namespace arc { +namespace { -ArcClipboardBridge::ArcClipboardBridge(ArcBridgeService* bridge_service) - : ArcService(bridge_service), binding_(this) { - arc_bridge_service()->clipboard()->AddObserver(this); +// Singleton factory for ArcClipboardBridge. +class ArcClipboardBridgeFactory + : public internal::ArcBrowserContextKeyedServiceFactoryBase< + ArcClipboardBridge, + ArcClipboardBridgeFactory> { + public: + // Factory name used by ArcBrowserContextKeyedServiceFactoryBase. + static constexpr const char* kName = "ArcClipboardBridgeFactory"; + + static ArcClipboardBridgeFactory* GetInstance() { + return base::Singleton<ArcClipboardBridgeFactory>::get(); + } + + private: + friend base::DefaultSingletonTraits<ArcClipboardBridgeFactory>; + ArcClipboardBridgeFactory() = default; + ~ArcClipboardBridgeFactory() override = default; +}; + +} // namespace + +// static +ArcClipboardBridge* ArcClipboardBridge::GetForBrowserContext( + content::BrowserContext* context) { + return ArcClipboardBridgeFactory::GetForBrowserContext(context); +} + +ArcClipboardBridge::ArcClipboardBridge(content::BrowserContext* context, + ArcBridgeService* bridge_service) + : arc_bridge_service_(bridge_service), binding_(this) { + arc_bridge_service_->clipboard()->AddObserver(this); } ArcClipboardBridge::~ArcClipboardBridge() { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); - arc_bridge_service()->clipboard()->RemoveObserver(this); + + // TODO(hidehiko): Currently, the lifetime of ArcBridgeService and + // BrowserContextKeyedService is not nested. + // If ArcServiceManager::Get() returns nullptr, it is already destructed, + // so do not touch it. + if (ArcServiceManager::Get()) + arc_bridge_service_->clipboard()->RemoveObserver(this); } void ArcClipboardBridge::OnInstanceReady() { mojom::ClipboardInstance* clipboard_instance = - ARC_GET_INSTANCE_FOR_METHOD(arc_bridge_service()->clipboard(), Init); + ARC_GET_INSTANCE_FOR_METHOD(arc_bridge_service_->clipboard(), Init); DCHECK(clipboard_instance); mojom::ClipboardHostPtr host_proxy; binding_.Bind(mojo::MakeRequest(&host_proxy)); @@ -47,7 +86,7 @@ clipboard->ReadText(ui::CLIPBOARD_TYPE_COPY_PASTE, &text); mojom::ClipboardInstance* clipboard_instance = ARC_GET_INSTANCE_FOR_METHOD( - arc_bridge_service()->clipboard(), OnGetTextContent); + arc_bridge_service_->clipboard(), OnGetTextContent); if (!clipboard_instance) return; clipboard_instance->OnGetTextContent(base::UTF16ToUTF8(text));
diff --git a/components/arc/clipboard/arc_clipboard_bridge.h b/components/arc/clipboard/arc_clipboard_bridge.h index 56bf10f..4ac2e4d 100644 --- a/components/arc/clipboard/arc_clipboard_bridge.h +++ b/components/arc/clipboard/arc_clipboard_bridge.h
@@ -8,19 +8,31 @@ #include <string> #include "base/macros.h" -#include "components/arc/arc_service.h" #include "components/arc/common/clipboard.mojom.h" #include "components/arc/instance_holder.h" +#include "components/keyed_service/core/keyed_service.h" #include "mojo/public/cpp/bindings/binding.h" +namespace content { +class BrowserContext; +} // namespace content + namespace arc { +class ArcBridgeService; + class ArcClipboardBridge - : public ArcService, + : public KeyedService, public InstanceHolder<mojom::ClipboardInstance>::Observer, public mojom::ClipboardHost { public: - explicit ArcClipboardBridge(ArcBridgeService* bridge_service); + // Returns singleton instance for the given BrowserContext, + // or nullptr if the browser |context| is not allowed to use ARC. + static ArcClipboardBridge* GetForBrowserContext( + content::BrowserContext* context); + + ArcClipboardBridge(content::BrowserContext* context, + ArcBridgeService* bridge_service); ~ArcClipboardBridge() override; // InstanceHolder<mojom::ClipboardInstance>::Observer overrides. @@ -33,6 +45,7 @@ private: THREAD_CHECKER(thread_checker_); + ArcBridgeService* const arc_bridge_service_; // Owned by ArcServiceManager. mojo::Binding<mojom::ClipboardHost> binding_; DISALLOW_COPY_AND_ASSIGN(ArcClipboardBridge);
diff --git a/components/viz/service/BUILD.gn b/components/viz/service/BUILD.gn index 27e8d2cd..07c5b3b 100644 --- a/components/viz/service/BUILD.gn +++ b/components/viz/service/BUILD.gn
@@ -53,6 +53,9 @@ "frame_sinks/gpu_root_compositor_frame_sink.h", "frame_sinks/primary_begin_frame_source.cc", "frame_sinks/primary_begin_frame_source.h", + "frame_sinks/surface_resource_holder.cc", + "frame_sinks/surface_resource_holder.h", + "frame_sinks/surface_resource_holder_client.h", "hit_test/hit_test_aggregator.cc", "hit_test/hit_test_aggregator.h", "viz_service_export.h",
diff --git a/components/viz/service/frame_sinks/compositor_frame_sink_support.h b/components/viz/service/frame_sinks/compositor_frame_sink_support.h index b77fa99..650e467 100644 --- a/components/viz/service/frame_sinks/compositor_frame_sink_support.h +++ b/components/viz/service/frame_sinks/compositor_frame_sink_support.h
@@ -16,10 +16,10 @@ #include "cc/scheduler/begin_frame_source.h" #include "cc/surfaces/referenced_surface_tracker.h" #include "cc/surfaces/surface_client.h" -#include "cc/surfaces/surface_resource_holder.h" -#include "cc/surfaces/surface_resource_holder_client.h" #include "components/viz/common/surfaces/surface_info.h" #include "components/viz/service/frame_sinks/frame_sink_manager_client.h" +#include "components/viz/service/frame_sinks/surface_resource_holder.h" +#include "components/viz/service/frame_sinks/surface_resource_holder_client.h" #include "components/viz/service/viz_service_export.h" namespace cc { @@ -34,7 +34,7 @@ class VIZ_SERVICE_EXPORT CompositorFrameSinkSupport : public cc::BeginFrameObserver, - public cc::SurfaceResourceHolderClient, + public SurfaceResourceHolderClient, public FrameSinkManagerClient, public cc::SurfaceClient { public: @@ -125,7 +125,7 @@ // added. This will not contain a value if |is_root_| is false. base::Optional<LocalSurfaceId> referenced_local_surface_id_; - cc::SurfaceResourceHolder surface_resource_holder_; + SurfaceResourceHolder surface_resource_holder_; // Counts the number of CompositorFrames that have been submitted and have not // yet received an ACK.
diff --git a/cc/surfaces/surface_resource_holder.cc b/components/viz/service/frame_sinks/surface_resource_holder.cc similarity index 61% rename from cc/surfaces/surface_resource_holder.cc rename to components/viz/service/frame_sinks/surface_resource_holder.cc index bbcd0cf..63d5d4e0 100644 --- a/cc/surfaces/surface_resource_holder.cc +++ b/components/viz/service/frame_sinks/surface_resource_holder.cc
@@ -2,10 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "cc/surfaces/surface_resource_holder.h" +#include "components/viz/service/frame_sinks/surface_resource_holder.h" -#include "cc/surfaces/surface_resource_holder_client.h" -namespace cc { +#include "components/viz/service/frame_sinks/surface_resource_holder_client.h" + +namespace viz { SurfaceResourceHolder::SurfaceResourceHolder( SurfaceResourceHolderClient* client) @@ -21,7 +22,7 @@ } void SurfaceResourceHolder::ReceiveFromChild( - const std::vector<TransferableResource>& resources) { + const std::vector<cc::TransferableResource>& resources) { for (const auto& resource : resources) { ResourceRefs& ref = resource_id_info_map_[resource.id]; ref.refs_holding_resource_alive++; @@ -30,33 +31,32 @@ } void SurfaceResourceHolder::RefResources( - const std::vector<TransferableResource>& resources) { - for (std::vector<TransferableResource>::const_iterator it = resources.begin(); - it != resources.end(); ++it) { - ResourceIdInfoMap::iterator count_it = resource_id_info_map_.find(it->id); + const std::vector<cc::TransferableResource>& resources) { + for (const auto& resource : resources) { + ResourceIdInfoMap::iterator count_it = + resource_id_info_map_.find(resource.id); DCHECK(count_it != resource_id_info_map_.end()); count_it->second.refs_holding_resource_alive++; } } void SurfaceResourceHolder::UnrefResources( - const std::vector<ReturnedResource>& resources) { - std::vector<ReturnedResource> resources_available_to_return; + const std::vector<cc::ReturnedResource>& resources) { + std::vector<cc::ReturnedResource> resources_available_to_return; - for (std::vector<ReturnedResource>::const_iterator it = resources.begin(); - it != resources.end(); ++it) { - unsigned id = it->id; - ResourceIdInfoMap::iterator count_it = resource_id_info_map_.find(id); + for (const auto& resource : resources) { + ResourceIdInfoMap::iterator count_it = + resource_id_info_map_.find(resource.id); if (count_it == resource_id_info_map_.end()) continue; ResourceRefs& ref = count_it->second; - ref.refs_holding_resource_alive -= it->count; + ref.refs_holding_resource_alive -= resource.count; // Keep the newest return sync token that has data. // TODO(jbauman): Handle the case with two valid sync tokens. - if (it->sync_token.HasData()) - ref.sync_token = it->sync_token; + if (resource.sync_token.HasData()) + ref.sync_token = resource.sync_token; if (ref.refs_holding_resource_alive == 0) { - ReturnedResource returned = *it; + cc::ReturnedResource returned = resource; returned.sync_token = ref.sync_token; returned.count = ref.refs_received_from_child; resources_available_to_return.push_back(returned); @@ -67,4 +67,4 @@ client_->ReturnResources(resources_available_to_return); } -} // namespace cc +} // namespace viz
diff --git a/cc/surfaces/surface_resource_holder.h b/components/viz/service/frame_sinks/surface_resource_holder.h similarity index 67% rename from cc/surfaces/surface_resource_holder.h rename to components/viz/service/frame_sinks/surface_resource_holder.h index c96d4e5..33aed9a 100644 --- a/cc/surfaces/surface_resource_holder.h +++ b/components/viz/service/frame_sinks/surface_resource_holder.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CC_SURFACES_SURFACE_RESOURCE_HOLDER_H_ -#define CC_SURFACES_SURFACE_RESOURCE_HOLDER_H_ +#ifndef COMPONENTS_VIZ_SERVICE_FRAME_SINKS_SURFACE_RESOURCE_HOLDER_H_ +#define COMPONENTS_VIZ_SERVICE_FRAME_SINKS_SURFACE_RESOURCE_HOLDER_H_ #include <unordered_map> @@ -11,24 +11,24 @@ #include "cc/base/resource_id.h" #include "cc/resources/returned_resource.h" #include "cc/resources/transferable_resource.h" -#include "cc/surfaces/surfaces_export.h" +#include "components/viz/service/viz_service_export.h" -namespace cc { +namespace viz { class SurfaceResourceHolderClient; // A SurfaceResourceHolder manages the lifetime of resources submitted by a // particular SurfaceFactory. Each resource is held by the service until // it is no longer referenced by any pending frames or by any // resource providers. -class CC_SURFACES_EXPORT SurfaceResourceHolder { +class VIZ_SERVICE_EXPORT SurfaceResourceHolder { public: explicit SurfaceResourceHolder(SurfaceResourceHolderClient* client); ~SurfaceResourceHolder(); void Reset(); - void ReceiveFromChild(const std::vector<TransferableResource>& resources); - void RefResources(const std::vector<TransferableResource>& resources); - void UnrefResources(const std::vector<ReturnedResource>& resources); + void ReceiveFromChild(const std::vector<cc::TransferableResource>& resources); + void RefResources(const std::vector<cc::TransferableResource>& resources); + void UnrefResources(const std::vector<cc::ReturnedResource>& resources); private: SurfaceResourceHolderClient* client_; @@ -44,12 +44,12 @@ // ID we've received from the client. When this counter hits zero for a // particular resource, that ID is available to return to the client with // the most recently given non-empty sync token. - using ResourceIdInfoMap = std::unordered_map<ResourceId, ResourceRefs>; + using ResourceIdInfoMap = std::unordered_map<cc::ResourceId, ResourceRefs>; ResourceIdInfoMap resource_id_info_map_; DISALLOW_COPY_AND_ASSIGN(SurfaceResourceHolder); }; -} // namespace cc +} // namespace viz -#endif // CC_SURFACES_SURFACE_RESOURCE_HOLDER_H_ +#endif // COMPONENTS_VIZ_SERVICE_FRAME_SINKS_SURFACE_RESOURCE_HOLDER_H_
diff --git a/components/viz/service/frame_sinks/surface_resource_holder_client.h b/components/viz/service/frame_sinks/surface_resource_holder_client.h new file mode 100644 index 0000000..31b56e1 --- /dev/null +++ b/components/viz/service/frame_sinks/surface_resource_holder_client.h
@@ -0,0 +1,25 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_VIZ_SERVICE_FRAME_SINKS_SURFACE_RESOURCE_HOLDER_CLIENT_H_ +#define COMPONENTS_VIZ_SERVICE_FRAME_SINKS_SURFACE_RESOURCE_HOLDER_CLIENT_H_ + +#include "cc/resources/returned_resource.h" +#include "components/viz/service/viz_service_export.h" + +namespace viz { + +class VIZ_SERVICE_EXPORT SurfaceResourceHolderClient { + public: + virtual ~SurfaceResourceHolderClient() = default; + + // ReturnResources gets called when the display compositor is done using the + // resources so that the client can use them. + virtual void ReturnResources( + const std::vector<cc::ReturnedResource>& resources) = 0; +}; + +} // namespace viz + +#endif // COMPONENTS_VIZ_SERVICE_FRAME_SINKS_SURFACE_RESOURCE_HOLDER_CLIENT_H_
diff --git a/third_party/WebKit/Source/core/url/OWNERS b/third_party/WebKit/Source/core/url/OWNERS new file mode 100644 index 0000000..62a6417 --- /dev/null +++ b/third_party/WebKit/Source/core/url/OWNERS
@@ -0,0 +1,6 @@ +mkwst@chromium.org +sigbjornf@opera.com +tyoshino@chromium.org + +# TEAM: blink-network-dev@chromium.org +# COMPONENT: Blink>Network
diff --git a/third_party/WebKit/Source/core/url/README.md b/third_party/WebKit/Source/core/url/README.md new file mode 100644 index 0000000..440f7498 --- /dev/null +++ b/third_party/WebKit/Source/core/url/README.md
@@ -0,0 +1,14 @@ +# core/url/ + +This directory contains: +- [the URL and URLSearchParams API][1] implementation +- the utility for [Location][2], [WorkerLocation][3] and [the a and area element][4] to implement URL operations +- the object URL methods for [Blob][5], [Media Source Extensions][6] and [Media Capture and Streams][7] + +[1]: https://url.spec.whatwg.org/ +[2]: https://html.spec.whatwg.org/multipage/history.html#the-location-interface +[3]: https://html.spec.whatwg.org/multipage/workers.html#worker-locations +[4]: https://html.spec.whatwg.org/multipage/links.html#api-for-a-and-area-elements +[5]: https://w3c.github.io/FileAPI/#dfn-createObjectURL +[6]: http://w3c.github.io/media-source/#dom-url-createobjecturl +[7]: https://w3c.github.io/mediacapture-main/
diff --git a/third_party/WebKit/Source/core/url/URLUtilsReadOnly.idl b/third_party/WebKit/Source/core/url/URLUtilsReadOnly.idl index ed0d9a8..4b15bf8 100644 --- a/third_party/WebKit/Source/core/url/URLUtilsReadOnly.idl +++ b/third_party/WebKit/Source/core/url/URLUtilsReadOnly.idl
@@ -23,7 +23,10 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -// https://url.spec.whatwg.org/#urlutilsreadonly +// This interface was defined independently in the WHATWG URL spec, but has +// been removed from it in +// https://github.com/whatwg/url/commit/c2877946857bc904ecb8a5805abc423c82d9da98. +// It's now inlined in the users. See crbug.com/699873. [ NoInterfaceObject, // Always used on target of 'implements'
diff --git a/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp b/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp index 690f17cc..4d2efab 100644 --- a/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp +++ b/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp
@@ -102,11 +102,75 @@ int* const level_; }; +// These methods were placed in HTTPParsers.h. Since these methods don't +// perform ABNF validation but loosely look for the part that is likely to be +// indicating the charset parameter, new code should use +// HttpUtil::ParseContentType() than these. To discourage use of these methods, +// moved from HTTPParser.h to the only user XMLHttpRequest.cpp. +// +// TODO(tyoshino): Switch XHR to use HttpUtil. See crbug.com/743311. +void FindCharsetInMediaType(const String& media_type, + unsigned& charset_pos, + unsigned& charset_len, + unsigned start) { + charset_pos = start; + charset_len = 0; + + size_t pos = start; + unsigned length = media_type.length(); + + while (pos < length) { + pos = media_type.FindIgnoringASCIICase("charset", pos); + if (pos == kNotFound || !pos) { + charset_len = 0; + return; + } + + // is what we found a beginning of a word? + if (media_type[pos - 1] > ' ' && media_type[pos - 1] != ';') { + pos += 7; + continue; + } + + pos += 7; + + // skip whitespace + while (pos != length && media_type[pos] <= ' ') + ++pos; + + // this "charset" substring wasn't a parameter + // name, but there may be others + if (media_type[pos++] != '=') + continue; + + while (pos != length && (media_type[pos] <= ' ' || media_type[pos] == '"' || + media_type[pos] == '\'')) + ++pos; + + // we don't handle spaces within quoted parameter values, because charset + // names cannot have any + unsigned endpos = pos; + while (pos != length && media_type[endpos] > ' ' && + media_type[endpos] != '"' && media_type[endpos] != '\'' && + media_type[endpos] != ';') + ++endpos; + + charset_pos = pos; + charset_len = endpos - pos; + return; + } +} +String ExtractCharsetFromMediaType(const String& media_type) { + unsigned pos, len; + FindCharsetInMediaType(media_type, pos, len, 0); + return media_type.Substring(pos, len); +} + void ReplaceCharsetInMediaType(String& media_type, const String& charset_value) { unsigned pos = 0, len = 0; - FindCharsetInMediaType(media_type, pos, len); + FindCharsetInMediaType(media_type, pos, len, 0); if (!len) { // When no charset found, do nothing.
diff --git a/third_party/WebKit/Source/platform/network/HTTPParsers.cpp b/third_party/WebKit/Source/platform/network/HTTPParsers.cpp index e7861e1..22aeb1b 100644 --- a/third_party/WebKit/Source/platform/network/HTTPParsers.cpp +++ b/third_party/WebKit/Source/platform/network/HTTPParsers.cpp
@@ -362,64 +362,6 @@ media_type.GetString().Substring(type_start, type_end - type_start)); } -String ExtractCharsetFromMediaType(const String& media_type) { - unsigned pos, len; - FindCharsetInMediaType(media_type, pos, len); - return media_type.Substring(pos, len); -} - -void FindCharsetInMediaType(const String& media_type, - unsigned& charset_pos, - unsigned& charset_len, - unsigned start) { - charset_pos = start; - charset_len = 0; - - size_t pos = start; - unsigned length = media_type.length(); - - while (pos < length) { - pos = media_type.FindIgnoringASCIICase("charset", pos); - if (pos == kNotFound || !pos) { - charset_len = 0; - return; - } - - // is what we found a beginning of a word? - if (media_type[pos - 1] > ' ' && media_type[pos - 1] != ';') { - pos += 7; - continue; - } - - pos += 7; - - // skip whitespace - while (pos != length && media_type[pos] <= ' ') - ++pos; - - if (media_type[pos++] != - '=') // this "charset" substring wasn't a parameter - // name, but there may be others - continue; - - while (pos != length && (media_type[pos] <= ' ' || media_type[pos] == '"' || - media_type[pos] == '\'')) - ++pos; - - // we don't handle spaces within quoted parameter values, because charset - // names cannot have any - unsigned endpos = pos; - while (pos != length && media_type[endpos] > ' ' && - media_type[endpos] != '"' && media_type[endpos] != '\'' && - media_type[endpos] != ';') - ++endpos; - - charset_pos = pos; - charset_len = endpos - pos; - return; - } -} - ReflectedXSSDisposition ParseXSSProtectionHeader(const String& header, String& failure_reason, unsigned& failure_position,
diff --git a/third_party/WebKit/Source/platform/network/HTTPParsers.h b/third_party/WebKit/Source/platform/network/HTTPParsers.h index 40fee8b..b52261c 100644 --- a/third_party/WebKit/Source/platform/network/HTTPParsers.h +++ b/third_party/WebKit/Source/platform/network/HTTPParsers.h
@@ -121,11 +121,7 @@ // - OWSes at the head and the tail of the region before the first semicolon // are trimmed. PLATFORM_EXPORT AtomicString ExtractMIMETypeFromMediaType(const AtomicString&); -PLATFORM_EXPORT String ExtractCharsetFromMediaType(const String&); -PLATFORM_EXPORT void FindCharsetInMediaType(const String& media_type, - unsigned& charset_pos, - unsigned& charset_len, - unsigned start = 0); + PLATFORM_EXPORT ReflectedXSSDisposition ParseXSSProtectionHeader(const String& header, String& failure_reason,
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/base.py b/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/base.py index 93446f5..93ec408 100644 --- a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/base.py +++ b/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/base.py
@@ -1066,6 +1066,7 @@ 'LD_LIBRARY_PATH', 'DBUS_SESSION_BUS_ADDRESS', 'XDG_DATA_DIRS', + 'XDG_RUNTIME_DIR' ] clean_env['DISPLAY'] = self.host.environ.get('DISPLAY', ':1') if self.host.platform.is_mac():