diff --git a/WATCHLISTS b/WATCHLISTS index 688c71c..19eb6ac 100644 --- a/WATCHLISTS +++ b/WATCHLISTS
@@ -866,6 +866,13 @@ 'version_assembly': { 'filepath': 'chrome/app/version_assembly', }, + 'video_capture': { + 'filepath': 'chrome/browser/media/.*(capture|media|webrtc)'\ + '|content/browser/renderer_host/media/.*(capture|media)'\ + '|content/renderer/media/.*(capture|media|webrtc)'\ + '|media/capture/'\ + '|media/muxers/', + }, 'views': { # Applies to all files and subdirs within this directory. 'filepath': '^ui/views/', @@ -878,6 +885,10 @@ 'chrome/test/data/chromeos/virtual_keyboard/'\ 'chrome/common/extensions/api/virtual_keyboard', }, + 'webrtc_browser_tests': { + 'filepath': 'chrome/browser/media/.*webrtc.*browsertest|'\ + 'content/browser/media/.*webrtc.*browsertest', + }, 'webrtc_media': { 'filepath': 'chrome/browser/media/|'\ 'content/browser/renderer_host/media/|'\ @@ -887,10 +898,6 @@ 'media/capture/|'\ 'video.*_accelerat', }, - 'webrtc_browser_tests': { - 'filepath': 'chrome/browser/media/.*webrtc.*browsertest|'\ - 'content/browser/media/.*webrtc.*browsertest', - }, 'website_settings': { 'filepath': 'chrome/browser/content_settings/'\ '|chrome/browser/ui/views/website_settings/'\ @@ -1158,6 +1165,18 @@ '|third_party/WebKit/Source/web/.*Quota' \ '|third_party/WebKit/public/.*Quota' }, + 'blink_mediacapturefromelement': { + 'filepath': 'third_party/WebKit/Source/modules/mediacapture/' \ + '|third_party/WebKit/Source/platform/exported/WebCanvasCapture' \ + '|third_party/WebKit/LayoutTests/fast/mediacapturefromelement/' \ + '|third_party/WebKit/public/platform/WebCanvasCapture' + }, + 'blink_mediarecorder': { + 'filepath': 'third_party/WebKit/Source/modules/mediarecorder/' \ + '|third_party/WebKit/Source/platform/exported/WebMediaRecorder' \ + '|third_party/WebKit/LayoutTests/fast/mediarecorder/' \ + '|third_party/WebKit/public/platform/WebMediaRecorder' + }, 'blink_mediastream': { 'filepath': 'third_party/WebKit/Source/modules/mediastream/' \ '|third_party/WebKit/Source/platform/mediastream/' \ @@ -1555,13 +1574,13 @@ 'glider+watch@chromium.org'], 'version_assembly': ['caitkp+watch@chromium.org', 'gab+watch@chromium.org'], + 'video_capture': ['mcasas+watch+vc@chromium.org'], 'views': ['tfarina@chromium.org'], 'virtual_keyboard': ['dfaden+virtualkb@google.com', 'groby+virtualkb@chromium.org'], - 'webrtc_media': ['mcasas+watch@chromium.org', - 'posciak+watch@chromium.org'], 'webrtc_browser_tests': ['phoglund+watch@chromium.org', 'tnakamura+watch@chromium.org'], + 'webrtc_media': ['posciak+watch@chromium.org'], 'website_settings': ['markusheintz@chromium.org', 'raymes+watch@chromium.org', 'msramek+watch@chromium.org'], @@ -1705,7 +1724,12 @@ 'blink_viewport_interaction': [ 'kenneth.christiansen@gmail.com' ], 'blink_webcomponents': [ 'webcomponents-bugzilla@chromium.org', 'dglazkov+blink@chromium.org' ], - 'blink_mediastream': [ 'tommyw+watchlist@chromium.org' ], + 'blink_mediacapturefromelement': [ 'emircan+watch+capturefromdom@chromium.org', + 'mcasas+watch+capturefromdom@chromium.org' ], + 'blink_mediarecorder': [ 'emircan+watch+mediarecorder@chromium.org', + 'mcasas+watch+mediarecorder@chromium.org' ], + 'blink_mediastream': [ 'tommyw+watchlist@chromium.org', + 'mcasas+watch+mediastream@chromium.org' ], 'blink_navigator_content_utils': [ 'gyuyoung.kim@chromium.org' ], 'blink_notifications': [ 'peter@chromium.org' ], 'blink_geolocation': [ 'mvanouwerkerk+watch@chromium.org',
diff --git a/chrome/VERSION b/chrome/VERSION index 9373f6bb..fe3f7f29b 100644 --- a/chrome/VERSION +++ b/chrome/VERSION
@@ -1,4 +1,4 @@ -MAJOR=51 +MAJOR=52 MINOR=0 -BUILD=2704 +BUILD=2705 PATCH=0
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadManagerService.java b/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadManagerService.java index 91b70a60..050bb61 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadManagerService.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadManagerService.java
@@ -1136,7 +1136,10 @@ * @param downloadGuid GUID of the download. */ void cancelDownload(String downloadGuid) { - nativeCancelDownload(getNativeDownloadManagerService(), downloadGuid); + DownloadProgress progress = mDownloadProgressMap.get(downloadGuid); + boolean isOffTheRecord = progress == null + ? false : progress.mDownloadItem.getDownloadInfo().isOffTheRecord(); + nativeCancelDownload(getNativeDownloadManagerService(), downloadGuid, isOffTheRecord); } /** @@ -1287,6 +1290,6 @@ private native void nativeResumeDownload( long nativeDownloadManagerService, String downloadGuid); private native void nativeCancelDownload( - long nativeDownloadManagerService, String downloadGuid); + long nativeDownloadManagerService, String downloadGuid, boolean isOffTheRecord); private native void nativePauseDownload(long nativeDownloadManagerService, String downloadGuid); }
diff --git a/chrome/browser/android/download/download_manager_service.cc b/chrome/browser/android/download/download_manager_service.cc index c847bf9..bdc6b05 100644 --- a/chrome/browser/android/download/download_manager_service.cc +++ b/chrome/browser/android/download/download_manager_service.cc
@@ -28,10 +28,8 @@ static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& jobj) { Profile* profile = ProfileManager::GetActiveUserProfile(); - content::DownloadManager* manager = - content::BrowserContext::GetDownloadManager(profile); DownloadManagerService* service = - new DownloadManagerService(env, jobj, manager); + new DownloadManagerService(env, jobj); DownloadService* download_service = DownloadServiceFactory::GetForBrowserContext(profile); DownloadHistory* history = download_service->GetDownloadHistory(); @@ -42,20 +40,14 @@ DownloadManagerService::DownloadManagerService( JNIEnv* env, - jobject obj, - content::DownloadManager* manager) + jobject obj) : java_ref_(env, obj), - manager_(manager), is_history_query_complete_(false) { content::DownloadControllerAndroid::Get()->SetDefaultDownloadFileName( l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME)); - manager_->AddObserver(this); } -DownloadManagerService::~DownloadManagerService() { - if (manager_) - manager_->RemoveObserver(this); -} +DownloadManagerService::~DownloadManagerService() {} void DownloadManagerService::ResumeDownload( JNIEnv* env, @@ -82,19 +74,22 @@ void DownloadManagerService::CancelDownload( JNIEnv* env, jobject obj, - const JavaParamRef<jstring>& jdownload_guid) { + const JavaParamRef<jstring>& jdownload_guid, + bool is_off_the_record) { std::string download_guid = ConvertJavaStringToUTF8(env, jdownload_guid); + // Incognito download can only be cancelled in the same browser session, no + // need to wait for download history. + if (is_off_the_record) { + CancelDownloadInternal(download_guid, true); + return; + } + if (is_history_query_complete_) - CancelDownloadInternal(download_guid); + CancelDownloadInternal(download_guid, false); else EnqueueDownloadAction(download_guid, CANCEL); } -void DownloadManagerService::ManagerGoingDown( - content::DownloadManager* manager) { - manager_ = nullptr; -} - void DownloadManagerService::OnHistoryQueryComplete() { is_history_query_complete_ = true; for (auto iter = pending_actions_.begin(); iter != pending_actions_.end(); @@ -109,7 +104,7 @@ PauseDownloadInternal(download_guid); break; case CANCEL: - CancelDownloadInternal(download_guid); + CancelDownloadInternal(download_guid, false); break; default: NOTREACHED(); @@ -121,11 +116,12 @@ void DownloadManagerService::ResumeDownloadInternal( const std::string& download_guid) { - if (!manager_) { + content::DownloadManager* manager = GetDownloadManager(false); + if (!manager) { OnResumptionFailed(download_guid); return; } - content::DownloadItem* item = manager_->GetDownloadByGuid(download_guid); + content::DownloadItem* item = manager->GetDownloadByGuid(download_guid); if (!item) { OnResumptionFailed(download_guid); return; @@ -141,10 +137,11 @@ } void DownloadManagerService::CancelDownloadInternal( - const std::string& download_guid) { - if (!manager_) + const std::string& download_guid, bool is_off_the_record) { + content::DownloadManager* manager = GetDownloadManager(is_off_the_record); + if (!manager) return; - content::DownloadItem* item = manager_->GetDownloadByGuid(download_guid); + content::DownloadItem* item = manager->GetDownloadByGuid(download_guid); if (item) { item->Cancel(true); item->RemoveObserver(content::DownloadControllerAndroid::Get()); @@ -153,9 +150,10 @@ void DownloadManagerService::PauseDownloadInternal( const std::string& download_guid) { - if (!manager_) + content::DownloadManager* manager = GetDownloadManager(false); + if (!manager) return; - content::DownloadItem* item = manager_->GetDownloadByGuid(download_guid); + content::DownloadItem* item = manager->GetDownloadByGuid(download_guid); if (item) item->Pause(); item->RemoveObserver(content::DownloadControllerAndroid::Get()); @@ -205,3 +203,11 @@ if (!resume_callback_for_testing_.is_null()) resume_callback_for_testing_.Run(false); } + +content::DownloadManager* DownloadManagerService::GetDownloadManager( + bool is_off_the_record) { + Profile* profile = ProfileManager::GetActiveUserProfile(); + if (is_off_the_record) + profile = profile->GetOffTheRecordProfile(); + return content::BrowserContext::GetDownloadManager(profile); +}
diff --git a/chrome/browser/android/download/download_manager_service.h b/chrome/browser/android/download/download_manager_service.h index 10d6205a..695d346 100644 --- a/chrome/browser/android/download/download_manager_service.h +++ b/chrome/browser/android/download/download_manager_service.h
@@ -23,15 +23,13 @@ // Native side of DownloadManagerService.java. The native object is owned by its // Java object. -class DownloadManagerService : public content::DownloadManager::Observer, - public DownloadHistory::Observer { +class DownloadManagerService : public DownloadHistory::Observer { public: // JNI registration. static bool RegisterDownloadManagerService(JNIEnv* env); DownloadManagerService(JNIEnv* env, - jobject jobj, - content::DownloadManager* manager); + jobject jobj); ~DownloadManagerService() override; // Called to resume downloading the item that has GUID equal to @@ -44,7 +42,8 @@ // If the DownloadItem is not yet created, retry after a while. void CancelDownload(JNIEnv* env, jobject obj, - const JavaParamRef<jstring>& jdownload_guid); + const JavaParamRef<jstring>& jdownload_guid, + bool is_off_the_record); // Called to pause a download item that has GUID equal to |jdownload_guid|. // If the DownloadItem is not yet created, do nothing as it is already paused. @@ -52,12 +51,13 @@ jobject obj, const JavaParamRef<jstring>& jdownload_guid); - // content::DownloadManager::Observer methods. - void ManagerGoingDown(content::DownloadManager* manager) override; - // DownloadHistory::Observer methods. void OnHistoryQueryComplete() override; + protected: + // Called to get the content::DownloadManager instance. + virtual content::DownloadManager* GetDownloadManager(bool is_off_the_record); + private: // For testing. friend class DownloadManagerServiceTest; @@ -66,7 +66,8 @@ void ResumeDownloadInternal(const std::string& download_guid); // Helper function to cancel a download. - void CancelDownloadInternal(const std::string& download_guid); + void CancelDownloadInternal(const std::string& download_guid, + bool is_off_the_record); // Helper function to pause a download. void PauseDownloadInternal(const std::string& download_guid); @@ -84,9 +85,6 @@ // Reference to the Java object. base::android::ScopedJavaGlobalRef<jobject> java_ref_; - // Download manager this class observes - content::DownloadManager* manager_; - bool is_history_query_complete_; enum DownloadAction { RESUME, PAUSE, CANCEL, UNKNOWN };
diff --git a/chrome/browser/android/download/download_manager_service_unittest.cc b/chrome/browser/android/download/download_manager_service_unittest.cc index 15325af..1201291 100644 --- a/chrome/browser/android/download/download_manager_service_unittest.cc +++ b/chrome/browser/android/download/download_manager_service_unittest.cc
@@ -27,20 +27,42 @@ struct DownloadCreateInfo; } +class MockDownloadManagerService : public DownloadManagerService { + public: + MockDownloadManagerService() + : DownloadManagerService(base::android::AttachCurrentThread(), nullptr) { + ON_CALL(manager_, GetDownloadByGuid(_)).WillByDefault( + ::testing::Invoke(this, + &MockDownloadManagerService::GetDownloadByGuid)); + } + + void CreateDownloadItem(bool can_resume) { + download_.reset(new content::MockDownloadItem()); + ON_CALL(*download_, CanResume()).WillByDefault( + ::testing::Return(can_resume)); + } + + protected: + content::DownloadItem* GetDownloadByGuid(const std::string&) { + return download_.get(); + } + + content::DownloadManager* GetDownloadManager( + bool is_off_the_record) override { + return &manager_; + } + + private: + std::unique_ptr<content::MockDownloadItem> download_; + content::MockDownloadManager manager_; +}; + class DownloadManagerServiceTest : public testing::Test { public: DownloadManagerServiceTest() - : service_( - new DownloadManagerService(base::android::AttachCurrentThread(), - nullptr, - &manager_)), + : service_(new MockDownloadManagerService()), finished_(false), - success_(false) { - ON_CALL(manager_, GetDownloadByGuid(_)) - .WillByDefault( - ::testing::Invoke(this, - &DownloadManagerServiceTest::GetDownloadByGuid)); - } + success_(false) {} void OnResumptionDone(bool success) { finished_ = true; @@ -62,21 +84,9 @@ message_loop_.RunUntilIdle(); } - void CreateDownloadItem(bool can_resume) { - download_.reset(new content::MockDownloadItem()); - ON_CALL(*download_, CanResume()) - .WillByDefault(::testing::Return(can_resume)); - } - protected: - content::DownloadItem* GetDownloadByGuid(const std::string&) { - return download_.get(); - } - base::MessageLoop message_loop_; - std::unique_ptr<content::MockDownloadItem> download_; - content::MockDownloadManager manager_; - DownloadManagerService* service_; + MockDownloadManagerService* service_; bool finished_; bool success_; @@ -86,14 +96,14 @@ // Test that resumption succeeds if the download item is found and can be // resumed. TEST_F(DownloadManagerServiceTest, ResumptionWithResumableItem) { - CreateDownloadItem(true); + service_->CreateDownloadItem(true); StartDownload("0000"); EXPECT_TRUE(success_); } // Test that resumption fails if the target download item is not resumable. TEST_F(DownloadManagerServiceTest, ResumptionWithNonResumableItem) { - CreateDownloadItem(false); + service_->CreateDownloadItem(false); StartDownload("0000"); EXPECT_FALSE(success_); }
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index 8bb7ef2..95f9b92 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc
@@ -53,6 +53,7 @@ #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_factory.h" #include "chrome/browser/notifications/platform_notification_service_impl.h" +#include "chrome/browser/password_manager/chrome_password_manager_client.h" #include "chrome/browser/permissions/permission_context_base.h" #include "chrome/browser/platform_util.h" #include "chrome/browser/prerender/prerender_final_status.h" @@ -2768,6 +2769,13 @@ base::Bind(&CreateWebUsbChooserService, render_frame_host)); } + // Register mojo CredentialManager service only for main frame. + if (!render_frame_host->GetParent()) { + registry->AddService( + base::Bind(&ChromePasswordManagerClient::BindCredentialManager, + render_frame_host)); + } + #if BUILDFLAG(ANDROID_JAVA_UI) ChromeServiceRegistrarAndroid::RegisterRenderFrameMojoServices(registry); #endif
diff --git a/chrome/browser/extensions/api/desktop_capture/desktop_capture_base.cc b/chrome/browser/extensions/api/desktop_capture/desktop_capture_base.cc index 1ff843a..8c0c170 100644 --- a/chrome/browser/extensions/api/desktop_capture/desktop_capture_base.cc +++ b/chrome/browser/extensions/api/desktop_capture/desktop_capture_base.cc
@@ -143,7 +143,7 @@ (show_windows ? DesktopMediaListAsh::WINDOWS : 0)))); } #endif - if (!media_list) { + if (media_lists.empty()) { webrtc::DesktopCaptureOptions options = webrtc::DesktopCaptureOptions::CreateDefault(); options.set_disable_effects(false);
diff --git a/chrome/browser/mac/keystone_glue.mm b/chrome/browser/mac/keystone_glue.mm index 79621ff9..e16e62f 100644 --- a/chrome/browser/mac/keystone_glue.mm +++ b/chrome/browser/mac/keystone_glue.mm
@@ -760,11 +760,11 @@ NSMutableDictionary* dictionary = [NSMutableDictionary dictionaryWithObject:statusNumber forKey:kAutoupdateStatusStatus]; - if (version) { + if ([version length]) { [dictionary setObject:version forKey:kAutoupdateStatusVersion]; } - if (error) { - [dictionary setObject:version forKey:kAutoupdateStatusErrorMessages]; + if ([error length]) { + [dictionary setObject:error forKey:kAutoupdateStatusErrorMessages]; } NSNotification* notification =
diff --git a/chrome/browser/password_manager/chrome_password_manager_client.cc b/chrome/browser/password_manager/chrome_password_manager_client.cc index 9264179..0c11394 100644 --- a/chrome/browser/password_manager/chrome_password_manager_client.cc +++ b/chrome/browser/password_manager/chrome_password_manager_client.cc
@@ -33,7 +33,6 @@ #include "components/browser_sync/browser/profile_sync_service.h" #include "components/password_manager/content/browser/content_password_manager_driver.h" #include "components/password_manager/content/browser/password_manager_internals_service_factory.h" -#include "components/password_manager/content/common/credential_manager_messages.h" #include "components/password_manager/core/browser/browser_save_password_progress_logger.h" #include "components/password_manager/core/browser/log_manager.h" #include "components/password_manager/core/browser/log_receiver.h" @@ -141,7 +140,7 @@ profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())), password_manager_(this), driver_factory_(nullptr), - credential_manager_dispatcher_(web_contents, this), + credential_manager_impl_(web_contents, this), observer_(nullptr), credentials_filter_(this, base::Bind(&GetSyncService, profile_), @@ -611,3 +610,17 @@ const { return log_manager_.get(); } + +// static +void ChromePasswordManagerClient::BindCredentialManager( + content::RenderFrameHost* render_frame_host, + password_manager::mojom::CredentialManagerRequest request) { + content::WebContents* web_contents = + content::WebContents::FromRenderFrameHost(render_frame_host); + DCHECK(web_contents); + + ChromePasswordManagerClient* instance = + ChromePasswordManagerClient::FromWebContents(web_contents); + DCHECK(instance); + instance->credential_manager_impl_.BindRequest(std::move(request)); +}
diff --git a/chrome/browser/password_manager/chrome_password_manager_client.h b/chrome/browser/password_manager/chrome_password_manager_client.h index fa85691..150d83acc 100644 --- a/chrome/browser/password_manager/chrome_password_manager_client.h +++ b/chrome/browser/password_manager/chrome_password_manager_client.h
@@ -12,7 +12,7 @@ #include "base/macros.h" #include "base/memory/scoped_vector.h" #include "components/password_manager/content/browser/content_password_manager_driver_factory.h" -#include "components/password_manager/content/browser/credential_manager_dispatcher.h" +#include "components/password_manager/content/browser/credential_manager_impl.h" #include "components/password_manager/core/browser/password_manager.h" #include "components/password_manager/core/browser/password_manager_client.h" #include "components/password_manager/sync/browser/sync_credentials_filter.h" @@ -105,6 +105,10 @@ // the sad old Infobar UI. static bool IsTheHotNewBubbleUIEnabled(); + static void BindCredentialManager( + content::RenderFrameHost* render_frame_host, + password_manager::mojom::CredentialManagerRequest request); + protected: // Callable for tests. ChromePasswordManagerClient(content::WebContents* web_contents, @@ -168,8 +172,10 @@ password_manager::ContentPasswordManagerDriverFactory* driver_factory_; - password_manager::CredentialManagerDispatcher - credential_manager_dispatcher_; + // As a mojo service, will be registered into service registry + // of the main frame host by ChromeContentBrowserClient + // once main frame host was created. + password_manager::CredentialManagerImpl credential_manager_impl_; // Observer for password generation popup. autofill::PasswordGenerationPopupObserver* observer_;
diff --git a/chrome/browser/password_manager/chrome_password_manager_client_unittest.cc b/chrome/browser/password_manager/chrome_password_manager_client_unittest.cc index 056525ff..588dc8d0 100644 --- a/chrome/browser/password_manager/chrome_password_manager_client_unittest.cc +++ b/chrome/browser/password_manager/chrome_password_manager_client_unittest.cc
@@ -20,7 +20,6 @@ #include "chrome/test/base/testing_profile.h" #include "components/autofill/content/common/autofill_messages.h" #include "components/password_manager/content/browser/password_manager_internals_service_factory.h" -#include "components/password_manager/content/common/credential_manager_messages.h" #include "components/password_manager/core/browser/credentials_filter.h" #include "components/password_manager/core/browser/log_manager.h" #include "components/password_manager/core/browser/log_receiver.h"
diff --git a/chrome/browser/ui/cocoa/media_picker/desktop_media_picker_controller.h b/chrome/browser/ui/cocoa/media_picker/desktop_media_picker_controller.h index d0ac418..fd4a575 100644 --- a/chrome/browser/ui/cocoa/media_picker/desktop_media_picker_controller.h +++ b/chrome/browser/ui/cocoa/media_picker/desktop_media_picker_controller.h
@@ -33,7 +33,9 @@ NSButton* cancelButton_; // weak; owned by contentView // The checkbox for audio share. + // |audioShareState_| records the state when check box is disabled. base::scoped_nsobject<NSButton> audioShareCheckbox_; + NSCellStateValue audioShareState_; // Provides source information (including thumbnails) to fill up |items_| and // to render in |sourceBrowser_|.
diff --git a/chrome/browser/ui/cocoa/media_picker/desktop_media_picker_controller.mm b/chrome/browser/ui/cocoa/media_picker/desktop_media_picker_controller.mm index d04274d..7c03f91 100644 --- a/chrome/browser/ui/cocoa/media_picker/desktop_media_picker_controller.mm +++ b/chrome/browser/ui/cocoa/media_picker/desktop_media_picker_controller.mm
@@ -161,6 +161,7 @@ [audioShareCheckbox_ setAutoresizingMask:NSViewMaxXMargin | NSViewMinYMargin]; [audioShareCheckbox_ setButtonType:NSSwitchButton]; + audioShareState_ = NSOnState; [audioShareCheckbox_ setTitle:l10n_util::GetNSString(IDS_DESKTOP_MEDIA_PICKER_AUDIO_SHARE)]; [audioShareCheckbox_ sizeToFit]; @@ -329,7 +330,11 @@ // On Mac, the checkbox will enabled for tab sharing, namely // TYPE_WEB_CONTENTS. if ([indexes count] == 0) { - [audioShareCheckbox_ setEnabled:NO]; + if ([audioShareCheckbox_ isEnabled]) { + [audioShareCheckbox_ setEnabled:NO]; + audioShareState_ = [audioShareCheckbox_ state]; + [audioShareCheckbox_ setState:NSOffState]; + } [audioShareCheckbox_ setToolTip:l10n_util::GetNSString( IDS_DESKTOP_MEDIA_PICKER_AUDIO_SHARE_TOOLTIP_MAC)]; @@ -341,13 +346,20 @@ switch ([item sourceID].type) { case content::DesktopMediaID::TYPE_SCREEN: case content::DesktopMediaID::TYPE_WINDOW: - [audioShareCheckbox_ setEnabled:NO]; + if ([audioShareCheckbox_ isEnabled]) { + [audioShareCheckbox_ setEnabled:NO]; + audioShareState_ = [audioShareCheckbox_ state]; + [audioShareCheckbox_ setState:NSOffState]; + } [audioShareCheckbox_ setToolTip:l10n_util::GetNSString( IDS_DESKTOP_MEDIA_PICKER_AUDIO_SHARE_TOOLTIP_MAC)]; break; case content::DesktopMediaID::TYPE_WEB_CONTENTS: - [audioShareCheckbox_ setEnabled:YES]; + if (![audioShareCheckbox_ isEnabled]) { + [audioShareCheckbox_ setEnabled:YES]; + [audioShareCheckbox_ setState:audioShareState_]; + } [audioShareCheckbox_ setToolTip:@""]; break; case content::DesktopMediaID::TYPE_NONE:
diff --git a/chrome/browser/ui/views/desktop_media_picker_views.cc b/chrome/browser/ui/views/desktop_media_picker_views.cc index 82a6d04..065247cf 100644 --- a/chrome/browser/ui/views/desktop_media_picker_views.cc +++ b/chrome/browser/ui/views/desktop_media_picker_views.cc
@@ -401,6 +401,7 @@ app_name_(app_name), description_label_(new views::Label()), audio_share_checkbox_(nullptr), + audio_share_checked_(true), sources_scroll_view_(views::ScrollView::CreateScrollViewWithBorder()), sources_list_view_( new DesktopMediaListView(this, std::move(media_list))) { @@ -557,10 +558,17 @@ if (source.type == DesktopMediaID::TYPE_SCREEN || source.type == DesktopMediaID::TYPE_WEB_CONTENTS) { - audio_share_checkbox_->SetEnabled(true); + if (!audio_share_checkbox_->enabled()) { + audio_share_checkbox_->SetEnabled(true); + audio_share_checkbox_->SetChecked(audio_share_checked_); + } audio_share_checkbox_->SetTooltipText(base::string16()); } else if (source.type == DesktopMediaID::TYPE_WINDOW) { - audio_share_checkbox_->SetEnabled(false); + if (audio_share_checkbox_->enabled()) { + audio_share_checkbox_->SetEnabled(false); + audio_share_checked_ = audio_share_checkbox_->checked(); + audio_share_checkbox_->SetChecked(false); + } audio_share_checkbox_->SetTooltipText(l10n_util::GetStringUTF16( IDS_DESKTOP_MEDIA_PICKER_AUDIO_SHARE_TOOLTIP_WINDOW)); } else {
diff --git a/chrome/browser/ui/views/desktop_media_picker_views.h b/chrome/browser/ui/views/desktop_media_picker_views.h index 992a46c4..de4554b 100644 --- a/chrome/browser/ui/views/desktop_media_picker_views.h +++ b/chrome/browser/ui/views/desktop_media_picker_views.h
@@ -152,7 +152,12 @@ base::string16 app_name_; views::Label* description_label_; + + // |audio_share_checked_| records whether the user permits audio, when + // |audio_share_checkbox_| is disabled. views::Checkbox* audio_share_checkbox_; + bool audio_share_checked_; + views::ScrollView* sources_scroll_view_; DesktopMediaListView* sources_list_view_;
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi index 9ded65f..4c5b4598 100644 --- a/chrome/chrome_common.gypi +++ b/chrome/chrome_common.gypi
@@ -405,8 +405,8 @@ 'common_mojo_bindings', '<(DEPTH)/components/components.gyp:autofill_core_common', '<(DEPTH)/components/components.gyp:autofill_content_common', + '<(DEPTH)/components/components.gyp:password_manager_content_mojo_bindings', '<(DEPTH)/components/components.gyp:password_manager_core_common', - '<(DEPTH)/components/components.gyp:password_manager_content_common', '<(DEPTH)/components/components.gyp:signin_core_common', '<(DEPTH)/components/components.gyp:translate_content_common', '<(DEPTH)/components/components.gyp:visitedlink_common',
diff --git a/chrome/common/BUILD.gn b/chrome/common/BUILD.gn index 4a08381e..363da304 100644 --- a/chrome/common/BUILD.gn +++ b/chrome/common/BUILD.gn
@@ -139,7 +139,7 @@ "//chrome/common/net", "//components/autofill/content/common", "//components/autofill/core/common", - "//components/password_manager/content/common", + "//components/password_manager/content/public/interfaces", "//components/password_manager/core/common", "//components/signin/core/common", "//components/translate/content/common",
diff --git a/chrome/renderer/autofill/password_generation_agent_browsertest.cc b/chrome/renderer/autofill/password_generation_agent_browsertest.cc index 410b75b8..7f89123 100644 --- a/chrome/renderer/autofill/password_generation_agent_browsertest.cc +++ b/chrome/renderer/autofill/password_generation_agent_browsertest.cc
@@ -575,11 +575,13 @@ SetNotBlacklistedMessage(password_generation_, kPasswordChangeFormHTML); ExpectGenerationAvailable("password", false); ExpectGenerationAvailable("newpassword", false); + ExpectGenerationAvailable("confirmpassword", false); SetAccountCreationFormsDetectedMessage(password_generation_, GetMainFrame()->document(), 0, 2); ExpectGenerationAvailable("password", false); ExpectGenerationAvailable("newpassword", true); + ExpectGenerationAvailable("confirmpassword", false); } TEST_F(PasswordGenerationAgentTest, ManualGenerationInFormTest) { @@ -607,4 +609,41 @@ ExpectGenerationAvailable("second_password", false); } +TEST_F(PasswordGenerationAgentTest, PresavingGeneratedPassword) { + const struct { + const char* form; + const char* generation_element; + } kTestCases[] = {{kAccountCreationFormHTML, "first_password"}, + {kAccountCreationNoForm, "first_password"}, + {kPasswordChangeFormHTML, "newpassword"}}; + for (auto& test_case : kTestCases) { + SCOPED_TRACE(testing::Message("form: ") << test_case.form); + LoadHTMLWithUserGesture(test_case.form); + // To be able to work with input elements outside <form>'s, use manual + // generation. + ShowGenerationPopUpManually(test_case.generation_element); + ExpectGenerationAvailable(test_case.generation_element, true); + + base::string16 password = base::ASCIIToUTF16("random_password"); + AutofillMsg_GeneratedPasswordAccepted msg(0, password); + password_generation_->OnMessageReceived(msg); + EXPECT_TRUE(render_thread_->sink().GetFirstMessageMatching( + AutofillHostMsg_PresaveGeneratedPassword::ID)); + render_thread_->sink().ClearMessages(); + + FocusField(test_case.generation_element); + SimulateUserTypingASCIICharacter('a', true); + EXPECT_TRUE(render_thread_->sink().GetFirstMessageMatching( + AutofillHostMsg_PresaveGeneratedPassword::ID)); + render_thread_->sink().ClearMessages(); + + for (size_t i = 0; i < password.length(); ++i) + SimulateUserTypingASCIICharacter(ui::VKEY_BACK, false); + SimulateUserTypingASCIICharacter(ui::VKEY_BACK, true); + EXPECT_TRUE(render_thread_->sink().GetFirstMessageMatching( + AutofillHostMsg_PasswordNoLongerGenerated::ID)); + render_thread_->sink().ClearMessages(); + } +} + } // namespace autofill
diff --git a/chrome/test/data/webui/promise_resolver_test.html b/chrome/test/data/webui/promise_resolver_test.html new file mode 100644 index 0000000..2df51627 --- /dev/null +++ b/chrome/test/data/webui/promise_resolver_test.html
@@ -0,0 +1,27 @@ +<!DOCTYPE html> +<html> +<body> +<script> + +function testMembersReadOnly() { + var resolver = new PromiseResolver; + assertThrows(function() { resolver.promise = new Promise; }); + assertThrows(function() { resolver.resolve = function() {}; }); + assertThrows(function() { resolver.reject = function() {}; }); +} + +function testResolves(done) { + var resolver = new PromiseResolver; + resolver.promise.then(done); + resolver.resolve(); +} + +function testRejects(done) { + var resolver = new PromiseResolver; + resolver.promise.catch(done); + resolver.reject(); +} + +</script> +</body> +</html>
diff --git a/chrome/test/data/webui/webui_resource_browsertest.cc b/chrome/test/data/webui/webui_resource_browsertest.cc index b1d55188..5f966dc 100644 --- a/chrome/test/data/webui/webui_resource_browsertest.cc +++ b/chrome/test/data/webui/webui_resource_browsertest.cc
@@ -239,3 +239,9 @@ AddLibrary(IDR_WEBUI_JS_UTIL); LoadFile(base::FilePath(FILE_PATH_LITERAL("util_test.html"))); } + +IN_PROC_BROWSER_TEST_F(WebUIResourceBrowserTest, PromiseResolverTest) { + AddLibrary(IDR_WEBUI_JS_ASSERT); + AddLibrary(IDR_WEBUI_JS_PROMISE_RESOLVER); + LoadFile(base::FilePath(FILE_PATH_LITERAL("promise_resolver_test.html"))); +}
diff --git a/chromeos/CHROMEOS_LKGM b/chromeos/CHROMEOS_LKGM index 51a33692..628df16 100644 --- a/chromeos/CHROMEOS_LKGM +++ b/chromeos/CHROMEOS_LKGM
@@ -1 +1 @@ -8161.0.0 \ No newline at end of file +8164.0.0 \ No newline at end of file
diff --git a/components/BUILD.gn b/components/BUILD.gn index 2f721df..999d71d0 100644 --- a/components/BUILD.gn +++ b/components/BUILD.gn
@@ -398,7 +398,6 @@ "//components/dom_distiller/core", "//components/dom_distiller/core:test_support", "//components/password_manager/content/browser", - "//components/password_manager/content/common", "//components/password_manager/content/renderer", "//components/strings", "//components/tracing",
diff --git a/components/arc/ime/arc_ime_service.cc b/components/arc/ime/arc_ime_service.cc index b8cd974a..d96fa332 100644 --- a/components/arc/ime/arc_ime_service.cc +++ b/components/arc/ime/arc_ime_service.cc
@@ -8,6 +8,7 @@ #include "components/arc/ime/arc_ime_bridge_impl.h" #include "components/exo/shell_surface.h" #include "components/exo/surface.h" +#include "ui/aura/client/aura_constants.h" #include "ui/aura/client/focus_client.h" #include "ui/aura/env.h" #include "ui/aura/window.h" @@ -20,6 +21,15 @@ namespace { +// The height in DIP of the window titlebar, rendered in client-side (i.e., +// inside ARC), but outside where ARC apps and IME recognize. Rather than +// to complicate things by wiring the value progaramatically via yet another +// IPC, we just embed the constant here for simplicity. +// +// TODO(kinaba, skuhne): Future version of ARC window management should make +// this host-side offsetting unnecessary. Get rid of this when it's ready. +constexpr int kWindowTitleHeight = 32; + bool IsArcWindow(const aura::Window* window) { return exo::Surface::AsSurface(window); } @@ -206,7 +216,29 @@ } gfx::Rect ArcImeService::GetCaretBounds() const { - return cursor_rect_; + if (!focused_arc_window_.has_windows()) + return gfx::Rect(); + aura::Window* window = focused_arc_window_.windows().front(); + + // |cursor_rect_| holds the rectangle reported from ARC apps, in the "screen + // coordinates" in ARC, counted by physical pixels. + // Chrome OS input methods expect the coordinates in Chrome OS screen, within + // device independent pixels. Three factors are involved for the conversion. + + // Divide by the scale factor. To convert from physical pixels to DIP. + gfx::Rect converted = gfx::ScaleToEnclosingRect( + cursor_rect_, 1 / window->layer()->device_scale_factor()); + + // Add the offset of the window showing the ARC app. + converted.Offset(window->GetBoundsInScreen().OffsetFromOrigin()); + + // Add the titlebar height (drawn inside ARC.) + // TODO(kinaba, skuhne): This should be absorbed inside ARC in the future. + if (window->GetProperty(aura::client::kShowStateKey) != + ui::SHOW_STATE_FULLSCREEN) { + converted.Offset(0, kWindowTitleHeight); + } + return converted; } ui::TextInputMode ArcImeService::GetTextInputMode() const {
diff --git a/components/autofill/content/common/autofill_messages.h b/components/autofill/content/common/autofill_messages.h index 0b2e813..8d60016 100644 --- a/components/autofill/content/common/autofill_messages.h +++ b/components/autofill/content/common/autofill_messages.h
@@ -341,7 +341,12 @@ // Instructs the browser to hide any password generation popups. IPC_MESSAGE_ROUTED0(AutofillHostMsg_HidePasswordGenerationPopup) -// Instructs the browsr that form no longer contains a generated password. +// Instructs the browser to presave the form with generated password. +IPC_MESSAGE_ROUTED1(AutofillHostMsg_PresaveGeneratedPassword, + autofill::PasswordForm) + +// Instructs the browser that form no longer contains a generated password and +// the presaved form should be removed. IPC_MESSAGE_ROUTED1(AutofillHostMsg_PasswordNoLongerGenerated, autofill::PasswordForm)
diff --git a/components/autofill/content/renderer/password_generation_agent.cc b/components/autofill/content/renderer/password_generation_agent.cc index 2485c3d..23564323 100644 --- a/components/autofill/content/renderer/password_generation_agent.cc +++ b/components/autofill/content/renderer/password_generation_agent.cc
@@ -285,6 +285,35 @@ // an account creation form are always adjacent. render_frame()->GetRenderView()->GetWebView()->advanceFocus(false); } + std::unique_ptr<PasswordForm> presaved_form(CreatePasswordFormToPresave()); + if (presaved_form) { + Send(new AutofillHostMsg_PresaveGeneratedPassword(routing_id(), + *presaved_form)); + } +} + +std::unique_ptr<PasswordForm> +PasswordGenerationAgent::CreatePasswordFormToPresave() { + DCHECK(!generation_element_.isNull()); + // Since the form for presaving should match a form in the browser, create it + // with the same algorithm (to match html attributes, action, etc.), but + // change username and password values. + std::unique_ptr<PasswordForm> password_form; + if (!generation_element_.form().isNull()) { + password_form = CreatePasswordFormFromWebForm(generation_element_.form(), + nullptr, nullptr); + } else { + password_form = CreatePasswordFormFromUnownedInputElements( + *render_frame()->GetWebFrame(), nullptr, nullptr); + } + if (password_form) { + // TODO(kolos): when we are good in username detection, save username + // as well. + password_form->username_value = base::string16(); + password_form->password_value = generation_element_.value(); + } + + return password_form; } void PasswordGenerationAgent::OnFormsEligibleForGenerationFound( @@ -413,9 +442,12 @@ password_generation::PASSWORD_DELETED); CopyElementValueToOtherInputElements(&element, &generation_form_data_->password_elements); - Send(new AutofillHostMsg_PasswordNoLongerGenerated( - routing_id(), - *generation_form_data_->form)); + std::unique_ptr<PasswordForm> presaved_form( + CreatePasswordFormToPresave()); + if (presaved_form) { + Send(new AutofillHostMsg_PasswordNoLongerGenerated(routing_id(), + *presaved_form)); + } } // Do not treat the password as generated, either here or in the browser. @@ -429,6 +461,11 @@ // Mirror edits to any confirmation password fields. CopyElementValueToOtherInputElements(&element, &generation_form_data_->password_elements); + std::unique_ptr<PasswordForm> presaved_form(CreatePasswordFormToPresave()); + if (presaved_form) { + Send(new AutofillHostMsg_PresaveGeneratedPassword(routing_id(), + *presaved_form)); + } } else if (element.value().length() > kMaximumOfferSize) { // User has rejected the feature and has started typing a password. HidePopup();
diff --git a/components/autofill/content/renderer/password_generation_agent.h b/components/autofill/content/renderer/password_generation_agent.h index 82cdf5e..1b3d36d 100644 --- a/components/autofill/content/renderer/password_generation_agent.h +++ b/components/autofill/content/renderer/password_generation_agent.h
@@ -107,6 +107,12 @@ // generation popup at this field. void OnUserTriggeredGeneratePassword(); + // Creates a password form to presave a generated password. It copies behavior + // of CreatePasswordFormFromWebForm/FromUnownedInputElements, but takes + // |password_value| from |generation_element_| and empties |username_value|. + // If a form creating is failed, returns an empty unique_ptr. + std::unique_ptr<PasswordForm> CreatePasswordFormToPresave(); + // Stores forms that are candidates for account creation. AccountCreationFormDataList possible_account_creation_forms_;
diff --git a/components/components_tests.gyp b/components/components_tests.gyp index e344102..313d8b0 100644 --- a/components/components_tests.gyp +++ b/components/components_tests.gyp
@@ -457,7 +457,7 @@ ], 'password_manager_unittest_sources': [ 'password_manager/content/browser/content_password_manager_driver_unittest.cc', - 'password_manager/content/browser/credential_manager_dispatcher_unittest.cc', + 'password_manager/content/browser/credential_manager_impl_unittest.cc', 'password_manager/core/browser/affiliated_match_helper_unittest.cc', 'password_manager/core/browser/affiliation_backend_unittest.cc', 'password_manager/core/browser/affiliation_database_unittest.cc', @@ -1261,7 +1261,6 @@ 'components.gyp:page_load_metrics_browser', 'components.gyp:page_load_metrics_renderer', 'components.gyp:password_manager_content_browser', - 'components.gyp:password_manager_content_common', 'components.gyp:power', 'components.gyp:precache_content', 'components.gyp:safe_browsing_db',
diff --git a/components/password_manager.gypi b/components/password_manager.gypi index d3b0631..a7e411c 100644 --- a/components/password_manager.gypi +++ b/components/password_manager.gypi
@@ -249,26 +249,47 @@ ['OS != "ios"', { 'targets': [ { - # GN version: //components/password_manager/content/common - 'target_name': 'password_manager_content_common', + # GN version: //components/password_manager/content/public/interfaces + 'target_name': 'password_manager_content_mojo_bindings_mojom', + 'type': 'none', + 'variables': { + 'mojom_extra_generator_args': [ + '--typemap', '<(DEPTH)/url/mojo/origin.typemap', + ], + 'mojom_files': [ + 'password_manager/content/public/interfaces/credential_manager.mojom', + ], + }, + 'include_dirs': [ + '..', + ], + 'includes': [ + '../mojo/mojom_bindings_generator_explicit.gypi', + ], + }, + { + # GN version: //components/password_manager/content/public/cpp + 'target_name': 'password_manager_content_mojo_bindings', 'type': 'static_library', 'dependencies': [ '../base/base.gyp:base', - '../content/content.gyp:content_common', - '../ipc/ipc.gyp:ipc', - '../third_party/WebKit/public/blink.gyp:blink_minimal', - '../url/ipc/url_ipc.gyp:url_ipc', + '../mojo/mojo_base.gyp:mojo_common_lib', + '../mojo/mojo_base.gyp:mojo_url_type_converters', + '../mojo/mojo_public.gyp:mojo_cpp_bindings', + '../third_party/WebKit/public/blink.gyp:blink', + '../url/url.gyp:url_mojom', + 'password_manager_content_mojo_bindings_mojom', 'password_manager_core_common', ], + 'export_dependent_settings': [ + '../url/url.gyp:url_mojom', + ], 'include_dirs': [ '..', ], 'sources': [ - 'password_manager/content/common/credential_manager_content_utils.cc', - 'password_manager/content/common/credential_manager_content_utils.h', - 'password_manager/content/common/credential_manager_message_generator.cc', - 'password_manager/content/common/credential_manager_message_generator.h', - 'password_manager/content/common/credential_manager_messages.h', + 'password_manager/content/public/cpp/type_converters.cc', + 'password_manager/content/public/cpp/type_converters.h', ], }, { @@ -278,11 +299,10 @@ 'dependencies': [ '../base/base.gyp:base', '../content/content.gyp:content_common', - '../ipc/ipc.gyp:ipc', + '../mojo/mojo_base.gyp:mojo_url_type_converters', '../third_party/WebKit/public/blink.gyp:blink', - '../url/ipc/url_ipc.gyp:url_ipc', + 'password_manager_content_mojo_bindings', 'password_manager_core_common', - 'password_manager_content_common', ], 'include_dirs': [ '..', @@ -301,13 +321,14 @@ '../content/content.gyp:content_browser', '../content/content.gyp:content_common', '../ipc/ipc.gyp:ipc', + '../mojo/mojo_base.gyp:mojo_url_type_converters', '../net/net.gyp:net', 'autofill_content_browser', 'autofill_content_common', 'autofill_core_common', 'keyed_service_content', + 'password_manager_content_mojo_bindings', 'password_manager_core_browser', - 'password_manager_content_common', ], 'include_dirs': [ '..', @@ -320,8 +341,8 @@ 'password_manager/content/browser/content_password_manager_driver.h', 'password_manager/content/browser/content_password_manager_driver_factory.cc', 'password_manager/content/browser/content_password_manager_driver_factory.h', - 'password_manager/content/browser/credential_manager_dispatcher.cc', - 'password_manager/content/browser/credential_manager_dispatcher.h', + 'password_manager/content/browser/credential_manager_impl.cc', + 'password_manager/content/browser/credential_manager_impl.h', 'password_manager/content/browser/password_manager_internals_service_factory.cc', 'password_manager/content/browser/password_manager_internals_service_factory.h', ],
diff --git a/components/password_manager/content/DEPS b/components/password_manager/content/DEPS index 4d5d19c..6a69bf3 100644 --- a/components/password_manager/content/DEPS +++ b/components/password_manager/content/DEPS
@@ -2,10 +2,10 @@ "+components/autofill/content/common", "+components/autofill/core/common", "+content/public/common", + "+mojo/common", # Allow inclusion of WebKit API files. "+third_party/WebKit/public/platform", "+third_party/WebKit/public/web", - "+ipc", ] specific_include_rules = {
diff --git a/components/password_manager/content/browser/BUILD.gn b/components/password_manager/content/browser/BUILD.gn index 85f89dc0..4220c2c 100644 --- a/components/password_manager/content/browser/BUILD.gn +++ b/components/password_manager/content/browser/BUILD.gn
@@ -10,8 +10,8 @@ "content_password_manager_driver.h", "content_password_manager_driver_factory.cc", "content_password_manager_driver_factory.h", - "credential_manager_dispatcher.cc", - "credential_manager_dispatcher.h", + "credential_manager_impl.cc", + "credential_manager_impl.h", "password_manager_internals_service_factory.cc", "password_manager_internals_service_factory.h", ] @@ -22,13 +22,15 @@ "//components/autofill/content/common", "//components/autofill/core/common", "//components/keyed_service/content", - "//components/password_manager/content/common", + "//components/password_manager/content/public/cpp", + "//components/password_manager/content/public/interfaces", "//components/password_manager/core/browser", "//components/password_manager/core/common", "//components/prefs", "//content/public/browser", "//content/public/common", "//ipc", + "//mojo/common:url_type_converters", "//net", ] } @@ -37,7 +39,7 @@ testonly = true sources = [ "content_password_manager_driver_unittest.cc", - "credential_manager_dispatcher_unittest.cc", + "credential_manager_impl_unittest.cc", ] deps = [ ":browser",
diff --git a/components/password_manager/content/browser/DEPS b/components/password_manager/content/browser/DEPS index 8dac82f..4bab70e2 100644 --- a/components/password_manager/content/browser/DEPS +++ b/components/password_manager/content/browser/DEPS
@@ -3,5 +3,7 @@ "+components/autofill/content/browser", "+components/keyed_service/content", "+content/public/browser", + "+ipc", + "+mojo/public", "+net", ]
diff --git a/components/password_manager/content/browser/bad_message.h b/components/password_manager/content/browser/bad_message.h index 37efbefd..90e9ab6 100644 --- a/components/password_manager/content/browser/bad_message.h +++ b/components/password_manager/content/browser/bad_message.h
@@ -25,6 +25,7 @@ CPMD_BAD_ORIGIN_FOCUSED_PASSWORD_FORM_FOUND = 4, CPMD_BAD_ORIGIN_IN_PAGE_NAVIGATION = 5, CPMD_BAD_ORIGIN_PASSWORD_NO_LONGER_GENERATED = 6, + CPMD_BAD_ORIGIN_PRESAVE_GENERATED_PASSWORD = 7, // Please add new elements here. The naming convention is abbreviated class // name (e.g. ContentPasswordManagerDriver becomes CPMD) plus a unique
diff --git a/components/password_manager/content/browser/content_password_manager_driver.cc b/components/password_manager/content/browser/content_password_manager_driver.cc index 08bb4d9..38129bf2 100644 --- a/components/password_manager/content/browser/content_password_manager_driver.cc +++ b/components/password_manager/content/browser/content_password_manager_driver.cc
@@ -151,6 +151,8 @@ IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordFormSubmitted, OnPasswordFormSubmitted) IPC_MESSAGE_HANDLER(AutofillHostMsg_InPageNavigation, OnInPageNavigation) + IPC_MESSAGE_HANDLER(AutofillHostMsg_PresaveGeneratedPassword, + OnPresaveGeneratedPassword) IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordNoLongerGenerated, OnPasswordNoLongerGenerated) IPC_MESSAGE_HANDLER(AutofillHostMsg_FocusedPasswordFormFound, @@ -231,6 +233,15 @@ GetPasswordManager()->OnInPageNavigation(this, password_form); } +void ContentPasswordManagerDriver::OnPresaveGeneratedPassword( + const autofill::PasswordForm& password_form) { + if (!CheckChildProcessSecurityPolicy( + password_form.origin, + BadMessageReason::CPMD_BAD_ORIGIN_PRESAVE_GENERATED_PASSWORD)) + return; + GetPasswordManager()->OnPresaveGeneratedPassword(password_form); +} + void ContentPasswordManagerDriver::OnPasswordNoLongerGenerated( const autofill::PasswordForm& password_form) { if (!CheckChildProcessSecurityPolicy(
diff --git a/components/password_manager/content/browser/content_password_manager_driver.h b/components/password_manager/content/browser/content_password_manager_driver.h index f2bf8822..0592207 100644 --- a/components/password_manager/content/browser/content_password_manager_driver.h +++ b/components/password_manager/content/browser/content_password_manager_driver.h
@@ -87,6 +87,7 @@ bool did_stop_loading); void OnPasswordFormSubmitted(const autofill::PasswordForm& password_form); void OnInPageNavigation(const autofill::PasswordForm& password_form); + void OnPresaveGeneratedPassword(const autofill::PasswordForm& password_form); void OnPasswordNoLongerGenerated(const autofill::PasswordForm& password_form); void OnFocusedPasswordFormFound(const autofill::PasswordForm& password_form);
diff --git a/components/password_manager/content/browser/credential_manager_dispatcher.cc b/components/password_manager/content/browser/credential_manager_dispatcher.cc deleted file mode 100644 index 6f6780cf..0000000 --- a/components/password_manager/content/browser/credential_manager_dispatcher.cc +++ /dev/null
@@ -1,292 +0,0 @@ -// Copyright 2014 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 "components/password_manager/content/browser/credential_manager_dispatcher.h" - -#include <utility> - -#include "base/bind.h" -#include "base/strings/string16.h" -#include "base/strings/utf_string_conversions.h" -#include "components/autofill/core/common/password_form.h" -#include "components/password_manager/content/browser/content_password_manager_driver.h" -#include "components/password_manager/content/browser/content_password_manager_driver_factory.h" -#include "components/password_manager/content/common/credential_manager_messages.h" -#include "components/password_manager/core/browser/affiliated_match_helper.h" -#include "components/password_manager/core/browser/password_manager_client.h" -#include "components/password_manager/core/browser/password_store.h" -#include "components/password_manager/core/common/credential_manager_types.h" -#include "components/password_manager/core/common/password_manager_pref_names.h" -#include "content/public/browser/render_view_host.h" -#include "content/public/browser/web_contents.h" -#include "ipc/ipc_message_macros.h" - -namespace password_manager { - -// CredentialManagerDispatcher ------------------------------------------------- - -CredentialManagerDispatcher::CredentialManagerDispatcher( - content::WebContents* web_contents, - PasswordManagerClient* client) - : WebContentsObserver(web_contents), client_(client), weak_factory_(this) { - DCHECK(web_contents); - auto_signin_enabled_.Init(prefs::kCredentialsEnableAutosignin, - client_->GetPrefs()); -} - -CredentialManagerDispatcher::~CredentialManagerDispatcher() { -} - -bool CredentialManagerDispatcher::OnMessageReceived( - const IPC::Message& message) { - bool handled = true; - IPC_BEGIN_MESSAGE_MAP(CredentialManagerDispatcher, message) - IPC_MESSAGE_HANDLER(CredentialManagerHostMsg_Store, OnStore); - IPC_MESSAGE_HANDLER(CredentialManagerHostMsg_RequireUserMediation, - OnRequireUserMediation); - IPC_MESSAGE_HANDLER(CredentialManagerHostMsg_RequestCredential, - OnRequestCredential); - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - return handled; -} - -void CredentialManagerDispatcher::OnStore( - int request_id, - const password_manager::CredentialInfo& credential) { - DCHECK(credential.type != CredentialType::CREDENTIAL_TYPE_EMPTY); - DCHECK(request_id); - web_contents()->GetRenderViewHost()->Send( - new CredentialManagerMsg_AcknowledgeStore( - web_contents()->GetRenderViewHost()->GetRoutingID(), request_id)); - - if (!client_->IsSavingAndFillingEnabledForCurrentPage()) - return; - - std::unique_ptr<autofill::PasswordForm> form( - CreatePasswordFormFromCredentialInfo( - credential, web_contents()->GetLastCommittedURL().GetOrigin())); - form->skip_zero_click = !IsZeroClickAllowed(); - - form_manager_.reset(new CredentialManagerPasswordFormManager( - client_, GetDriver(), *form, this)); -} - -void CredentialManagerDispatcher::OnProvisionalSaveComplete() { - DCHECK(form_manager_); - DCHECK(client_->IsSavingAndFillingEnabledForCurrentPage()); - const autofill::PasswordForm& form = form_manager_->pending_credentials(); - - if (!form.federation_origin.unique()) { - // If this is a federated credential, check it against the federated matches - // produced by the PasswordFormManager. If a match is found, update it and - // return. - for (const auto& match : form_manager_->federated_matches()) { - if (match->username_value == form.username_value && - match->federation_origin.IsSameOriginWith(form.federation_origin)) { - form_manager_->Update(*match); - return; - } - } - } else if (!form_manager_->IsNewLogin()) { - // Otherwise, if this is not a new password credential, update the existing - // credential without prompting the user. This will also update the - // 'skip_zero_click' state, as we've gotten an explicit signal that the page - // understands the credential management API and so can be trusted to notify - // us when they sign the user out. - form_manager_->Update(*form_manager_->preferred_match()); - return; - } - - // Otherwise, this is a new form, so as the user if they'd like to save. - client_->PromptUserToSaveOrUpdatePassword( - std::move(form_manager_), CredentialSourceType::CREDENTIAL_SOURCE_API, - false); -} - -void CredentialManagerDispatcher::OnRequireUserMediation(int request_id) { - DCHECK(request_id); - - PasswordStore* store = GetPasswordStore(); - if (!store || !IsUpdatingCredentialAllowed()) { - web_contents()->GetRenderViewHost()->Send( - new CredentialManagerMsg_AcknowledgeRequireUserMediation( - web_contents()->GetRenderViewHost()->GetRoutingID(), request_id)); - return; - } - - if (store->affiliated_match_helper()) { - store->affiliated_match_helper()->GetAffiliatedAndroidRealms( - GetSynthesizedFormForOrigin(), - base::Bind(&CredentialManagerDispatcher::ScheduleRequireMediationTask, - weak_factory_.GetWeakPtr(), request_id)); - } else { - std::vector<std::string> no_affiliated_realms; - ScheduleRequireMediationTask(request_id, no_affiliated_realms); - } -} - -void CredentialManagerDispatcher::ScheduleRequireMediationTask( - int request_id, - const std::vector<std::string>& android_realms) { - DCHECK(GetPasswordStore()); - if (!pending_require_user_mediation_) { - pending_require_user_mediation_.reset( - new CredentialManagerPendingRequireUserMediationTask( - this, web_contents()->GetLastCommittedURL().GetOrigin(), - android_realms)); - - // This will result in a callback to - // CredentialManagerPendingRequireUserMediationTask::OnGetPasswordStoreResults(). - GetPasswordStore()->GetAutofillableLogins( - pending_require_user_mediation_.get()); - } else { - pending_require_user_mediation_->AddOrigin( - web_contents()->GetLastCommittedURL().GetOrigin()); - } - - web_contents()->GetRenderViewHost()->Send( - new CredentialManagerMsg_AcknowledgeRequireUserMediation( - web_contents()->GetRenderViewHost()->GetRoutingID(), request_id)); -} - -void CredentialManagerDispatcher::OnRequestCredential( - int request_id, - bool zero_click_only, - bool include_passwords, - const std::vector<GURL>& federations) { - DCHECK(request_id); - PasswordStore* store = GetPasswordStore(); - if (pending_request_ || !store) { - web_contents()->GetRenderViewHost()->Send( - new CredentialManagerMsg_RejectCredentialRequest( - web_contents()->GetRenderViewHost()->GetRoutingID(), request_id, - pending_request_ - ? blink::WebCredentialManagerPendingRequestError - : blink::WebCredentialManagerPasswordStoreUnavailableError)); - return; - } - - // Return an empty credential if zero-click is required but disabled, or if - // the current page has TLS errors. - if ((zero_click_only && !IsZeroClickAllowed()) || - client_->DidLastPageLoadEncounterSSLErrors()) { - web_contents()->GetRenderViewHost()->Send( - new CredentialManagerMsg_SendCredential( - web_contents()->GetRenderViewHost()->GetRoutingID(), request_id, - CredentialInfo())); - return; - } - - if (store->affiliated_match_helper()) { - store->affiliated_match_helper()->GetAffiliatedAndroidRealms( - GetSynthesizedFormForOrigin(), - base::Bind(&CredentialManagerDispatcher::ScheduleRequestTask, - weak_factory_.GetWeakPtr(), request_id, zero_click_only, - include_passwords, federations)); - } else { - std::vector<std::string> no_affiliated_realms; - ScheduleRequestTask(request_id, zero_click_only, include_passwords, - federations, no_affiliated_realms); - } -} - -void CredentialManagerDispatcher::ScheduleRequestTask( - int request_id, - bool zero_click_only, - bool include_passwords, - const std::vector<GURL>& federations, - const std::vector<std::string>& android_realms) { - DCHECK(GetPasswordStore()); - pending_request_.reset(new CredentialManagerPendingRequestTask( - this, request_id, zero_click_only, - web_contents()->GetLastCommittedURL().GetOrigin(), include_passwords, - federations, android_realms)); - - // This will result in a callback to - // PendingRequestTask::OnGetPasswordStoreResults(). - GetPasswordStore()->GetAutofillableLogins(pending_request_.get()); -} - -PasswordStore* CredentialManagerDispatcher::GetPasswordStore() { - return client_ ? client_->GetPasswordStore() : nullptr; -} - -bool CredentialManagerDispatcher::IsZeroClickAllowed() const { - return *auto_signin_enabled_ && !client_->IsOffTheRecord(); -} - -GURL CredentialManagerDispatcher::GetOrigin() const { - return web_contents()->GetLastCommittedURL().GetOrigin(); -} - -base::WeakPtr<PasswordManagerDriver> CredentialManagerDispatcher::GetDriver() { - ContentPasswordManagerDriverFactory* driver_factory = - ContentPasswordManagerDriverFactory::FromWebContents(web_contents()); - DCHECK(driver_factory); - PasswordManagerDriver* driver = - driver_factory->GetDriverForFrame(web_contents()->GetMainFrame()); - return driver->AsWeakPtr(); -} - -void CredentialManagerDispatcher::SendCredential(int request_id, - const CredentialInfo& info) { - DCHECK(pending_request_); - DCHECK_EQ(pending_request_->id(), request_id); - - web_contents()->GetRenderViewHost()->Send( - new CredentialManagerMsg_SendCredential( - web_contents()->GetRenderViewHost()->GetRoutingID(), - pending_request_->id(), info)); - pending_request_.reset(); -} - -void CredentialManagerDispatcher::SendPasswordForm( - int request_id, - const autofill::PasswordForm* form) { - CredentialInfo info; - if (form) { - password_manager::CredentialType type_to_return = - form->federation_origin.unique() - ? CredentialType::CREDENTIAL_TYPE_PASSWORD - : CredentialType::CREDENTIAL_TYPE_FEDERATED; - info = CredentialInfo(*form, type_to_return); - if (PasswordStore* store = GetPasswordStore()) { - if (form->skip_zero_click && IsZeroClickAllowed()) { - DCHECK(IsUpdatingCredentialAllowed()); - autofill::PasswordForm update_form = *form; - update_form.skip_zero_click = false; - store->UpdateLogin(update_form); - } - } - } - SendCredential(request_id, info); -} - -PasswordManagerClient* CredentialManagerDispatcher::client() const { - return client_; -} - -autofill::PasswordForm -CredentialManagerDispatcher::GetSynthesizedFormForOrigin() const { - autofill::PasswordForm synthetic_form; - synthetic_form.origin = web_contents()->GetLastCommittedURL().GetOrigin(); - synthetic_form.signon_realm = synthetic_form.origin.spec(); - synthetic_form.scheme = autofill::PasswordForm::SCHEME_HTML; - synthetic_form.ssl_valid = synthetic_form.origin.SchemeIsCryptographic() && - !client_->DidLastPageLoadEncounterSSLErrors(); - return synthetic_form; -} - -void CredentialManagerDispatcher::DoneRequiringUserMediation() { - DCHECK(pending_require_user_mediation_); - pending_require_user_mediation_.reset(); -} - -bool CredentialManagerDispatcher::IsUpdatingCredentialAllowed() const { - return !client_->DidLastPageLoadEncounterSSLErrors() && - !client_->IsOffTheRecord(); -} - -} // namespace password_manager
diff --git a/components/password_manager/content/browser/credential_manager_impl.cc b/components/password_manager/content/browser/credential_manager_impl.cc new file mode 100644 index 0000000..0d5fa0d --- /dev/null +++ b/components/password_manager/content/browser/credential_manager_impl.cc
@@ -0,0 +1,281 @@ +// Copyright 2014 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 "components/password_manager/content/browser/credential_manager_impl.h" + +#include <utility> + +#include "base/bind.h" +#include "base/strings/string16.h" +#include "base/strings/utf_string_conversions.h" +#include "components/autofill/core/common/password_form.h" +#include "components/password_manager/content/browser/content_password_manager_driver.h" +#include "components/password_manager/content/browser/content_password_manager_driver_factory.h" +#include "components/password_manager/content/public/cpp/type_converters.h" +#include "components/password_manager/core/browser/affiliated_match_helper.h" +#include "components/password_manager/core/browser/password_manager_client.h" +#include "components/password_manager/core/browser/password_store.h" +#include "components/password_manager/core/common/credential_manager_types.h" +#include "components/password_manager/core/common/password_manager_pref_names.h" +#include "content/public/browser/web_contents.h" +#include "mojo/common/url_type_converters.h" + +namespace password_manager { + +namespace { + +void RunMojoGetCallback(const mojom::CredentialManager::GetCallback& callback, + const CredentialInfo& info) { + mojom::CredentialInfoPtr credential = mojom::CredentialInfo::From(info); + callback.Run(mojom::CredentialManagerError::SUCCESS, std::move(credential)); +} + +} // namespace + +// CredentialManagerImpl ------------------------------------------------- + +CredentialManagerImpl::CredentialManagerImpl(content::WebContents* web_contents, + PasswordManagerClient* client) + : WebContentsObserver(web_contents), client_(client), weak_factory_(this) { + DCHECK(web_contents); + auto_signin_enabled_.Init(prefs::kCredentialsEnableAutosignin, + client_->GetPrefs()); +} + +CredentialManagerImpl::~CredentialManagerImpl() {} + +void CredentialManagerImpl::BindRequest( + mojom::CredentialManagerRequest request) { + bindings_.AddBinding(this, std::move(request)); +} + +void CredentialManagerImpl::Store(mojom::CredentialInfoPtr credential, + const StoreCallback& callback) { + CredentialInfo info = credential.To<CredentialInfo>(); + DCHECK_NE(CredentialType::CREDENTIAL_TYPE_EMPTY, info.type); + + // Send acknowledge response back. + callback.Run(); + + if (!client_->IsSavingAndFillingEnabledForCurrentPage()) + return; + + std::unique_ptr<autofill::PasswordForm> form( + CreatePasswordFormFromCredentialInfo( + info, web_contents()->GetLastCommittedURL().GetOrigin())); + form->skip_zero_click = !IsZeroClickAllowed(); + + form_manager_.reset(new CredentialManagerPasswordFormManager( + client_, GetDriver(), *form, this)); +} + +void CredentialManagerImpl::OnProvisionalSaveComplete() { + DCHECK(form_manager_); + DCHECK(client_->IsSavingAndFillingEnabledForCurrentPage()); + const autofill::PasswordForm& form = form_manager_->pending_credentials(); + + if (!form.federation_origin.unique()) { + // If this is a federated credential, check it against the federated matches + // produced by the PasswordFormManager. If a match is found, update it and + // return. + for (const auto& match : form_manager_->federated_matches()) { + if (match->username_value == form.username_value && + match->federation_origin.IsSameOriginWith(form.federation_origin)) { + form_manager_->Update(*match); + return; + } + } + } else if (!form_manager_->IsNewLogin()) { + // Otherwise, if this is not a new password credential, update the existing + // credential without prompting the user. This will also update the + // 'skip_zero_click' state, as we've gotten an explicit signal that the page + // understands the credential management API and so can be trusted to notify + // us when they sign the user out. + form_manager_->Update(*form_manager_->preferred_match()); + return; + } + + // Otherwise, this is a new form, so as the user if they'd like to save. + client_->PromptUserToSaveOrUpdatePassword( + std::move(form_manager_), CredentialSourceType::CREDENTIAL_SOURCE_API, + false); +} + +void CredentialManagerImpl::RequireUserMediation( + const RequireUserMediationCallback& callback) { + PasswordStore* store = GetPasswordStore(); + if (!store || !IsUpdatingCredentialAllowed()) { + callback.Run(); + return; + } + + if (store->affiliated_match_helper()) { + store->affiliated_match_helper()->GetAffiliatedAndroidRealms( + GetSynthesizedFormForOrigin(), + base::Bind(&CredentialManagerImpl::ScheduleRequireMediationTask, + weak_factory_.GetWeakPtr(), callback)); + } else { + std::vector<std::string> no_affiliated_realms; + ScheduleRequireMediationTask(callback, no_affiliated_realms); + } +} + +void CredentialManagerImpl::ScheduleRequireMediationTask( + const RequireUserMediationCallback& callback, + const std::vector<std::string>& android_realms) { + DCHECK(GetPasswordStore()); + if (!pending_require_user_mediation_) { + pending_require_user_mediation_.reset( + new CredentialManagerPendingRequireUserMediationTask( + this, web_contents()->GetLastCommittedURL().GetOrigin(), + android_realms)); + + // This will result in a callback to + // CredentialManagerPendingRequireUserMediationTask:: + // OnGetPasswordStoreResults(). + GetPasswordStore()->GetAutofillableLogins( + pending_require_user_mediation_.get()); + } else { + pending_require_user_mediation_->AddOrigin( + web_contents()->GetLastCommittedURL().GetOrigin()); + } + + // Send acknowledge response back. + callback.Run(); +} + +void CredentialManagerImpl::Get(bool zero_click_only, + bool include_passwords, + mojo::Array<mojo::String> federations, + const GetCallback& callback) { + PasswordStore* store = GetPasswordStore(); + if (pending_request_ || !store) { + // Callback error. + callback.Run(pending_request_ + ? mojom::CredentialManagerError::PENDINGREQUEST + : mojom::CredentialManagerError::PASSWORDSTOREUNAVAILABLE, + nullptr); + return; + } + + // Return an empty credential if zero-click is required but disabled, or if + // the current page has TLS errors. + if ((zero_click_only && !IsZeroClickAllowed()) || + client_->DidLastPageLoadEncounterSSLErrors()) { + // Callback with empty credential info. + callback.Run(mojom::CredentialManagerError::SUCCESS, + mojom::CredentialInfo::New()); + return; + } + + if (store->affiliated_match_helper()) { + store->affiliated_match_helper()->GetAffiliatedAndroidRealms( + GetSynthesizedFormForOrigin(), + base::Bind(&CredentialManagerImpl::ScheduleRequestTask, + weak_factory_.GetWeakPtr(), callback, zero_click_only, + include_passwords, federations.To<std::vector<GURL>>())); + } else { + std::vector<std::string> no_affiliated_realms; + ScheduleRequestTask(callback, zero_click_only, include_passwords, + federations.To<std::vector<GURL>>(), + no_affiliated_realms); + } +} + +void CredentialManagerImpl::ScheduleRequestTask( + const GetCallback& callback, + bool zero_click_only, + bool include_passwords, + const std::vector<GURL>& federations, + const std::vector<std::string>& android_realms) { + DCHECK(GetPasswordStore()); + pending_request_.reset(new CredentialManagerPendingRequestTask( + this, base::Bind(&RunMojoGetCallback, callback), zero_click_only, + web_contents()->GetLastCommittedURL().GetOrigin(), include_passwords, + federations, android_realms)); + + // This will result in a callback to + // PendingRequestTask::OnGetPasswordStoreResults(). + GetPasswordStore()->GetAutofillableLogins(pending_request_.get()); +} + +PasswordStore* CredentialManagerImpl::GetPasswordStore() { + return client_ ? client_->GetPasswordStore() : nullptr; +} + +bool CredentialManagerImpl::IsZeroClickAllowed() const { + return *auto_signin_enabled_ && !client_->IsOffTheRecord(); +} + +GURL CredentialManagerImpl::GetOrigin() const { + return web_contents()->GetLastCommittedURL().GetOrigin(); +} + +base::WeakPtr<PasswordManagerDriver> CredentialManagerImpl::GetDriver() { + ContentPasswordManagerDriverFactory* driver_factory = + ContentPasswordManagerDriverFactory::FromWebContents(web_contents()); + DCHECK(driver_factory); + PasswordManagerDriver* driver = + driver_factory->GetDriverForFrame(web_contents()->GetMainFrame()); + return driver->AsWeakPtr(); +} + +void CredentialManagerImpl::SendCredential( + const SendCredentialCallback& send_callback, + const CredentialInfo& info) { + DCHECK(pending_request_); + DCHECK(send_callback.Equals(pending_request_->send_callback())); + + send_callback.Run(info); + pending_request_.reset(); +} + +void CredentialManagerImpl::SendPasswordForm( + const SendCredentialCallback& send_callback, + const autofill::PasswordForm* form) { + CredentialInfo info; + if (form) { + password_manager::CredentialType type_to_return = + form->federation_origin.unique() + ? CredentialType::CREDENTIAL_TYPE_PASSWORD + : CredentialType::CREDENTIAL_TYPE_FEDERATED; + info = CredentialInfo(*form, type_to_return); + if (PasswordStore* store = GetPasswordStore()) { + if (form->skip_zero_click && IsZeroClickAllowed()) { + DCHECK(IsUpdatingCredentialAllowed()); + autofill::PasswordForm update_form = *form; + update_form.skip_zero_click = false; + store->UpdateLogin(update_form); + } + } + } + SendCredential(send_callback, info); +} + +PasswordManagerClient* CredentialManagerImpl::client() const { + return client_; +} + +autofill::PasswordForm CredentialManagerImpl::GetSynthesizedFormForOrigin() + const { + autofill::PasswordForm synthetic_form; + synthetic_form.origin = web_contents()->GetLastCommittedURL().GetOrigin(); + synthetic_form.signon_realm = synthetic_form.origin.spec(); + synthetic_form.scheme = autofill::PasswordForm::SCHEME_HTML; + synthetic_form.ssl_valid = synthetic_form.origin.SchemeIsCryptographic() && + !client_->DidLastPageLoadEncounterSSLErrors(); + return synthetic_form; +} + +void CredentialManagerImpl::DoneRequiringUserMediation() { + DCHECK(pending_require_user_mediation_); + pending_require_user_mediation_.reset(); +} + +bool CredentialManagerImpl::IsUpdatingCredentialAllowed() const { + return !client_->DidLastPageLoadEncounterSSLErrors() && + !client_->IsOffTheRecord(); +} + +} // namespace password_manager
diff --git a/components/password_manager/content/browser/credential_manager_dispatcher.h b/components/password_manager/content/browser/credential_manager_impl.h similarity index 68% rename from components/password_manager/content/browser/credential_manager_dispatcher.h rename to components/password_manager/content/browser/credential_manager_impl.h index 1471a7b7..e6429eb0 100644 --- a/components/password_manager/content/browser/credential_manager_dispatcher.h +++ b/components/password_manager/content/browser/credential_manager_impl.h
@@ -2,20 +2,22 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_CREDENTIAL_MANAGER_DISPATCHER_H_ -#define COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_CREDENTIAL_MANAGER_DISPATCHER_H_ +#ifndef COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_CREDENTIAL_MANAGER_IMPL_H_ +#define COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_CREDENTIAL_MANAGER_IMPL_H_ #include <memory> #include "base/callback.h" #include "base/macros.h" #include "base/memory/weak_ptr.h" +#include "components/password_manager/content/public/interfaces/credential_manager.mojom.h" #include "components/password_manager/core/browser/credential_manager_password_form_manager.h" #include "components/password_manager/core/browser/credential_manager_pending_request_task.h" #include "components/password_manager/core/browser/credential_manager_pending_require_user_mediation_task.h" #include "components/password_manager/core/browser/password_store_consumer.h" #include "components/prefs/pref_member.h" #include "content/public/browser/web_contents_observer.h" +#include "mojo/public/cpp/bindings/binding_set.h" class GURL; @@ -34,42 +36,35 @@ class PasswordStore; struct CredentialInfo; -class CredentialManagerDispatcher - : public content::WebContentsObserver, +class CredentialManagerImpl + : public mojom::CredentialManager, + public content::WebContentsObserver, public CredentialManagerPasswordFormManagerDelegate, public CredentialManagerPendingRequestTaskDelegate, public CredentialManagerPendingRequireUserMediationTaskDelegate { public: - CredentialManagerDispatcher(content::WebContents* web_contents, - PasswordManagerClient* client); - ~CredentialManagerDispatcher() override; + CredentialManagerImpl(content::WebContents* web_contents, + PasswordManagerClient* client); + ~CredentialManagerImpl() override; - // Called in response to an IPC from the renderer, triggered by a page's call - // to 'navigator.credentials.store'. - virtual void OnStore(int request_id, const password_manager::CredentialInfo&); + void BindRequest(mojom::CredentialManagerRequest request); - // Called in response to an IPC from the renderer, triggered by a page's call - // to 'navigator.credentials.requireUserMediation'. - virtual void OnRequireUserMediation(int request_id); - - // Called in response to an IPC from the renderer, triggered by a page's call - // to 'navigator.credentials.request'. - // - // TODO(vabr): Determine if we can drop the `const` here to save some copies - // while processing the request. - virtual void OnRequestCredential(int request_id, - bool zero_click_only, - bool include_passwords, - const std::vector<GURL>& federations); - - // content::WebContentsObserver implementation. - bool OnMessageReceived(const IPC::Message& message) override; + // mojom::CredentialManager methods: + void Store(mojom::CredentialInfoPtr credential, + const StoreCallback& callback) override; + void RequireUserMediation( + const RequireUserMediationCallback& callback) override; + void Get(bool zero_click_only, + bool include_passwords, + mojo::Array<mojo::String> federations, + const GetCallback& callback) override; // CredentialManagerPendingRequestTaskDelegate: bool IsZeroClickAllowed() const override; GURL GetOrigin() const override; - void SendCredential(int request_id, const CredentialInfo& info) override; - void SendPasswordForm(int request_id, + void SendCredential(const SendCredentialCallback& send_callback, + const CredentialInfo& info) override; + void SendPasswordForm(const SendCredentialCallback& send_callback, const autofill::PasswordForm* form) override; PasswordManagerClient* client() const override; autofill::PasswordForm GetSynthesizedFormForOrigin() const override; @@ -89,7 +84,7 @@ // Schedules a CredentiaManagerPendingRequestTask (during // |OnRequestCredential()|) after the PasswordStore's AffiliationMatchHelper // grabs a list of realms related to the current web origin. - void ScheduleRequestTask(int request_id, + void ScheduleRequestTask(const GetCallback& callback, bool zero_click_only, bool include_passwords, const std::vector<GURL>& federations, @@ -99,7 +94,7 @@ // AffiliationMatchHelper grabs a list of realms related to the current // web origin. void ScheduleRequireMediationTask( - int request_id, + const RequireUserMediationCallback& callback, const std::vector<std::string>& android_realms); // Returns true iff it's OK to update credentials in the password store. @@ -119,11 +114,13 @@ std::unique_ptr<CredentialManagerPendingRequireUserMediationTask> pending_require_user_mediation_; - base::WeakPtrFactory<CredentialManagerDispatcher> weak_factory_; + mojo::BindingSet<mojom::CredentialManager> bindings_; - DISALLOW_COPY_AND_ASSIGN(CredentialManagerDispatcher); + base::WeakPtrFactory<CredentialManagerImpl> weak_factory_; + + DISALLOW_COPY_AND_ASSIGN(CredentialManagerImpl); }; } // namespace password_manager -#endif // COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_CREDENTIAL_MANAGER_DISPATCHER_H_ +#endif // COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_CREDENTIAL_MANAGER_IMPL_H_
diff --git a/components/password_manager/content/browser/credential_manager_dispatcher_unittest.cc b/components/password_manager/content/browser/credential_manager_impl_unittest.cc similarity index 70% rename from components/password_manager/content/browser/credential_manager_dispatcher_unittest.cc rename to components/password_manager/content/browser/credential_manager_impl_unittest.cc index 75a26f1..4286c6e8 100644 --- a/components/password_manager/content/browser/credential_manager_dispatcher_unittest.cc +++ b/components/password_manager/content/browser/credential_manager_impl_unittest.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/password_manager/content/browser/credential_manager_dispatcher.h" +#include "components/password_manager/content/browser/credential_manager_impl.h" #include <stdint.h> @@ -18,7 +18,7 @@ #include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" #include "base/thread_task_runner_handle.h" -#include "components/password_manager/content/common/credential_manager_messages.h" +#include "components/password_manager/content/public/cpp/type_converters.h" #include "components/password_manager/core/browser/credential_manager_password_form_manager.h" #include "components/password_manager/core/browser/mock_affiliated_match_helper.h" #include "components/password_manager/core/browser/password_manager.h" @@ -32,6 +32,7 @@ #include "content/public/browser/web_contents.h" #include "content/public/test/mock_render_process_host.h" #include "content/public/test/test_renderer_host.h" +#include "mojo/common/url_type_converters.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -44,9 +45,6 @@ namespace { -// Chosen by fair dice roll. Guaranteed to be random. -const int kRequestId = 4; - const char kTestWebOrigin[] = "https://example.com/"; const char kTestAndroidRealm1[] = "android://hash@com.example.one.android/"; const char kTestAndroidRealm2[] = "android://hash@com.example.two.android/"; @@ -135,11 +133,11 @@ DISALLOW_COPY_AND_ASSIGN(MockPasswordManagerClient); }; -class TestCredentialManagerDispatcher : public CredentialManagerDispatcher { +class TestCredentialManagerImpl : public CredentialManagerImpl { public: - TestCredentialManagerDispatcher(content::WebContents* web_contents, - PasswordManagerClient* client, - PasswordManagerDriver* driver); + TestCredentialManagerImpl(content::WebContents* web_contents, + PasswordManagerClient* client, + PasswordManagerDriver* driver); private: base::WeakPtr<PasswordManagerDriver> GetDriver() override; @@ -147,15 +145,14 @@ base::WeakPtr<PasswordManagerDriver> driver_; }; -TestCredentialManagerDispatcher::TestCredentialManagerDispatcher( +TestCredentialManagerImpl::TestCredentialManagerImpl( content::WebContents* web_contents, PasswordManagerClient* client, PasswordManagerDriver* driver) - : CredentialManagerDispatcher(web_contents, client), + : CredentialManagerImpl(web_contents, client), driver_(driver->AsWeakPtr()) {} -base::WeakPtr<PasswordManagerDriver> -TestCredentialManagerDispatcher::GetDriver() { +base::WeakPtr<PasswordManagerDriver> TestCredentialManagerImpl::GetDriver() { return driver_; } @@ -179,12 +176,26 @@ PasswordManager password_manager_; }; +// Callbacks from CredentialManagerImpl methods +void RespondCallback(bool* called) { + *called = true; +} + +void GetCredentialCallback(bool* called, + mojom::CredentialManagerError* out_error, + mojom::CredentialInfoPtr* out_info, + mojom::CredentialManagerError error, + mojom::CredentialInfoPtr info) { + *called = true; + *out_error = error; + *out_info = std::move(info); +} + } // namespace -class CredentialManagerDispatcherTest - : public content::RenderViewHostTestHarness { +class CredentialManagerImplTest : public content::RenderViewHostTestHarness { public: - CredentialManagerDispatcherTest() {} + CredentialManagerImplTest() {} void SetUp() override { content::RenderViewHostTestHarness::SetUp(); @@ -193,7 +204,7 @@ new testing::NiceMock<MockPasswordManagerClient>(store_.get())); stub_driver_.reset( new SlightlyLessStubbyPasswordManagerDriver(client_.get())); - dispatcher_.reset(new TestCredentialManagerDispatcher( + cm_service_impl_.reset(new TestCredentialManagerImpl( web_contents(), client_.get(), stub_driver_.get())); ON_CALL(*client_, IsSavingAndFillingEnabledForCurrentPage()) .WillByDefault(testing::Return(true)); @@ -251,11 +262,20 @@ } void TearDown() override { + cm_service_impl_.reset(); + store_->ShutdownOnUIThread(); content::RenderViewHostTestHarness::TearDown(); } - void ExpectZeroClickSignInFailure() { + void ExpectZeroClickSignInFailure(bool zero_click_only, + bool include_passwords, + const std::vector<GURL>& federations) { + bool called = false; + mojom::CredentialManagerError error; + mojom::CredentialInfoPtr credential; + CallGet(zero_click_only, include_passwords, federations, + base::Bind(&GetCredentialCallback, &called, &error, &credential)); EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _, _)) .Times(testing::Exactly(0)); EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)) @@ -263,18 +283,20 @@ RunAllPendingTasks(); - const uint32_t kMsgID = CredentialManagerMsg_SendCredential::ID; - const IPC::Message* message = - process()->sink().GetFirstMessageMatching(kMsgID); - ASSERT_TRUE(message); - CredentialManagerMsg_SendCredential::Param send_param; - CredentialManagerMsg_SendCredential::Read(message, &send_param); - - EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY, - std::get<1>(send_param).type); + EXPECT_TRUE(called); + EXPECT_EQ(mojom::CredentialManagerError::SUCCESS, error); + EXPECT_EQ(mojom::CredentialType::EMPTY, credential->type); } - void ExpectZeroClickSignInSuccess(CredentialType type) { + void ExpectZeroClickSignInSuccess(bool zero_click_only, + bool include_passwords, + const std::vector<GURL>& federations, + mojom::CredentialType type) { + bool called = false; + mojom::CredentialManagerError error; + mojom::CredentialInfoPtr credential; + CallGet(zero_click_only, include_passwords, federations, + base::Bind(&GetCredentialCallback, &called, &error, &credential)); EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _, _)) .Times(testing::Exactly(0)); EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)) @@ -282,17 +304,50 @@ RunAllPendingTasks(); - const uint32_t kMsgID = CredentialManagerMsg_SendCredential::ID; - const IPC::Message* message = - process()->sink().GetFirstMessageMatching(kMsgID); - ASSERT_TRUE(message); - CredentialManagerMsg_SendCredential::Param send_param; - CredentialManagerMsg_SendCredential::Read(message, &send_param); - - EXPECT_EQ(type, std::get<1>(send_param).type); + EXPECT_TRUE(called); + EXPECT_EQ(mojom::CredentialManagerError::SUCCESS, error); + EXPECT_EQ(type, credential->type); } - CredentialManagerDispatcher* dispatcher() { return dispatcher_.get(); } + void ExpectCredentialType(bool zero_click_only, + bool include_passwords, + const std::vector<GURL>& federations, + mojom::CredentialType type) { + bool called = false; + mojom::CredentialManagerError error; + mojom::CredentialInfoPtr credential; + CallGet(zero_click_only, include_passwords, federations, + base::Bind(&GetCredentialCallback, &called, &error, &credential)); + + RunAllPendingTasks(); + + EXPECT_TRUE(called); + EXPECT_EQ(mojom::CredentialManagerError::SUCCESS, error); + EXPECT_EQ(type, credential->type); + } + + CredentialManagerImpl* cm_service_impl() { return cm_service_impl_.get(); } + + // Helpers for testing CredentialManagerImpl methods. + void CallStore(const CredentialInfo& info, + const CredentialManagerImpl::StoreCallback& callback) { + mojom::CredentialInfoPtr credential = mojom::CredentialInfo::From(info); + cm_service_impl_->Store(std::move(credential), callback); + } + + void CallRequireUserMediation( + const CredentialManagerImpl::RequireUserMediationCallback& callback) { + cm_service_impl_->RequireUserMediation(callback); + } + + void CallGet(bool zero_click_only, + bool include_passwords, + const std::vector<GURL>& federations, + const CredentialManagerImpl::GetCallback& callback) { + cm_service_impl_->Get(zero_click_only, include_passwords, + mojo::Array<mojo::String>::From(federations), + callback); + } protected: autofill::PasswordForm form_; @@ -303,46 +358,42 @@ scoped_refptr<TestPasswordStore> store_; std::unique_ptr<testing::NiceMock<MockPasswordManagerClient>> client_; std::unique_ptr<SlightlyLessStubbyPasswordManagerDriver> stub_driver_; - std::unique_ptr<CredentialManagerDispatcher> dispatcher_; + std::unique_ptr<CredentialManagerImpl> cm_service_impl_; }; -TEST_F(CredentialManagerDispatcherTest, IsZeroClickAllowed) { +TEST_F(CredentialManagerImplTest, IsZeroClickAllowed) { // IsZeroClickAllowed is uneffected by the first-run status. client_->set_zero_click_enabled(true); client_->set_first_run_seen(true); - EXPECT_TRUE(dispatcher()->IsZeroClickAllowed()); + EXPECT_TRUE(cm_service_impl()->IsZeroClickAllowed()); client_->set_zero_click_enabled(true); client_->set_first_run_seen(false); - EXPECT_TRUE(dispatcher()->IsZeroClickAllowed()); + EXPECT_TRUE(cm_service_impl()->IsZeroClickAllowed()); client_->set_zero_click_enabled(false); client_->set_first_run_seen(true); - EXPECT_FALSE(dispatcher()->IsZeroClickAllowed()); + EXPECT_FALSE(cm_service_impl()->IsZeroClickAllowed()); client_->set_zero_click_enabled(false); client_->set_first_run_seen(false); - EXPECT_FALSE(dispatcher()->IsZeroClickAllowed()); + EXPECT_FALSE(cm_service_impl()->IsZeroClickAllowed()); } -TEST_F(CredentialManagerDispatcherTest, CredentialManagerOnStore) { +TEST_F(CredentialManagerImplTest, CredentialManagerOnStore) { CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_PASSWORD); EXPECT_CALL(*client_, PromptUserToSavePasswordPtr( _, CredentialSourceType::CREDENTIAL_SOURCE_API)) .Times(testing::Exactly(1)); - dispatcher()->OnStore(kRequestId, info); - - const uint32_t kMsgID = CredentialManagerMsg_AcknowledgeStore::ID; - const IPC::Message* message = - process()->sink().GetFirstMessageMatching(kMsgID); - EXPECT_TRUE(message); - process()->sink().ClearMessages(); + bool called = false; + CallStore(info, base::Bind(&RespondCallback, &called)); // Allow the PasswordFormManager to talk to the password store, determine // that the form is new, and set it as pending. RunAllPendingTasks(); + EXPECT_TRUE(called); EXPECT_TRUE(client_->pending_manager()->HasCompletedMatching()); autofill::PasswordForm new_form = @@ -355,31 +406,28 @@ EXPECT_EQ(autofill::PasswordForm::SCHEME_HTML, new_form.scheme); } -TEST_F(CredentialManagerDispatcherTest, CredentialManagerStoreOverwrite) { +TEST_F(CredentialManagerImplTest, CredentialManagerStoreOverwrite) { // Populate the PasswordStore with a form. store_->AddLogin(form_); RunAllPendingTasks(); - // Calling 'OnStore' with a credential that matches |form_| should update + // Calling 'Store' with a credential that matches |form_| should update // the password without prompting the user. CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_PASSWORD); info.password = base::ASCIIToUTF16("Totally new password."); - dispatcher()->OnStore(kRequestId, info); + bool called = false; + CallStore(info, base::Bind(&RespondCallback, &called)); EXPECT_CALL(*client_, PromptUserToSavePasswordPtr( _, CredentialSourceType::CREDENTIAL_SOURCE_API)) .Times(testing::Exactly(0)); - const uint32_t kMsgID = CredentialManagerMsg_AcknowledgeStore::ID; - const IPC::Message* message = - process()->sink().GetFirstMessageMatching(kMsgID); - EXPECT_TRUE(message); - process()->sink().ClearMessages(); - // Allow the PasswordFormManager to talk to the password store, determine // the form is a match for an existing form, and update the PasswordStore. RunAllPendingTasks(); + EXPECT_TRUE(called); + TestPasswordStore::PasswordMap passwords = store_->stored_passwords(); EXPECT_EQ(1U, passwords.size()); EXPECT_EQ(1U, passwords[form_.signon_realm].size()); @@ -387,8 +435,7 @@ passwords[form_.signon_realm][0].password_value); } -TEST_F(CredentialManagerDispatcherTest, - CredentialManagerStoreOverwriteZeroClick) { +TEST_F(CredentialManagerImplTest, CredentialManagerStoreOverwriteZeroClick) { // Set the global zero click flag on, and populate the PasswordStore with a // form that's set to skip zero click. client_->set_zero_click_enabled(true); @@ -397,11 +444,11 @@ store_->AddLogin(form_); RunAllPendingTasks(); - // Calling 'OnStore' with a credential that matches |form_| should update + // Calling 'Store' with a credential that matches |form_| should update // the credential without prompting the user. CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_PASSWORD); - dispatcher()->OnStore(kRequestId, info); - process()->sink().ClearMessages(); + bool called = false; + CallStore(info, base::Bind(&RespondCallback, &called)); // Allow the PasswordFormManager to talk to the password store, determine // the form is a match for an existing form, and update the PasswordStore. @@ -412,7 +459,7 @@ EXPECT_FALSE(passwords[form_.signon_realm][0].skip_zero_click); } -TEST_F(CredentialManagerDispatcherTest, +TEST_F(CredentialManagerImplTest, CredentialManagerFederatedStoreOverwriteZeroClick) { // Set the global zero click flag on, and populate the PasswordStore with a // form that's set to skip zero click. @@ -424,11 +471,11 @@ store_->AddLogin(form_); RunAllPendingTasks(); - // Calling 'OnStore' with a credential that matches |form_| should update + // Calling 'Store' with a credential that matches |form_| should update // the credential without prompting the user. CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_FEDERATED); - dispatcher()->OnStore(kRequestId, info); - process()->sink().ClearMessages(); + bool called = false; + CallStore(info, base::Bind(&RespondCallback, &called)); // Allow the PasswordFormManager to talk to the password store, determine // the form is a match for an existing form, and update the PasswordStore. @@ -439,8 +486,7 @@ EXPECT_FALSE(passwords[form_.signon_realm][0].skip_zero_click); } -TEST_F(CredentialManagerDispatcherTest, - CredentialManagerGetOverwriteZeroClick) { +TEST_F(CredentialManagerImplTest, CredentialManagerGetOverwriteZeroClick) { // Set the global zero click flag on, and populate the PasswordStore with a // form that's set to skip zero click and has a primary key that won't match // credentials initially created via `store()`. @@ -458,21 +504,23 @@ .Times(testing::Exactly(1)); EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0)); - dispatcher()->OnRequestCredential(kRequestId, false, true, federations); + bool called = false; + mojom::CredentialManagerError error; + mojom::CredentialInfoPtr credential; + CallGet(false, true, federations, + base::Bind(&GetCredentialCallback, &called, &error, &credential)); RunAllPendingTasks(); - const uint32_t kMsgID = CredentialManagerMsg_SendCredential::ID; - const IPC::Message* message = - process()->sink().GetFirstMessageMatching(kMsgID); - EXPECT_TRUE(message); + EXPECT_TRUE(called); + EXPECT_EQ(mojom::CredentialManagerError::SUCCESS, error); // Verify that the update toggled the skip_zero_click flag. TestPasswordStore::PasswordMap passwords = store_->stored_passwords(); EXPECT_FALSE(passwords[form_.signon_realm][0].skip_zero_click); } -TEST_F(CredentialManagerDispatcherTest, +TEST_F(CredentialManagerImplTest, CredentialManagerSignInWithSavingDisabledForCurrentPage) { CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_PASSWORD); EXPECT_CALL(*client_, IsSavingAndFillingEnabledForCurrentPage()) @@ -481,21 +529,16 @@ _, CredentialSourceType::CREDENTIAL_SOURCE_API)) .Times(testing::Exactly(0)); - dispatcher()->OnStore(kRequestId, info); - - const uint32_t kMsgID = CredentialManagerMsg_AcknowledgeStore::ID; - const IPC::Message* message = - process()->sink().GetFirstMessageMatching(kMsgID); - EXPECT_TRUE(message); - process()->sink().ClearMessages(); + bool called = false; + CallStore(info, base::Bind(&RespondCallback, &called)); RunAllPendingTasks(); + EXPECT_TRUE(called); EXPECT_FALSE(client_->pending_manager()); } -TEST_F(CredentialManagerDispatcherTest, - CredentialManagerOnRequireUserMediation) { +TEST_F(CredentialManagerImplTest, CredentialManagerOnRequireUserMediation) { store_->AddLogin(form_); store_->AddLogin(cross_origin_form_); RunAllPendingTasks(); @@ -507,15 +550,12 @@ EXPECT_FALSE(passwords[form_.signon_realm][0].skip_zero_click); EXPECT_FALSE(passwords[cross_origin_form_.signon_realm][0].skip_zero_click); - dispatcher()->OnRequireUserMediation(kRequestId); + bool called = false; + CallRequireUserMediation(base::Bind(&RespondCallback, &called)); + RunAllPendingTasks(); - const uint32_t kMsgID = - CredentialManagerMsg_AcknowledgeRequireUserMediation::ID; - const IPC::Message* message = - process()->sink().GetFirstMessageMatching(kMsgID); - EXPECT_TRUE(message); - process()->sink().ClearMessages(); + EXPECT_TRUE(called); passwords = store_->stored_passwords(); EXPECT_EQ(2U, passwords.size()); @@ -525,7 +565,7 @@ EXPECT_FALSE(passwords[cross_origin_form_.signon_realm][0].skip_zero_click); } -TEST_F(CredentialManagerDispatcherTest, +TEST_F(CredentialManagerImplTest, CredentialManagerOnRequireUserMediationIncognito) { EXPECT_CALL(*client_, IsOffTheRecord()).WillRepeatedly(testing::Return(true)); store_->AddLogin(form_); @@ -536,15 +576,11 @@ ASSERT_EQ(1U, passwords[form_.signon_realm].size()); EXPECT_FALSE(passwords[form_.signon_realm][0].skip_zero_click); - dispatcher()->OnRequireUserMediation(kRequestId); + bool called = false; + CallRequireUserMediation(base::Bind(&RespondCallback, &called)); RunAllPendingTasks(); - const uint32_t kMsgID = - CredentialManagerMsg_AcknowledgeRequireUserMediation::ID; - const IPC::Message* message = - process()->sink().GetFirstMessageMatching(kMsgID); - EXPECT_TRUE(message); - process()->sink().ClearMessages(); + EXPECT_TRUE(called); passwords = store_->stored_passwords(); ASSERT_EQ(1U, passwords.size()); @@ -552,7 +588,7 @@ EXPECT_FALSE(passwords[form_.signon_realm][0].skip_zero_click); } -TEST_F(CredentialManagerDispatcherTest, +TEST_F(CredentialManagerImplTest, CredentialManagerOnRequireUserMediationWithAffiliation) { store_->AddLogin(form_); store_->AddLogin(cross_origin_form_); @@ -567,7 +603,7 @@ affiliated_realms.push_back(kTestAndroidRealm1); static_cast<MockAffiliatedMatchHelper*>(store_->affiliated_match_helper()) ->ExpectCallToGetAffiliatedAndroidRealms( - dispatcher_->GetSynthesizedFormForOrigin(), affiliated_realms); + cm_service_impl_->GetSynthesizedFormForOrigin(), affiliated_realms); RunAllPendingTasks(); TestPasswordStore::PasswordMap passwords = store_->stored_passwords(); @@ -577,9 +613,9 @@ EXPECT_FALSE(passwords[affiliated_form1_.signon_realm][0].skip_zero_click); EXPECT_FALSE(passwords[affiliated_form2_.signon_realm][0].skip_zero_click); - dispatcher()->OnRequireUserMediation(kRequestId); + bool called = false; + CallRequireUserMediation(base::Bind(&RespondCallback, &called)); RunAllPendingTasks(); - process()->sink().ClearMessages(); passwords = store_->stored_passwords(); EXPECT_EQ(4U, passwords.size()); @@ -589,7 +625,7 @@ EXPECT_FALSE(passwords[affiliated_form2_.signon_realm][0].skip_zero_click); } -TEST_F(CredentialManagerDispatcherTest, +TEST_F(CredentialManagerImplTest, CredentialManagerOnRequestCredentialWithEmptyPasswordStore) { std::vector<GURL> federations; EXPECT_CALL(*client_, PromptUserToSavePasswordPtr( @@ -599,21 +635,10 @@ .Times(testing::Exactly(0)); EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0)); - dispatcher()->OnRequestCredential(kRequestId, false, true, federations); - - RunAllPendingTasks(); - - const uint32_t kMsgID = CredentialManagerMsg_SendCredential::ID; - const IPC::Message* message = - process()->sink().GetFirstMessageMatching(kMsgID); - EXPECT_TRUE(message); - CredentialManagerMsg_SendCredential::Param param; - CredentialManagerMsg_SendCredential::Read(message, ¶m); - EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY, std::get<1>(param).type); - process()->sink().ClearMessages(); + ExpectCredentialType(false, true, federations, mojom::CredentialType::EMPTY); } -TEST_F(CredentialManagerDispatcherTest, +TEST_F(CredentialManagerImplTest, CredentialManagerOnRequestCredentialWithCrossOriginPasswordStore) { store_->AddLogin(cross_origin_form_); @@ -625,21 +650,10 @@ .Times(testing::Exactly(0)); EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0)); - dispatcher()->OnRequestCredential(kRequestId, false, true, federations); - - RunAllPendingTasks(); - - const uint32_t kMsgID = CredentialManagerMsg_SendCredential::ID; - const IPC::Message* message = - process()->sink().GetFirstMessageMatching(kMsgID); - EXPECT_TRUE(message); - CredentialManagerMsg_SendCredential::Param param; - CredentialManagerMsg_SendCredential::Read(message, ¶m); - EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY, std::get<1>(param).type); - process()->sink().ClearMessages(); + ExpectCredentialType(false, true, federations, mojom::CredentialType::EMPTY); } -TEST_F(CredentialManagerDispatcherTest, +TEST_F(CredentialManagerImplTest, CredentialManagerOnRequestCredentialWithFullPasswordStore) { client_->set_zero_click_enabled(false); store_->AddLogin(form_); @@ -649,39 +663,39 @@ .Times(testing::Exactly(1)); EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0)); - dispatcher()->OnRequestCredential(kRequestId, false, true, federations); + bool called = false; + mojom::CredentialManagerError error; + mojom::CredentialInfoPtr credential; + CallGet(false, true, federations, + base::Bind(&GetCredentialCallback, &called, &error, &credential)); RunAllPendingTasks(); - const uint32_t kMsgID = CredentialManagerMsg_SendCredential::ID; - const IPC::Message* message = - process()->sink().GetFirstMessageMatching(kMsgID); - EXPECT_TRUE(message); + EXPECT_TRUE(called); + EXPECT_EQ(mojom::CredentialManagerError::SUCCESS, error); } TEST_F( - CredentialManagerDispatcherTest, + CredentialManagerImplTest, CredentialManagerOnRequestCredentialWithZeroClickOnlyEmptyPasswordStore) { std::vector<GURL> federations; EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _, _)) .Times(testing::Exactly(0)); EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0)); - dispatcher()->OnRequestCredential(kRequestId, true, true, federations); + bool called = false; + mojom::CredentialManagerError error; + mojom::CredentialInfoPtr credential; + CallGet(true, true, federations, + base::Bind(&GetCredentialCallback, &called, &error, &credential)); RunAllPendingTasks(); - const uint32_t kMsgID = CredentialManagerMsg_SendCredential::ID; - const IPC::Message* message = - process()->sink().GetFirstMessageMatching(kMsgID); - EXPECT_TRUE(message); - CredentialManagerMsg_SendCredential::Param send_param; - CredentialManagerMsg_SendCredential::Read(message, &send_param); - EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY, - std::get<1>(send_param).type); + EXPECT_TRUE(called); + EXPECT_EQ(mojom::CredentialManagerError::SUCCESS, error); } -TEST_F(CredentialManagerDispatcherTest, +TEST_F(CredentialManagerImplTest, CredentialManagerOnRequestCredentialWithZeroClickOnlyFullPasswordStore) { store_->AddLogin(form_); client_->set_first_run_seen(true); @@ -689,12 +703,12 @@ std::vector<GURL> federations; EXPECT_CALL(*client_, NotifyUserCouldBeAutoSignedInPtr(_)).Times(0); - dispatcher()->OnRequestCredential(kRequestId, true, true, federations); - ExpectZeroClickSignInSuccess(CredentialType::CREDENTIAL_TYPE_PASSWORD); + ExpectZeroClickSignInSuccess(true, true, federations, + mojom::CredentialType::PASSWORD); } -TEST_F(CredentialManagerDispatcherTest, +TEST_F(CredentialManagerImplTest, CredentialManagerOnRequestCredentialWithoutPasswords) { store_->AddLogin(form_); client_->set_first_run_seen(true); @@ -702,12 +716,11 @@ std::vector<GURL> federations; EXPECT_CALL(*client_, NotifyUserCouldBeAutoSignedInPtr(_)).Times(0); - dispatcher()->OnRequestCredential(kRequestId, true, false, federations); - ExpectZeroClickSignInFailure(); + ExpectZeroClickSignInFailure(true, false, federations); } -TEST_F(CredentialManagerDispatcherTest, +TEST_F(CredentialManagerImplTest, CredentialManagerOnRequestCredentialFederatedMatch) { form_.federation_origin = url::Origin(GURL("https://example.com/")); store_->AddLogin(form_); @@ -717,12 +730,12 @@ federations.push_back(GURL("https://example.com/")); EXPECT_CALL(*client_, NotifyUserCouldBeAutoSignedInPtr(_)).Times(0); - dispatcher()->OnRequestCredential(kRequestId, true, true, federations); - ExpectZeroClickSignInSuccess(CredentialType::CREDENTIAL_TYPE_FEDERATED); + ExpectZeroClickSignInSuccess(true, true, federations, + mojom::CredentialType::FEDERATED); } -TEST_F(CredentialManagerDispatcherTest, +TEST_F(CredentialManagerImplTest, CredentialManagerOnRequestCredentialFederatedNoMatch) { form_.federation_origin = url::Origin(GURL("https://example.com/")); store_->AddLogin(form_); @@ -732,12 +745,11 @@ federations.push_back(GURL("https://not-example.com/")); EXPECT_CALL(*client_, NotifyUserCouldBeAutoSignedInPtr(_)).Times(0); - dispatcher()->OnRequestCredential(kRequestId, true, true, federations); - ExpectZeroClickSignInFailure(); + ExpectZeroClickSignInFailure(true, true, federations); } -TEST_F(CredentialManagerDispatcherTest, +TEST_F(CredentialManagerImplTest, CredentialManagerOnRequestCredentialAffiliatedPasswordMatch) { store_->AddLogin(affiliated_form1_); client_->set_first_run_seen(true); @@ -749,16 +761,15 @@ affiliated_realms.push_back(kTestAndroidRealm1); static_cast<MockAffiliatedMatchHelper*>(store_->affiliated_match_helper()) ->ExpectCallToGetAffiliatedAndroidRealms( - dispatcher_->GetSynthesizedFormForOrigin(), affiliated_realms); + cm_service_impl_->GetSynthesizedFormForOrigin(), affiliated_realms); // We pass in 'true' for the 'include_passwords' argument to ensure that // password-type credentials are included as potential matches. - dispatcher()->OnRequestCredential(kRequestId, true, true, federations); - - ExpectZeroClickSignInSuccess(CredentialType::CREDENTIAL_TYPE_PASSWORD); + ExpectZeroClickSignInSuccess(true, true, federations, + mojom::CredentialType::PASSWORD); } -TEST_F(CredentialManagerDispatcherTest, +TEST_F(CredentialManagerImplTest, CredentialManagerOnRequestCredentialAffiliatedPasswordNoMatch) { store_->AddLogin(affiliated_form1_); client_->set_first_run_seen(true); @@ -770,16 +781,14 @@ affiliated_realms.push_back(kTestAndroidRealm1); static_cast<MockAffiliatedMatchHelper*>(store_->affiliated_match_helper()) ->ExpectCallToGetAffiliatedAndroidRealms( - dispatcher_->GetSynthesizedFormForOrigin(), affiliated_realms); + cm_service_impl_->GetSynthesizedFormForOrigin(), affiliated_realms); // We pass in 'false' for the 'include_passwords' argument to ensure that // password-type credentials are excluded as potential matches. - dispatcher()->OnRequestCredential(kRequestId, true, false, federations); - - ExpectZeroClickSignInFailure(); + ExpectZeroClickSignInFailure(true, false, federations); } -TEST_F(CredentialManagerDispatcherTest, +TEST_F(CredentialManagerImplTest, CredentialManagerOnRequestCredentialAffiliatedFederatedMatch) { affiliated_form1_.federation_origin = url::Origin(GURL("https://example.com/")); @@ -795,14 +804,13 @@ affiliated_realms.push_back(kTestAndroidRealm1); static_cast<MockAffiliatedMatchHelper*>(store_->affiliated_match_helper()) ->ExpectCallToGetAffiliatedAndroidRealms( - dispatcher_->GetSynthesizedFormForOrigin(), affiliated_realms); + cm_service_impl_->GetSynthesizedFormForOrigin(), affiliated_realms); - dispatcher()->OnRequestCredential(kRequestId, true, true, federations); - - ExpectZeroClickSignInSuccess(CredentialType::CREDENTIAL_TYPE_FEDERATED); + ExpectZeroClickSignInSuccess(true, true, federations, + mojom::CredentialType::FEDERATED); } -TEST_F(CredentialManagerDispatcherTest, +TEST_F(CredentialManagerImplTest, CredentialManagerOnRequestCredentialAffiliatedFederatedNoMatch) { affiliated_form1_.federation_origin = url::Origin(GURL("https://example.com/")); @@ -818,14 +826,12 @@ affiliated_realms.push_back(kTestAndroidRealm1); static_cast<MockAffiliatedMatchHelper*>(store_->affiliated_match_helper()) ->ExpectCallToGetAffiliatedAndroidRealms( - dispatcher_->GetSynthesizedFormForOrigin(), affiliated_realms); + cm_service_impl_->GetSynthesizedFormForOrigin(), affiliated_realms); - dispatcher()->OnRequestCredential(kRequestId, true, true, federations); - - ExpectZeroClickSignInFailure(); + ExpectZeroClickSignInFailure(true, true, federations); } -TEST_F(CredentialManagerDispatcherTest, RequestCredentialWithoutFirstRun) { +TEST_F(CredentialManagerImplTest, RequestCredentialWithoutFirstRun) { client_->set_first_run_seen(false); store_->AddLogin(form_); @@ -834,12 +840,11 @@ EXPECT_CALL(*client_, NotifyUserCouldBeAutoSignedInPtr(testing::Pointee(form_))) .Times(1); - dispatcher()->OnRequestCredential(kRequestId, true, true, federations); - ExpectZeroClickSignInFailure(); + ExpectZeroClickSignInFailure(true, true, federations); } -TEST_F(CredentialManagerDispatcherTest, RequestCredentialWithFirstRunAndSkip) { +TEST_F(CredentialManagerImplTest, RequestCredentialWithFirstRunAndSkip) { client_->set_first_run_seen(true); form_.skip_zero_click = true; @@ -849,12 +854,11 @@ EXPECT_CALL(*client_, NotifyUserCouldBeAutoSignedInPtr(testing::Pointee(form_))) .Times(1); - dispatcher()->OnRequestCredential(kRequestId, true, true, federations); - ExpectZeroClickSignInFailure(); + ExpectZeroClickSignInFailure(true, true, federations); } -TEST_F(CredentialManagerDispatcherTest, RequestCredentialWithTLSErrors) { +TEST_F(CredentialManagerImplTest, RequestCredentialWithTLSErrors) { // If we encounter TLS errors, we won't return credentials. EXPECT_CALL(*client_, DidLastPageLoadEncounterSSLErrors()) .WillRepeatedly(testing::Return(true)); @@ -862,12 +866,11 @@ store_->AddLogin(form_); std::vector<GURL> federations; - dispatcher()->OnRequestCredential(kRequestId, true, true, federations); - ExpectZeroClickSignInFailure(); + ExpectZeroClickSignInFailure(true, true, federations); } -TEST_F(CredentialManagerDispatcherTest, +TEST_F(CredentialManagerImplTest, CredentialManagerOnRequestCredentialWithZeroClickOnlyTwoPasswordStore) { store_->AddLogin(form_); store_->AddLogin(origin_path_form_); @@ -877,23 +880,11 @@ .Times(testing::Exactly(0)); EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0)); - dispatcher()->OnRequestCredential(kRequestId, true, true, federations); - - RunAllPendingTasks(); - - const uint32_t kMsgID = CredentialManagerMsg_SendCredential::ID; - const IPC::Message* message = - process()->sink().GetFirstMessageMatching(kMsgID); - EXPECT_TRUE(message); - CredentialManagerMsg_SendCredential::Param send_param; - CredentialManagerMsg_SendCredential::Read(message, &send_param); - // With two items in the password store, we shouldn't get credentials back. - EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY, - std::get<1>(send_param).type); + ExpectCredentialType(true, true, federations, mojom::CredentialType::EMPTY); } -TEST_F(CredentialManagerDispatcherTest, +TEST_F(CredentialManagerImplTest, OnRequestCredentialWithZeroClickOnlyAndSkipZeroClickPasswordStore) { form_.skip_zero_click = true; store_->AddLogin(form_); @@ -904,24 +895,12 @@ .Times(testing::Exactly(0)); EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0)); - dispatcher()->OnRequestCredential(kRequestId, true, true, federations); - - RunAllPendingTasks(); - - const uint32_t kMsgID = CredentialManagerMsg_SendCredential::ID; - const IPC::Message* message = - process()->sink().GetFirstMessageMatching(kMsgID); - EXPECT_TRUE(message); - CredentialManagerMsg_SendCredential::Param send_param; - CredentialManagerMsg_SendCredential::Read(message, &send_param); - // With two items in the password store, we shouldn't get credentials back, // even though only one item has |skip_zero_click| set |false|. - EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY, - std::get<1>(send_param).type); + ExpectCredentialType(true, true, federations, mojom::CredentialType::EMPTY); } -TEST_F(CredentialManagerDispatcherTest, +TEST_F(CredentialManagerImplTest, OnRequestCredentialWithZeroClickOnlyCrossOriginPasswordStore) { store_->AddLogin(cross_origin_form_); @@ -933,24 +912,12 @@ .Times(testing::Exactly(0)); EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0)); - dispatcher()->OnRequestCredential(kRequestId, true, true, federations); - - RunAllPendingTasks(); - - const uint32_t kMsgID = CredentialManagerMsg_SendCredential::ID; - const IPC::Message* message = - process()->sink().GetFirstMessageMatching(kMsgID); - EXPECT_TRUE(message); - CredentialManagerMsg_SendCredential::Param send_param; - CredentialManagerMsg_SendCredential::Read(message, &send_param); - // We only have cross-origin zero-click credentials; they should not be // returned. - EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY, - std::get<1>(send_param).type); + ExpectCredentialType(true, true, federations, mojom::CredentialType::EMPTY); } -TEST_F(CredentialManagerDispatcherTest, +TEST_F(CredentialManagerImplTest, CredentialManagerOnRequestCredentialWhileRequestPending) { client_->set_zero_click_enabled(false); store_->AddLogin(form_); @@ -960,40 +927,40 @@ .Times(testing::Exactly(0)); EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0)); - dispatcher()->OnRequestCredential(kRequestId, false, true, federations); - dispatcher()->OnRequestCredential(kRequestId + 1, false, true, federations); + // 1st request. + bool called_1 = false; + mojom::CredentialManagerError error_1; + mojom::CredentialInfoPtr credential_1; + CallGet( + false, true, federations, + base::Bind(&GetCredentialCallback, &called_1, &error_1, &credential_1)); + // 2nd request. + bool called_2 = false; + mojom::CredentialManagerError error_2; + mojom::CredentialInfoPtr credential_2; + CallGet( + false, true, federations, + base::Bind(&GetCredentialCallback, &called_2, &error_2, &credential_2)); - // Check that the second request triggered a rejection. - uint32_t kMsgID = CredentialManagerMsg_RejectCredentialRequest::ID; - const IPC::Message* message = - process()->sink().GetFirstMessageMatching(kMsgID); - EXPECT_TRUE(message); - - CredentialManagerMsg_RejectCredentialRequest::Param reject_param; - CredentialManagerMsg_RejectCredentialRequest::Read(message, &reject_param); - EXPECT_EQ(blink::WebCredentialManagerPendingRequestError, - std::get<1>(reject_param)); EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _, _)) .Times(testing::Exactly(1)); EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0)); - process()->sink().ClearMessages(); - // Execute the PasswordStore asynchronousness. RunAllPendingTasks(); + // Check that the second request triggered a rejection. + EXPECT_TRUE(called_2); + EXPECT_EQ(mojom::CredentialManagerError::PENDINGREQUEST, error_2); + EXPECT_TRUE(credential_2.is_null()); + // Check that the first request resolves. - kMsgID = CredentialManagerMsg_SendCredential::ID; - message = process()->sink().GetFirstMessageMatching(kMsgID); - EXPECT_TRUE(message); - CredentialManagerMsg_SendCredential::Param send_param; - CredentialManagerMsg_SendCredential::Read(message, &send_param); - EXPECT_NE(CredentialType::CREDENTIAL_TYPE_EMPTY, - std::get<1>(send_param).type); - process()->sink().ClearMessages(); + EXPECT_TRUE(called_1); + EXPECT_EQ(mojom::CredentialManagerError::SUCCESS, error_1); + EXPECT_NE(mojom::CredentialType::EMPTY, credential_1->type); } -TEST_F(CredentialManagerDispatcherTest, ResetSkipZeroClickAfterPrompt) { +TEST_F(CredentialManagerImplTest, ResetSkipZeroClickAfterPrompt) { // Turn on the global zero-click flag, and add two credentials in separate // origins, both set to skip zero-click. client_->set_zero_click_enabled(true); @@ -1026,7 +993,12 @@ .Times(testing::Exactly(1)); EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0)); - dispatcher()->OnRequestCredential(kRequestId, false, true, federations); + bool called = false; + mojom::CredentialManagerError error; + mojom::CredentialInfoPtr credential; + CallGet(false, true, federations, + base::Bind(&GetCredentialCallback, &called, &error, &credential)); + RunAllPendingTasks(); passwords = store_->stored_passwords(); @@ -1037,8 +1009,7 @@ EXPECT_TRUE(passwords[cross_origin_form_.signon_realm][0].skip_zero_click); } -TEST_F(CredentialManagerDispatcherTest, - NoResetSkipZeroClickAfterPromptInIncognito) { +TEST_F(CredentialManagerImplTest, NoResetSkipZeroClickAfterPromptInIncognito) { EXPECT_CALL(*client_, IsOffTheRecord()).WillRepeatedly(testing::Return(true)); // Turn on the global zero-click flag which should be overriden by Incognito. client_->set_zero_click_enabled(true); @@ -1058,8 +1029,12 @@ .Times(testing::Exactly(1)); EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0)); - dispatcher()->OnRequestCredential(kRequestId, false, true, - std::vector<GURL>()); + bool called = false; + mojom::CredentialManagerError error; + mojom::CredentialInfoPtr credential; + CallGet(false, true, std::vector<GURL>(), + base::Bind(&GetCredentialCallback, &called, &error, &credential)); + RunAllPendingTasks(); // The form shouldn't become a zero-click one. @@ -1069,7 +1044,7 @@ EXPECT_TRUE(passwords[form_.signon_realm][0].skip_zero_click); } -TEST_F(CredentialManagerDispatcherTest, IncognitoZeroClickRequestCredential) { +TEST_F(CredentialManagerImplTest, IncognitoZeroClickRequestCredential) { EXPECT_CALL(*client_, IsOffTheRecord()).WillRepeatedly(testing::Return(true)); store_->AddLogin(form_); @@ -1078,21 +1053,10 @@ .Times(testing::Exactly(0)); EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0)); - dispatcher()->OnRequestCredential(kRequestId, true, true, federations); - - RunAllPendingTasks(); - - const uint32_t kMsgID = CredentialManagerMsg_SendCredential::ID; - const IPC::Message* message = - process()->sink().GetFirstMessageMatching(kMsgID); - ASSERT_TRUE(message); - CredentialManagerMsg_SendCredential::Param param; - CredentialManagerMsg_SendCredential::Read(message, ¶m); - EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY, std::get<1>(param).type); + ExpectCredentialType(true, true, federations, mojom::CredentialType::EMPTY); } -TEST_F(CredentialManagerDispatcherTest, - ZeroClickWithAffiliatedFormInPasswordStore) { +TEST_F(CredentialManagerImplTest, ZeroClickWithAffiliatedFormInPasswordStore) { // Insert the affiliated form into the store, and mock out the association // with the current origin. As it's the only form matching the origin, it // ought to be returned automagically. @@ -1106,14 +1070,13 @@ affiliated_realms.push_back(kTestAndroidRealm1); static_cast<MockAffiliatedMatchHelper*>(store_->affiliated_match_helper()) ->ExpectCallToGetAffiliatedAndroidRealms( - dispatcher_->GetSynthesizedFormForOrigin(), affiliated_realms); + cm_service_impl_->GetSynthesizedFormForOrigin(), affiliated_realms); - dispatcher()->OnRequestCredential(kRequestId, true, true, federations); - - ExpectZeroClickSignInSuccess(CredentialType::CREDENTIAL_TYPE_PASSWORD); + ExpectZeroClickSignInSuccess(true, true, federations, + mojom::CredentialType::PASSWORD); } -TEST_F(CredentialManagerDispatcherTest, +TEST_F(CredentialManagerImplTest, ZeroClickWithTwoAffiliatedFormsInPasswordStore) { // Insert two affiliated forms into the store, and mock out the association // with the current origin. Multiple forms === no zero-click sign in. @@ -1129,14 +1092,12 @@ affiliated_realms.push_back(kTestAndroidRealm2); static_cast<MockAffiliatedMatchHelper*>(store_->affiliated_match_helper()) ->ExpectCallToGetAffiliatedAndroidRealms( - dispatcher_->GetSynthesizedFormForOrigin(), affiliated_realms); + cm_service_impl_->GetSynthesizedFormForOrigin(), affiliated_realms); - dispatcher()->OnRequestCredential(kRequestId, true, true, federations); - - ExpectZeroClickSignInFailure(); + ExpectZeroClickSignInFailure(true, true, federations); } -TEST_F(CredentialManagerDispatcherTest, +TEST_F(CredentialManagerImplTest, ZeroClickWithUnaffiliatedFormsInPasswordStore) { // Insert the affiliated form into the store, but don't mock out the // association with the current origin. No association === no zero-click sign @@ -1150,14 +1111,12 @@ std::vector<std::string> affiliated_realms; static_cast<MockAffiliatedMatchHelper*>(store_->affiliated_match_helper()) ->ExpectCallToGetAffiliatedAndroidRealms( - dispatcher_->GetSynthesizedFormForOrigin(), affiliated_realms); + cm_service_impl_->GetSynthesizedFormForOrigin(), affiliated_realms); - dispatcher()->OnRequestCredential(kRequestId, true, true, federations); - - ExpectZeroClickSignInFailure(); + ExpectZeroClickSignInFailure(true, true, federations); } -TEST_F(CredentialManagerDispatcherTest, +TEST_F(CredentialManagerImplTest, ZeroClickWithFormAndUnaffiliatedFormsInPasswordStore) { // Insert the affiliated form into the store, along with a real form for the // origin, and don't mock out the association with the current origin. No @@ -1172,16 +1131,15 @@ std::vector<std::string> affiliated_realms; static_cast<MockAffiliatedMatchHelper*>(store_->affiliated_match_helper()) ->ExpectCallToGetAffiliatedAndroidRealms( - dispatcher_->GetSynthesizedFormForOrigin(), affiliated_realms); + cm_service_impl_->GetSynthesizedFormForOrigin(), affiliated_realms); - dispatcher()->OnRequestCredential(kRequestId, true, true, federations); - - ExpectZeroClickSignInSuccess(CredentialType::CREDENTIAL_TYPE_PASSWORD); + ExpectZeroClickSignInSuccess(true, true, federations, + mojom::CredentialType::PASSWORD); } -TEST_F(CredentialManagerDispatcherTest, GetSynthesizedFormForOrigin) { +TEST_F(CredentialManagerImplTest, GetSynthesizedFormForOrigin) { autofill::PasswordForm synthesized = - dispatcher_->GetSynthesizedFormForOrigin(); + cm_service_impl_->GetSynthesizedFormForOrigin(); EXPECT_EQ(kTestWebOrigin, synthesized.origin.spec()); EXPECT_EQ(kTestWebOrigin, synthesized.signon_realm); EXPECT_EQ(autofill::PasswordForm::SCHEME_HTML, synthesized.scheme);
diff --git a/components/password_manager/content/common/BUILD.gn b/components/password_manager/content/common/BUILD.gn deleted file mode 100644 index 3fb2464..0000000 --- a/components/password_manager/content/common/BUILD.gn +++ /dev/null
@@ -1,22 +0,0 @@ -# Copyright 2014 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. - -static_library("common") { - sources = [ - "credential_manager_content_utils.cc", - "credential_manager_content_utils.h", - "credential_manager_message_generator.cc", - "credential_manager_message_generator.h", - "credential_manager_messages.h", - ] - - deps = [ - "//base", - "//components/password_manager/core/common", - "//content/public/common", - "//ipc", - "//third_party/WebKit/public:blink_headers", - "//url", - ] -}
diff --git a/components/password_manager/content/common/DEPS b/components/password_manager/content/common/DEPS deleted file mode 100644 index c3505fa..0000000 --- a/components/password_manager/content/common/DEPS +++ /dev/null
@@ -1,4 +0,0 @@ -include_rules = [ - "+content/public/common", - "+ipc", -]
diff --git a/components/password_manager/content/common/OWNERS b/components/password_manager/content/common/OWNERS deleted file mode 100644 index 790e6d7..0000000 --- a/components/password_manager/content/common/OWNERS +++ /dev/null
@@ -1,13 +0,0 @@ -# Changes to IPC messages require a security review to avoid introducing -# new sandbox escapes. -per-file credential_manager_messages*.h=set noparent -per-file credential_manager_messages*.h=dcheng@chromium.org -per-file credential_manager_messages*.h=inferno@chromium.org -per-file credential_manager_messages*.h=jln@chromium.org -per-file credential_manager_messages*.h=jschuh@chromium.org -per-file credential_manager_messages*.h=kenrb@chromium.org -per-file credential_manager_messages*.h=mkwst@chromium.org -per-file credential_manager_messages*.h=nasko@chromium.org -per-file credential_manager_messages*.h=palmer@chromium.org -per-file credential_manager_messages*.h=tsepez@chromium.org -per-file credential_manager_messages*.h=wfh@chromium.org
diff --git a/components/password_manager/content/common/credential_manager_content_utils.cc b/components/password_manager/content/common/credential_manager_content_utils.cc deleted file mode 100644 index 6205abd..0000000 --- a/components/password_manager/content/common/credential_manager_content_utils.cc +++ /dev/null
@@ -1,36 +0,0 @@ -// Copyright 2015 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 "components/password_manager/content/common/credential_manager_content_utils.h" - -#include "base/logging.h" -#include "third_party/WebKit/public/platform/WebCredential.h" -#include "third_party/WebKit/public/platform/WebFederatedCredential.h" -#include "third_party/WebKit/public/platform/WebPasswordCredential.h" - -namespace password_manager { - -CredentialInfo WebCredentialToCredentialInfo( - const blink::WebCredential& credential) { - CredentialInfo credential_info; - credential_info.id = credential.id(); - credential_info.name = credential.name(); - credential_info.icon = credential.iconURL(); - credential_info.type = credential.isPasswordCredential() - ? CredentialType::CREDENTIAL_TYPE_PASSWORD - : CredentialType::CREDENTIAL_TYPE_FEDERATED; - if (credential_info.type == CredentialType::CREDENTIAL_TYPE_PASSWORD) { - DCHECK(credential.isPasswordCredential()); - credential_info.password = - static_cast<const blink::WebPasswordCredential&>(credential).password(); - } else { - DCHECK(credential.isFederatedCredential()); - credential_info.federation = - static_cast<const blink::WebFederatedCredential&>(credential) - .provider(); - } - return credential_info; -} - -} // namespace password_manager
diff --git a/components/password_manager/content/common/credential_manager_content_utils.h b/components/password_manager/content/common/credential_manager_content_utils.h deleted file mode 100644 index 77315f7..0000000 --- a/components/password_manager/content/common/credential_manager_content_utils.h +++ /dev/null
@@ -1,22 +0,0 @@ -// Copyright 2015 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_PASSWORD_MANAGER_CONTENT_COMMON_CREDENTIAL_MANAGER_CONTENT_UTILS_H_ -#define COMPONENTS_PASSWORD_MANAGER_CONTENT_COMMON_CREDENTIAL_MANAGER_CONTENT_UTILS_H_ - -#include "components/password_manager/core/common/credential_manager_types.h" - -namespace blink { -class WebCredential; -}; - -namespace password_manager { - -// Returns a CredentialInfo struct populated from |credential|. -CredentialInfo WebCredentialToCredentialInfo( - const blink::WebCredential& credential); - -} // namespace password_manager - -#endif // COMPONENTS_PASSWORD_MANAGER_CONTENT_COMMON_CREDENTIAL_MANAGER_CONTENT_UTILS_H_
diff --git a/components/password_manager/content/common/credential_manager_message_generator.cc b/components/password_manager/content/common/credential_manager_message_generator.cc deleted file mode 100644 index 55eaf88..0000000 --- a/components/password_manager/content/common/credential_manager_message_generator.cc +++ /dev/null
@@ -1,33 +0,0 @@ -// Copyright 2014 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. - -// Get basic type definitions. -#define IPC_MESSAGE_IMPL -#include "components/password_manager/content/common/credential_manager_message_generator.h" - -// Generate constructors. -#include "ipc/struct_constructor_macros.h" -#include "components/password_manager/content/common/credential_manager_message_generator.h" - -// Generate destructors. -#include "ipc/struct_destructor_macros.h" -#include "components/password_manager/content/common/credential_manager_message_generator.h" - -// Generate param traits write methods. -#include "ipc/param_traits_write_macros.h" -namespace IPC { -#include "components/password_manager/content/common/credential_manager_message_generator.h" -} // namespace IPC - -// Generate param traits read methods. -#include "ipc/param_traits_read_macros.h" -namespace IPC { -#include "components/password_manager/content/common/credential_manager_message_generator.h" -} // namespace IPC - -// Generate param traits log methods. -#include "ipc/param_traits_log_macros.h" -namespace IPC { -#include "components/password_manager/content/common/credential_manager_message_generator.h" -} // namespace IPC
diff --git a/components/password_manager/content/common/credential_manager_message_generator.h b/components/password_manager/content/common/credential_manager_message_generator.h deleted file mode 100644 index c818a138..0000000 --- a/components/password_manager/content/common/credential_manager_message_generator.h +++ /dev/null
@@ -1,7 +0,0 @@ -// Copyright 2014 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. - -// Multiply-included file, hence no include guard. - -#include "components/password_manager/content/common/credential_manager_messages.h"
diff --git a/components/password_manager/content/common/credential_manager_messages.h b/components/password_manager/content/common/credential_manager_messages.h deleted file mode 100644 index 6ac642f..0000000 --- a/components/password_manager/content/common/credential_manager_messages.h +++ /dev/null
@@ -1,86 +0,0 @@ -// Copyright 2014 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. - -// Message definition file, included multiple times, hence no include guard. - -#include <string> -#include <vector> - -#include "base/strings/string16.h" -#include "components/password_manager/core/common/credential_manager_types.h" -#include "content/public/common/common_param_traits.h" -#include "ipc/ipc_message_macros.h" -#include "ipc/ipc_message_utils.h" -#include "third_party/WebKit/public/platform/WebCredentialManagerError.h" -#include "url/gurl.h" -#include "url/ipc/url_param_traits.h" - -#define IPC_MESSAGE_START CredentialManagerMsgStart - -IPC_ENUM_TRAITS_MAX_VALUE( - password_manager::CredentialType, - password_manager::CredentialType::CREDENTIAL_TYPE_LAST) - -IPC_ENUM_TRAITS_MAX_VALUE(blink::WebCredentialManagerError, - blink::WebCredentialManagerErrorLastType) - -IPC_STRUCT_TRAITS_BEGIN(password_manager::CredentialInfo) - IPC_STRUCT_TRAITS_MEMBER(type) - IPC_STRUCT_TRAITS_MEMBER(id) - IPC_STRUCT_TRAITS_MEMBER(name) - IPC_STRUCT_TRAITS_MEMBER(icon) - IPC_STRUCT_TRAITS_MEMBER(password) - IPC_STRUCT_TRAITS_MEMBER(federation) -IPC_STRUCT_TRAITS_END() - -// ---------------------------------------------------------------------------- -// Messages sent from the renderer to the browser - -// Passes the notification from 'navigator.credentials.store()' up to -// the browser process in order to (among other things) prompt the user to save -// the credential she used for signin. The browser process will respond with a -// CredentialManagerMsg_AcknowledgeStore message. -IPC_MESSAGE_ROUTED2(CredentialManagerHostMsg_Store, - int /* request_id */, - password_manager::CredentialInfo /* credential */) - -// Passes the notification from 'navigator.credentials.requireUserMediation()' -// up to the browser process in order to clear the "zeroclick" bit on that -// origin's stored credentials. The browser process will respond with a -// CredentialManagerMsg_AcknowledgeRequireUserMediation message. -IPC_MESSAGE_ROUTED1(CredentialManagerHostMsg_RequireUserMediation, - int /* request_id */) - -// Requests a credential from the browser process in response to a page calling -// 'navigator.credentials.get()'. The browser process will respond with a -// CredentialManagerMsg_SendCredential message. -IPC_MESSAGE_ROUTED4(CredentialManagerHostMsg_RequestCredential, - int /* request_id */, - bool /* zero_click_only */, - bool /* include_passwords */, - std::vector<GURL> /* federations */) - -// ---------------------------------------------------------------------------- -// Messages sent from the browser to the renderer - -// Notify the renderer that the browser process has finished processing a -// CredentialManagerHostMsg_Store message. -IPC_MESSAGE_ROUTED1(CredentialManagerMsg_AcknowledgeStore, int /* request_id */) - -// Notify the renderer that the browser process has finished processing a -// CredentialManagerHostMsg_RequireUserMediation message. -IPC_MESSAGE_ROUTED1(CredentialManagerMsg_AcknowledgeRequireUserMediation, - int /* request_id */) - -// Send a credential to the renderer in response to a -// CredentialManagerHostMsg_RequestCredential message. -IPC_MESSAGE_ROUTED2(CredentialManagerMsg_SendCredential, - int /* request_id */, - password_manager::CredentialInfo /* credential */) - -// Reject the credential request in response to a -// CredentialManagerHostMsg_RequestCredential message. -IPC_MESSAGE_ROUTED2(CredentialManagerMsg_RejectCredentialRequest, - int /* request_id */, - blink::WebCredentialManagerError /* rejection_reason */)
diff --git a/components/password_manager/content/public/cpp/BUILD.gn b/components/password_manager/content/public/cpp/BUILD.gn new file mode 100644 index 0000000..a4c0353 --- /dev/null +++ b/components/password_manager/content/public/cpp/BUILD.gn
@@ -0,0 +1,23 @@ +# Copyright 2016 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. + +source_set("cpp") { + sources = [ + "type_converters.cc", + "type_converters.h", + ] + + public_deps = [ + "../interfaces", + ] + + deps = [ + "//base", + "//components/password_manager/core/common", + "//mojo/common:common_base", + "//mojo/common:url_type_converters", + "//mojo/public/cpp/bindings", + "//third_party/WebKit/public:blink", + ] +}
diff --git a/components/password_manager/content/public/cpp/type_converters.cc b/components/password_manager/content/public/cpp/type_converters.cc new file mode 100644 index 0000000..6076149 --- /dev/null +++ b/components/password_manager/content/public/cpp/type_converters.cc
@@ -0,0 +1,128 @@ +// Copyright 2016 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 "components/password_manager/content/public/cpp/type_converters.h" + +#include "base/logging.h" +#include "components/password_manager/core/common/credential_manager_types.h" +#include "mojo/common/common_type_converters.h" +#include "mojo/common/url_type_converters.h" +#include "third_party/WebKit/public/platform/WebCredential.h" +#include "third_party/WebKit/public/platform/WebFederatedCredential.h" +#include "third_party/WebKit/public/platform/WebPasswordCredential.h" + +using namespace password_manager; + +namespace mojo { + +namespace { + +mojom::CredentialType CMCredentialTypeToMojo(CredentialType type) { + switch (type) { + case CredentialType::CREDENTIAL_TYPE_EMPTY: + return mojom::CredentialType::EMPTY; + case CredentialType::CREDENTIAL_TYPE_PASSWORD: + return mojom::CredentialType::PASSWORD; + case CredentialType::CREDENTIAL_TYPE_FEDERATED: + return mojom::CredentialType::FEDERATED; + } + + NOTREACHED(); + return mojom::CredentialType::EMPTY; +} + +CredentialType MojoCredentialTypeToCM(mojom::CredentialType type) { + switch (type) { + case mojom::CredentialType::EMPTY: + return CredentialType::CREDENTIAL_TYPE_EMPTY; + case mojom::CredentialType::PASSWORD: + return CredentialType::CREDENTIAL_TYPE_PASSWORD; + case mojom::CredentialType::FEDERATED: + return CredentialType::CREDENTIAL_TYPE_FEDERATED; + } + + NOTREACHED(); + return CredentialType::CREDENTIAL_TYPE_EMPTY; +} + +} // namespace + +mojom::CredentialInfoPtr +TypeConverter<mojom::CredentialInfoPtr, CredentialInfo>::Convert( + const CredentialInfo& input) { + mojom::CredentialInfoPtr output(mojom::CredentialInfo::New()); + output->type = CMCredentialTypeToMojo(input.type); + output->id = mojo::String::From(input.id); + output->name = mojo::String::From(input.name); + output->icon = mojo::String::From(input.icon); + output->password = mojo::String::From(input.password); + output->federation = input.federation; + + return output; +} + +CredentialInfo TypeConverter<CredentialInfo, mojom::CredentialInfoPtr>::Convert( + const mojom::CredentialInfoPtr& input) { + CredentialInfo output; + output.type = MojoCredentialTypeToCM(input->type); + output.id = input->id.To<base::string16>(); + output.name = input->name.To<base::string16>(); + output.icon = input->icon.To<GURL>(); + output.password = input->password.To<base::string16>(); + output.federation = input->federation; + + return output; +} + +mojom::CredentialInfoPtr +TypeConverter<mojom::CredentialInfoPtr, blink::WebCredential>::Convert( + const blink::WebCredential& input) { + mojom::CredentialInfoPtr output(mojom::CredentialInfo::New()); + + if (input.isPasswordCredential()) { + // blink::WebPasswordCredential + output->type = mojom::CredentialType::PASSWORD; + output->password = mojo::String::From(base::string16( + static_cast<const blink::WebPasswordCredential&>(input).password())); + } else { + DCHECK(input.isFederatedCredential()); + // blink::WebFederatedCredential + output->type = mojom::CredentialType::FEDERATED; + output->federation = + static_cast<const blink::WebFederatedCredential&>(input).provider(); + } + output->id = mojo::String::From(base::string16(input.id())); + output->name = mojo::String::From(base::string16(input.name())); + output->icon = mojo::String::From(GURL(input.iconURL())); + + return output; +} + +scoped_ptr<blink::WebCredential> TypeConverter< + scoped_ptr<blink::WebCredential>, + mojom::CredentialInfoPtr>::Convert(const mojom::CredentialInfoPtr& input) { + scoped_ptr<blink::WebCredential> output; + + switch (input->type) { + case mojom::CredentialType::PASSWORD: + output.reset(new blink::WebPasswordCredential( + input->id.To<base::string16>(), input->password.To<base::string16>(), + input->name.To<base::string16>(), input->icon.To<GURL>())); + break; + case mojom::CredentialType::FEDERATED: + output.reset(new blink::WebFederatedCredential( + input->id.To<base::string16>(), input->federation, + input->name.To<base::string16>(), input->icon.To<GURL>())); + break; + case mojom::CredentialType::EMPTY: + // Intentionally empty, return nullptr. + break; + default: + NOTREACHED(); + } + + return output; +} + +} // namespace mojo
diff --git a/components/password_manager/content/public/cpp/type_converters.h b/components/password_manager/content/public/cpp/type_converters.h new file mode 100644 index 0000000..648114f --- /dev/null +++ b/components/password_manager/content/public/cpp/type_converters.h
@@ -0,0 +1,51 @@ +// Copyright 2016 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_PASSWORD_MANAGER_CONTENT_PUBLIC_CPP_TYPE_CONVERTERS_IMPL_H_ +#define COMPONENTS_PASSWORD_MANAGER_CONTENT_PUBLIC_CPP_TYPE_CONVERTERS_IMPL_H_ + +#include "base/memory/scoped_ptr.h" +#include "components/password_manager/content/public/interfaces/credential_manager.mojom.h" + +namespace blink { +class WebCredential; +} + +namespace password_manager { +struct CredentialInfo; +} + +namespace mojo { + +template <> +struct TypeConverter<password_manager::mojom::CredentialInfoPtr, + password_manager::CredentialInfo> { + static password_manager::mojom::CredentialInfoPtr Convert( + const password_manager::CredentialInfo& input); +}; + +template <> +struct TypeConverter<password_manager::CredentialInfo, + password_manager::mojom::CredentialInfoPtr> { + static password_manager::CredentialInfo Convert( + const password_manager::mojom::CredentialInfoPtr& input); +}; + +template <> +struct TypeConverter<password_manager::mojom::CredentialInfoPtr, + blink::WebCredential> { + static password_manager::mojom::CredentialInfoPtr Convert( + const blink::WebCredential& input); +}; + +template <> +struct TypeConverter<scoped_ptr<blink::WebCredential>, + password_manager::mojom::CredentialInfoPtr> { + static scoped_ptr<blink::WebCredential> Convert( + const password_manager::mojom::CredentialInfoPtr& input); +}; + +} // namespace mojo + +#endif // COMPONENTS_PASSWORD_MANAGER_CONTENT_PUBLIC_CPP_TYPE_CONVERTERS_IMPL_H_
diff --git a/components/password_manager/content/public/interfaces/BUILD.gn b/components/password_manager/content/public/interfaces/BUILD.gn new file mode 100644 index 0000000..4c29ae1 --- /dev/null +++ b/components/password_manager/content/public/interfaces/BUILD.gn
@@ -0,0 +1,17 @@ +# Copyright 2016 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. + +import("//mojo/public/tools/bindings/mojom.gni") + +mojom("interfaces") { + sources = [ + "credential_manager.mojom", + ] + + typemaps = [ "//url/mojo/origin.typemap" ] + + public_deps = [ + "//url/mojo:url_mojom_origin", + ] +}
diff --git a/components/password_manager/content/public/interfaces/OWNERS b/components/password_manager/content/public/interfaces/OWNERS new file mode 100644 index 0000000..7afd0f9 --- /dev/null +++ b/components/password_manager/content/public/interfaces/OWNERS
@@ -0,0 +1,13 @@ +# Changes to mojom files require a security review to avoid introducing +# new sandbox escapes. +per-file *.mojom=set noparent +per-file *.mojom=dcheng@chromium.org +per-file *.mojom=inferno@chromium.org +per-file *.mojom=jln@chromium.org +per-file *.mojom=jschuh@chromium.org +per-file *.mojom=kenrb@chromium.org +per-file *.mojom=mkwst@chromium.org +per-file *.mojom=nasko@chromium.org +per-file *.mojom=palmer@chromium.org +per-file *.mojom=tsepez@chromium.org +per-file *.mojom=wfh@chromium.org
diff --git a/components/password_manager/content/public/interfaces/credential_manager.mojom b/components/password_manager/content/public/interfaces/credential_manager.mojom new file mode 100644 index 0000000..cc9492b --- /dev/null +++ b/components/password_manager/content/public/interfaces/credential_manager.mojom
@@ -0,0 +1,44 @@ +// Copyright 2016 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. + +module password_manager.mojom; + +import "url/mojo/origin.mojom"; + +enum CredentialType { + EMPTY, + PASSWORD, + FEDERATED +}; + +enum CredentialManagerError { + SUCCESS, + DISABLED, + PENDINGREQUEST, + PASSWORDSTOREUNAVAILABLE, + UNKNOWN +}; + +struct CredentialInfo { + CredentialType type = EMPTY; + string id = ""; + string name = ""; + string icon = ""; + string password = ""; + url.mojom.Origin federation; +}; + +interface CredentialManager { + // Store credential. For navigator.credentials.store(). + Store(CredentialInfo credential) => (); + + // Require user mediation. For navigator.credentials.requireUserMediation(). + RequireUserMediation() => (); + + // Get Credential. For navigator.credentials.get(). + // The result callback will return a non-null and valid CredentialInfo + // if succeeded, or null with a CredentialManagerError if failed. + Get(bool zero_click_only, bool include_passwords, array<string> federations) + => (CredentialManagerError error, CredentialInfo? credential); +};
diff --git a/components/password_manager/content/renderer/BUILD.gn b/components/password_manager/content/renderer/BUILD.gn index 350e5b06..16629b1 100644 --- a/components/password_manager/content/renderer/BUILD.gn +++ b/components/password_manager/content/renderer/BUILD.gn
@@ -10,11 +10,12 @@ deps = [ "//base", - "//components/password_manager/content/common", + "//components/password_manager/content/public/cpp", "//components/password_manager/core/common", "//components/strings", + "//content/public/common", "//content/public/renderer", - "//ipc", + "//mojo/common:url_type_converters", "//third_party/WebKit/public:blink", "//url", ] @@ -28,9 +29,8 @@ deps = [ ":renderer", - "//components/password_manager/content/common", + "//content/public/renderer", "//content/test:test_support", - "//ipc:test_support", "//testing/gmock", "//testing/gtest", "//third_party/WebKit/public:blink",
diff --git a/components/password_manager/content/renderer/DEPS b/components/password_manager/content/renderer/DEPS index 0c6d17a..488c67e 100644 --- a/components/password_manager/content/renderer/DEPS +++ b/components/password_manager/content/renderer/DEPS
@@ -2,6 +2,7 @@ "+content/public/common", "+content/public/renderer", "+content/test", + "+mojo/public", "+third_party/WebKit/public/platform", "+third_party/WebKit/public/web", ]
diff --git a/components/password_manager/content/renderer/credential_manager_client.cc b/components/password_manager/content/renderer/credential_manager_client.cc index 3c548e8..c3791bc6 100644 --- a/components/password_manager/content/renderer/credential_manager_client.cc +++ b/components/password_manager/content/renderer/credential_manager_client.cc
@@ -9,10 +9,14 @@ #include <memory> #include <utility> -#include "components/password_manager/content/common/credential_manager_content_utils.h" -#include "components/password_manager/content/common/credential_manager_messages.h" +#include "base/bind.h" +#include "base/logging.h" +#include "components/password_manager/content/public/cpp/type_converters.h" #include "components/password_manager/core/common/credential_manager_types.h" +#include "content/public/common/service_registry.h" +#include "content/public/renderer/render_frame.h" #include "content/public/renderer/render_view.h" +#include "mojo/common/url_type_converters.h" #include "third_party/WebKit/public/platform/WebCredential.h" #include "third_party/WebKit/public/platform/WebCredentialManagerError.h" #include "third_party/WebKit/public/platform/WebFederatedCredential.h" @@ -23,13 +27,128 @@ namespace { -template <typename T> -void ClearCallbacksMapWithErrors(T* callbacks_map) { - typename T::iterator iter(callbacks_map); - while (!iter.IsAtEnd()) { - iter.GetCurrentValue()->onError(blink::WebCredentialManagerUnknownError); - callbacks_map->Remove(iter.GetCurrentKey()); - iter.Advance(); +blink::WebCredentialManagerError GetWebCredentialManagerErrorFromMojo( + mojom::CredentialManagerError error) { + switch (error) { + case mojom::CredentialManagerError::DISABLED: + return blink::WebCredentialManagerError:: + WebCredentialManagerDisabledError; + case mojom::CredentialManagerError::PENDINGREQUEST: + return blink::WebCredentialManagerError:: + WebCredentialManagerPendingRequestError; + case mojom::CredentialManagerError::PASSWORDSTOREUNAVAILABLE: + return blink::WebCredentialManagerError:: + WebCredentialManagerPasswordStoreUnavailableError; + case mojom::CredentialManagerError::UNKNOWN: + return blink::WebCredentialManagerError::WebCredentialManagerUnknownError; + case mojom::CredentialManagerError::SUCCESS: + NOTREACHED(); + break; + } + + NOTREACHED(); + return blink::WebCredentialManagerError::WebCredentialManagerUnknownError; +} + +// Takes ownership of blink::WebCredentialManagerClient::NotificationCallbacks +// pointer. When the wrapper is destroyed, if |callbacks| is still alive +// its onError() will get called. +class NotificationCallbacksWrapper { + public: + explicit NotificationCallbacksWrapper( + blink::WebCredentialManagerClient::NotificationCallbacks* callbacks); + + ~NotificationCallbacksWrapper(); + + void NotifySuccess(); + + private: + std::unique_ptr<blink::WebCredentialManagerClient::NotificationCallbacks> + callbacks_; + + DISALLOW_COPY_AND_ASSIGN(NotificationCallbacksWrapper); +}; + +NotificationCallbacksWrapper::NotificationCallbacksWrapper( + blink::WebCredentialManagerClient::NotificationCallbacks* callbacks) + : callbacks_(callbacks) {} + +NotificationCallbacksWrapper::~NotificationCallbacksWrapper() { + if (callbacks_) + callbacks_->onError(blink::WebCredentialManagerUnknownError); +} + +void NotificationCallbacksWrapper::NotifySuccess() { + // Call onSuccess() and reset callbacks to avoid calling onError() in + // destructor. + if (callbacks_) { + callbacks_->onSuccess(); + callbacks_.reset(); + } +} + +// Takes ownership of blink::WebCredentialManagerClient::RequestCallbacks +// pointer. When the wrapper is destroied, if |callbacks| is still alive +// its onError() will get called. +class RequestCallbacksWrapper { + public: + explicit RequestCallbacksWrapper( + blink::WebCredentialManagerClient::RequestCallbacks* callbacks); + + ~RequestCallbacksWrapper(); + + void NotifySuccess(mojom::CredentialInfoPtr info); + + void NotifyError(mojom::CredentialManagerError error); + + private: + std::unique_ptr<blink::WebCredentialManagerClient::RequestCallbacks> + callbacks_; + + DISALLOW_COPY_AND_ASSIGN(RequestCallbacksWrapper); +}; + +RequestCallbacksWrapper::RequestCallbacksWrapper( + blink::WebCredentialManagerClient::RequestCallbacks* callbacks) + : callbacks_(callbacks) {} + +RequestCallbacksWrapper::~RequestCallbacksWrapper() { + if (callbacks_) + callbacks_->onError(blink::WebCredentialManagerUnknownError); +} + +void RequestCallbacksWrapper::NotifySuccess(mojom::CredentialInfoPtr info) { + // Call onSuccess() and reset callbacks to avoid calling onError() in + // destructor. + if (callbacks_) { + std::unique_ptr<blink::WebCredential> credential = + info.To<std::unique_ptr<blink::WebCredential>>(); + callbacks_->onSuccess(std::move(credential)); + callbacks_.reset(); + } +} + +void RequestCallbacksWrapper::NotifyError(mojom::CredentialManagerError error) { + if (callbacks_) { + callbacks_->onError(GetWebCredentialManagerErrorFromMojo(error)); + callbacks_.reset(); + } +} + +void RespondToNotificationCallback( + NotificationCallbacksWrapper* callbacks_wrapper) { + callbacks_wrapper->NotifySuccess(); +} + +void RespondToRequestCallback(RequestCallbacksWrapper* callbacks_wrapper, + mojom::CredentialManagerError error, + mojom::CredentialInfoPtr info) { + if (error == mojom::CredentialManagerError::SUCCESS) { + DCHECK(!info.is_null()); + callbacks_wrapper->NotifySuccess(std::move(info)); + } else { + DCHECK(info.is_null()); + callbacks_wrapper->NotifyError(error); } } @@ -41,86 +160,32 @@ render_view->GetWebView()->setCredentialManagerClient(this); } -CredentialManagerClient::~CredentialManagerClient() { - ClearCallbacksMapWithErrors(&store_callbacks_); - ClearCallbacksMapWithErrors(&require_user_mediation_callbacks_); - ClearCallbacksMapWithErrors(&get_callbacks_); -} +CredentialManagerClient::~CredentialManagerClient() {} // ----------------------------------------------------------------------------- -// Handle messages from the browser. - -bool CredentialManagerClient::OnMessageReceived(const IPC::Message& message) { - bool handled = true; - IPC_BEGIN_MESSAGE_MAP(CredentialManagerClient, message) - IPC_MESSAGE_HANDLER(CredentialManagerMsg_AcknowledgeStore, - OnAcknowledgeStore) - IPC_MESSAGE_HANDLER(CredentialManagerMsg_AcknowledgeRequireUserMediation, - OnAcknowledgeRequireUserMediation) - IPC_MESSAGE_HANDLER(CredentialManagerMsg_SendCredential, OnSendCredential) - IPC_MESSAGE_HANDLER(CredentialManagerMsg_RejectCredentialRequest, - OnRejectCredentialRequest) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - return handled; -} - -void CredentialManagerClient::OnAcknowledgeStore(int request_id) { - RespondToNotificationCallback(request_id, &store_callbacks_); -} - -void CredentialManagerClient::OnAcknowledgeRequireUserMediation( - int request_id) { - RespondToNotificationCallback(request_id, &require_user_mediation_callbacks_); -} - -void CredentialManagerClient::OnSendCredential(int request_id, - const CredentialInfo& info) { - RequestCallbacks* callbacks = get_callbacks_.Lookup(request_id); - DCHECK(callbacks); - std::unique_ptr<blink::WebCredential> credential; - switch (info.type) { - case CredentialType::CREDENTIAL_TYPE_FEDERATED: - credential.reset(new blink::WebFederatedCredential( - info.id, info.federation, info.name, info.icon)); - break; - case CredentialType::CREDENTIAL_TYPE_PASSWORD: - credential.reset(new blink::WebPasswordCredential( - info.id, info.password, info.name, info.icon)); - break; - case CredentialType::CREDENTIAL_TYPE_EMPTY: - // Intentionally empty; we'll send nullptr to the onSuccess call below. - break; - } - callbacks->onSuccess(std::move(credential)); - get_callbacks_.Remove(request_id); -} - -void CredentialManagerClient::OnRejectCredentialRequest( - int request_id, - blink::WebCredentialManagerError error) { - RequestCallbacks* callbacks = get_callbacks_.Lookup(request_id); - DCHECK(callbacks); - callbacks->onError(error); - get_callbacks_.Remove(request_id); -} - -// ----------------------------------------------------------------------------- -// Dispatch messages from the renderer to the browser. +// Access mojo CredentialManagerService. void CredentialManagerClient::dispatchStore( const blink::WebCredential& credential, blink::WebCredentialManagerClient::NotificationCallbacks* callbacks) { - int request_id = store_callbacks_.Add(callbacks); - CredentialInfo info(WebCredentialToCredentialInfo(credential)); - Send(new CredentialManagerHostMsg_Store(routing_id(), request_id, info)); + DCHECK(callbacks); + ConnectToMojoCMIfNeeded(); + + mojom::CredentialInfoPtr info = mojom::CredentialInfo::From(credential); + mojo_cm_service_->Store( + std::move(info), + base::Bind(&RespondToNotificationCallback, + base::Owned(new NotificationCallbacksWrapper(callbacks)))); } void CredentialManagerClient::dispatchRequireUserMediation( - NotificationCallbacks* callbacks) { - int request_id = require_user_mediation_callbacks_.Add(callbacks); - Send(new CredentialManagerHostMsg_RequireUserMediation(routing_id(), - request_id)); + blink::WebCredentialManagerClient::NotificationCallbacks* callbacks) { + DCHECK(callbacks); + ConnectToMojoCMIfNeeded(); + + mojo_cm_service_->RequireUserMediation( + base::Bind(&RespondToNotificationCallback, + base::Owned(new NotificationCallbacksWrapper(callbacks)))); } void CredentialManagerClient::dispatchGet( @@ -128,23 +193,27 @@ bool include_passwords, const blink::WebVector<blink::WebURL>& federations, RequestCallbacks* callbacks) { - int request_id = get_callbacks_.Add(callbacks); + DCHECK(callbacks); + ConnectToMojoCMIfNeeded(); + std::vector<GURL> federation_vector; for (size_t i = 0; i < std::min(federations.size(), kMaxFederations); ++i) federation_vector.push_back(federations[i]); - Send(new CredentialManagerHostMsg_RequestCredential( - routing_id(), request_id, zero_click_only, include_passwords, - federation_vector)); + + mojo_cm_service_->Get( + zero_click_only, include_passwords, + mojo::Array<mojo::String>::From(federation_vector), + base::Bind(&RespondToRequestCallback, + base::Owned(new RequestCallbacksWrapper(callbacks)))); } -void CredentialManagerClient::RespondToNotificationCallback( - int request_id, - CredentialManagerClient::NotificationCallbacksMap* map) { - blink::WebCredentialManagerClient::NotificationCallbacks* callbacks = - map->Lookup(request_id); - DCHECK(callbacks); - callbacks->onSuccess(); - map->Remove(request_id); +void CredentialManagerClient::ConnectToMojoCMIfNeeded() { + if (mojo_cm_service_) + return; + + content::RenderFrame* main_frame = render_view()->GetMainRenderFrame(); + main_frame->GetServiceRegistry()->ConnectToRemoteService( + mojo::GetProxy(&mojo_cm_service_)); } } // namespace password_manager
diff --git a/components/password_manager/content/renderer/credential_manager_client.h b/components/password_manager/content/renderer/credential_manager_client.h index d87e4601..99bd96d 100644 --- a/components/password_manager/content/renderer/credential_manager_client.h +++ b/components/password_manager/content/renderer/credential_manager_client.h
@@ -6,10 +6,9 @@ #define COMPONENTS_PASSWORD_MANAGER_CONTENT_RENDERER_CREDENTIAL_MANAGER_CLIENT_H_ #include "base/compiler_specific.h" -#include "base/id_map.h" #include "base/macros.h" +#include "components/password_manager/content/public/interfaces/credential_manager.mojom.h" #include "content/public/renderer/render_view_observer.h" -#include "ipc/ipc_listener.h" #include "third_party/WebKit/public/platform/WebCredentialManagerClient.h" #include "third_party/WebKit/public/platform/WebCredentialManagerError.h" #include "third_party/WebKit/public/platform/WebVector.h" @@ -45,19 +44,7 @@ explicit CredentialManagerClient(content::RenderView* render_view); ~CredentialManagerClient() override; - // RenderViewObserver: - bool OnMessageReceived(const IPC::Message& message) override; - - // Message handlers for messages from the browser process: - virtual void OnAcknowledgeStore(int request_id); - virtual void OnAcknowledgeRequireUserMediation(int request_id); - virtual void OnSendCredential(int request_id, - const CredentialInfo& credential_info); - virtual void OnRejectCredentialRequest( - int request_id, - blink::WebCredentialManagerError error); - - // blink::WebCredentialManager: + // blink::WebCredentialManagerClient: void dispatchStore( const blink::WebCredential& credential, WebCredentialManagerClient::NotificationCallbacks* callbacks) override; @@ -68,19 +55,9 @@ RequestCallbacks* callbacks) override; private: - typedef IDMap<blink::WebCredentialManagerClient::RequestCallbacks, - IDMapOwnPointer> RequestCallbacksMap; - typedef IDMap<blink::WebCredentialManagerClient::NotificationCallbacks, - IDMapOwnPointer> NotificationCallbacksMap; + void ConnectToMojoCMIfNeeded(); - void RespondToNotificationCallback(int request_id, - NotificationCallbacksMap* map); - - // Track the various blink::WebCredentialManagerClient::*Callbacks objects - // generated from Blink. This class takes ownership of these objects. - NotificationCallbacksMap store_callbacks_; - NotificationCallbacksMap require_user_mediation_callbacks_; - RequestCallbacksMap get_callbacks_; + mojom::CredentialManagerPtr mojo_cm_service_; DISALLOW_COPY_AND_ASSIGN(CredentialManagerClient); };
diff --git a/components/password_manager/content/renderer/credential_manager_client_browsertest.cc b/components/password_manager/content/renderer/credential_manager_client_browsertest.cc index addbcf2a..67dca8fa 100644 --- a/components/password_manager/content/renderer/credential_manager_client_browsertest.cc +++ b/components/password_manager/content/renderer/credential_manager_client_browsertest.cc
@@ -9,19 +9,70 @@ #include <memory> #include <tuple> -#include "components/password_manager/content/common/credential_manager_messages.h" +#include "content/public/common/service_registry.h" +#include "content/public/renderer/render_frame.h" +#include "content/public/renderer/render_view.h" #include "content/public/test/render_view_test.h" -#include "ipc/ipc_test_sink.h" +#include "mojo/public/cpp/bindings/binding_set.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/WebKit/public/platform/WebCredential.h" #include "third_party/WebKit/public/platform/WebCredentialManagerClient.h" #include "third_party/WebKit/public/platform/WebCredentialManagerError.h" #include "third_party/WebKit/public/platform/WebPasswordCredential.h" +using content::ServiceRegistry; + namespace password_manager { namespace { +const char kTestCredentialPassword[] = "https://password.com/"; +const char kTestCredentialEmpty[] = "https://empty.com/"; +const char kTestCredentialReject[] = "https://reject.com/"; + +class FakeCredentialManager : public mojom::CredentialManager { + public: + FakeCredentialManager() {} + ~FakeCredentialManager() override {} + + void BindRequest(mojom::CredentialManagerRequest request) { + bindings_.AddBinding(this, std::move(request)); + } + + private: + // mojom::CredentialManager methods: + void Store(mojom::CredentialInfoPtr credential, + const StoreCallback& callback) override { + callback.Run(); + } + + void RequireUserMediation( + const RequireUserMediationCallback& callback) override { + callback.Run(); + } + + void Get(bool zero_click_only, + bool include_passwords, + mojo::Array<mojo::String> federations, + const GetCallback& callback) override { + mojo::String& url = federations[0]; + + if (url == kTestCredentialPassword) { + mojom::CredentialInfoPtr info = mojom::CredentialInfo::New(); + info->type = mojom::CredentialType::PASSWORD; + callback.Run(mojom::CredentialManagerError::SUCCESS, std::move(info)); + } else if (url == kTestCredentialEmpty) { + callback.Run(mojom::CredentialManagerError::SUCCESS, + mojom::CredentialInfo::New()); + } else if (url == kTestCredentialReject) { + callback.Run(mojom::CredentialManagerError::PASSWORDSTOREUNAVAILABLE, + nullptr); + } + } + + mojo::BindingSet<mojom::CredentialManager> bindings_; +}; + class CredentialManagerClientTest : public content::RenderViewTest { public: CredentialManagerClientTest() @@ -30,8 +81,14 @@ void SetUp() override { content::RenderViewTest::SetUp(); - credential_.reset(new blink::WebPasswordCredential("", "", "", GURL())); client_.reset(new CredentialManagerClient(view_)); + + ServiceRegistry* registry = + view_->GetMainRenderFrame()->GetServiceRegistry(); + registry->AddServiceOverrideForTesting( + mojom::CredentialManager::Name_, + base::Bind(&CredentialManagerClientTest::BindCredentialManager, + base::Unretained(this))); } void TearDown() override { @@ -40,60 +97,24 @@ content::RenderViewTest::TearDown(); } - IPC::TestSink& sink() { return render_thread_->sink(); } - - blink::WebCredential* credential() { return credential_.get(); } - - // The browser's response to any of the messages the client sends must contain - // a request ID so that the client knows which request is being serviced. This - // method grabs the ID from an outgoing |message_id| message, and sets the - // |request_id| param to its value. If no request ID can be found, the method - // returns false, and the |request_id| is set to -1. - // - // Clears any pending messages upon return. - bool ExtractRequestId(uint32_t message_id, int& request_id) { - request_id = -1; - const IPC::Message* message = sink().GetFirstMessageMatching(message_id); - if (!message) - return false; - - switch (message_id) { - case CredentialManagerHostMsg_Store::ID: { - std::tuple<int, CredentialInfo> param; - CredentialManagerHostMsg_Store::Read(message, ¶m); - request_id = std::get<0>(param); - break; - } - - case CredentialManagerHostMsg_RequireUserMediation::ID: { - std::tuple<int> param; - CredentialManagerHostMsg_RequireUserMediation::Read(message, ¶m); - request_id = std::get<0>(param); - break; - } - - case CredentialManagerHostMsg_RequestCredential::ID: { - std::tuple<int, bool, bool, std::vector<GURL>> param; - CredentialManagerHostMsg_RequestCredential::Read(message, ¶m); - request_id = std::get<0>(param); - break; - } - - default: - break; - } - sink().ClearMessages(); - return request_id != -1; - } - bool callback_errored() const { return callback_errored_; } void set_callback_errored(bool state) { callback_errored_ = state; } bool callback_succeeded() const { return callback_succeeded_; } void set_callback_succeeded(bool state) { callback_succeeded_ = state; } + void BindCredentialManager(mojo::ScopedMessagePipeHandle handle) { + fake_cm_.BindRequest( + mojo::MakeRequest<mojom::CredentialManager>(std::move(handle))); + } + + std::unique_ptr<blink::WebPasswordCredential> credential_; + blink::WebCredentialManagerError error_; + protected: std::unique_ptr<CredentialManagerClient> client_; + FakeCredentialManager fake_cm_; + // True if a message's callback's 'onSuccess'/'onError' methods were called, // false otherwise. We put these on the test object rather than on the // Test*Callbacks objects because ownership of those objects passes into the @@ -101,8 +122,6 @@ // pending Blink-side Promise. bool callback_errored_; bool callback_succeeded_; - - std::unique_ptr<blink::WebPasswordCredential> credential_; }; class TestNotificationCallbacks @@ -131,90 +150,99 @@ ~TestRequestCallbacks() override {} - void onSuccess(std::unique_ptr<blink::WebCredential>) override { + void onSuccess(std::unique_ptr<blink::WebCredential> credential) override { test_->set_callback_succeeded(true); + + blink::WebCredential* ptr = credential.release(); + test_->credential_.reset(static_cast<blink::WebPasswordCredential*>(ptr)); } void onError(blink::WebCredentialManagerError reason) override { test_->set_callback_errored(true); + test_->credential_.reset(); + test_->error_ = reason; } private: CredentialManagerClientTest* test_; }; +void RunAllPendingTasks() { + base::RunLoop run_loop; + base::MessageLoop::current()->PostTask( + FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); + run_loop.Run(); +} + } // namespace TEST_F(CredentialManagerClientTest, SendStore) { - int request_id; - EXPECT_FALSE( - ExtractRequestId(CredentialManagerHostMsg_Store::ID, request_id)); - + credential_.reset(new blink::WebPasswordCredential("", "", "", GURL())); std::unique_ptr<TestNotificationCallbacks> callbacks( new TestNotificationCallbacks(this)); - client_->dispatchStore(*credential(), callbacks.release()); + client_->dispatchStore(*credential_, callbacks.release()); - EXPECT_TRUE(ExtractRequestId(CredentialManagerHostMsg_Store::ID, request_id)); + RunAllPendingTasks(); - client_->OnAcknowledgeStore(request_id); EXPECT_TRUE(callback_succeeded()); EXPECT_FALSE(callback_errored()); } TEST_F(CredentialManagerClientTest, SendRequestUserMediation) { - int request_id; - EXPECT_FALSE(ExtractRequestId( - CredentialManagerHostMsg_RequireUserMediation::ID, request_id)); - std::unique_ptr<TestNotificationCallbacks> callbacks( new TestNotificationCallbacks(this)); client_->dispatchRequireUserMediation(callbacks.release()); - EXPECT_TRUE(ExtractRequestId( - CredentialManagerHostMsg_RequireUserMediation::ID, request_id)); + RunAllPendingTasks(); - client_->OnAcknowledgeRequireUserMediation(request_id); EXPECT_TRUE(callback_succeeded()); EXPECT_FALSE(callback_errored()); } TEST_F(CredentialManagerClientTest, SendRequestCredential) { - int request_id; - EXPECT_FALSE(ExtractRequestId(CredentialManagerHostMsg_RequestCredential::ID, - request_id)); - std::unique_ptr<TestRequestCallbacks> callbacks( new TestRequestCallbacks(this)); std::vector<GURL> federations; + federations.push_back(GURL(kTestCredentialPassword)); client_->dispatchGet(false, true, federations, callbacks.release()); - EXPECT_TRUE(ExtractRequestId(CredentialManagerHostMsg_RequestCredential::ID, - request_id)); + RunAllPendingTasks(); - CredentialInfo info; - info.type = CredentialType::CREDENTIAL_TYPE_PASSWORD; - client_->OnSendCredential(request_id, info); EXPECT_TRUE(callback_succeeded()); EXPECT_FALSE(callback_errored()); + EXPECT_TRUE(credential_); + EXPECT_EQ("password", credential_->type()); } TEST_F(CredentialManagerClientTest, SendRequestCredentialEmpty) { - int request_id; - EXPECT_FALSE(ExtractRequestId(CredentialManagerHostMsg_RequestCredential::ID, - request_id)); - std::unique_ptr<TestRequestCallbacks> callbacks( new TestRequestCallbacks(this)); std::vector<GURL> federations; + federations.push_back(GURL(kTestCredentialEmpty)); client_->dispatchGet(false, true, federations, callbacks.release()); - EXPECT_TRUE(ExtractRequestId(CredentialManagerHostMsg_RequestCredential::ID, - request_id)); + RunAllPendingTasks(); - CredentialInfo info; // Send an empty credential in response. - client_->OnSendCredential(request_id, info); EXPECT_TRUE(callback_succeeded()); EXPECT_FALSE(callback_errored()); + EXPECT_FALSE(credential_); +} + +TEST_F(CredentialManagerClientTest, SendRequestCredentialReject) { + std::unique_ptr<TestRequestCallbacks> callbacks( + new TestRequestCallbacks(this)); + std::vector<GURL> federations; + federations.push_back(GURL(kTestCredentialReject)); + client_->dispatchGet(false, true, federations, callbacks.release()); + + RunAllPendingTasks(); + + EXPECT_FALSE(callback_succeeded()); + EXPECT_TRUE(callback_errored()); + EXPECT_FALSE(credential_); + EXPECT_EQ(blink::WebCredentialManagerError:: + WebCredentialManagerPasswordStoreUnavailableError, + error_); } } // namespace password_manager
diff --git a/components/password_manager/core/browser/credential_manager_pending_request_task.cc b/components/password_manager/core/browser/credential_manager_pending_request_task.cc index 1e1b6cd..a852003 100644 --- a/components/password_manager/core/browser/credential_manager_pending_request_task.cc +++ b/components/password_manager/core/browser/credential_manager_pending_request_task.cc
@@ -19,14 +19,14 @@ CredentialManagerPendingRequestTask::CredentialManagerPendingRequestTask( CredentialManagerPendingRequestTaskDelegate* delegate, - int request_id, + const SendCredentialCallback& callback, bool request_zero_click_only, const GURL& request_origin, bool include_passwords, const std::vector<GURL>& request_federations, const std::vector<std::string>& affiliated_realms) : delegate_(delegate), - id_(request_id), + send_callback_(callback), zero_click_only_(request_zero_click_only), origin_(request_origin), include_passwords_(include_passwords), @@ -42,7 +42,7 @@ void CredentialManagerPendingRequestTask::OnGetPasswordStoreResults( ScopedVector<autofill::PasswordForm> results) { if (delegate_->GetOrigin() != origin_) { - delegate_->SendCredential(id_, CredentialInfo()); + delegate_->SendCredential(send_callback_, CredentialInfo()); return; } @@ -88,7 +88,7 @@ } if ((local_results.empty() && federated_results.empty())) { - delegate_->SendCredential(id_, CredentialInfo()); + delegate_->SendCredential(send_callback_, CredentialInfo()); return; } @@ -109,7 +109,7 @@ : CredentialType::CREDENTIAL_TYPE_FEDERATED); delegate_->client()->NotifyUserAutoSignin(std::move(local_results), origin_); - delegate_->SendCredential(id_, info); + delegate_->SendCredential(send_callback_, info); return; } @@ -123,7 +123,7 @@ std::move(local_results), std::move(federated_results), origin_, base::Bind( &CredentialManagerPendingRequestTaskDelegate::SendPasswordForm, - base::Unretained(delegate_), id_))) { + base::Unretained(delegate_), send_callback_))) { if (can_use_autosignin) { // The user had credentials, but either chose not to share them with the // site, or was prevented from doing so by lack of zero-click (or the @@ -134,7 +134,7 @@ std::move(potential_autosignin_form)); } - delegate_->SendCredential(id_, CredentialInfo()); + delegate_->SendCredential(send_callback_, CredentialInfo()); } }
diff --git a/components/password_manager/core/browser/credential_manager_pending_request_task.h b/components/password_manager/core/browser/credential_manager_pending_request_task.h index 61211b2..1cafaf1b 100644 --- a/components/password_manager/core/browser/credential_manager_pending_request_task.h +++ b/components/password_manager/core/browser/credential_manager_pending_request_task.h
@@ -24,6 +24,9 @@ struct CredentialInfo; class PasswordManagerClient; +typedef base::Callback<void(const CredentialInfo& credential)> + SendCredentialCallback; + // Sends credentials retrieved from the PasswordStore to CredentialManager API // clients and retrieves embedder-dependent information. class CredentialManagerPendingRequestTaskDelegate { @@ -41,11 +44,13 @@ virtual PasswordManagerClient* client() const = 0; // Sends a credential to JavaScript. - virtual void SendCredential(int id, const CredentialInfo& credential) = 0; + virtual void SendCredential(const SendCredentialCallback& send_callback, + const CredentialInfo& credential) = 0; // Updates |skip_zero_click| for |form| in the PasswordStore if required. // Sends a credential to JavaScript. - virtual void SendPasswordForm(int id, const autofill::PasswordForm* form) = 0; + virtual void SendPasswordForm(const SendCredentialCallback& send_callback, + const autofill::PasswordForm* form) = 0; }; // Retrieves credentials from the PasswordStore. @@ -53,7 +58,7 @@ public: CredentialManagerPendingRequestTask( CredentialManagerPendingRequestTaskDelegate* delegate, - int request_id, + const SendCredentialCallback& callback, bool request_zero_click_only, const GURL& request_origin, bool include_passwords, @@ -61,7 +66,7 @@ const std::vector<std::string>& affiliated_realms); ~CredentialManagerPendingRequestTask() override; - int id() const { return id_; } + SendCredentialCallback send_callback() const { return send_callback_; } const GURL& origin() const { return origin_; } // PasswordStoreConsumer implementation. @@ -70,7 +75,7 @@ private: CredentialManagerPendingRequestTaskDelegate* delegate_; // Weak; - const int id_; + SendCredentialCallback send_callback_; const bool zero_click_only_; const GURL origin_; const bool include_passwords_;
diff --git a/components/password_manager/core/browser/password_form_manager.cc b/components/password_manager/core/browser/password_form_manager.cc index a4659e6a..52fe030 100644 --- a/components/password_manager/core/browser/password_form_manager.cc +++ b/components/password_manager/core/browser/password_form_manager.cc
@@ -636,7 +636,10 @@ pending_credentials_.date_created = Time::Now(); SanitizePossibleUsernames(&pending_credentials_); - password_store->AddLogin(pending_credentials_); + if (presaved_form_) + ReplacePresavedPasswordWithPendingCredentials(password_store); + else + password_store->AddLogin(pending_credentials_); UpdatePreferredLoginState(password_store); } @@ -706,7 +709,9 @@ bool password_was_updated = false; // Update the new preferred login. - if (!selected_username_.empty()) { + if (presaved_form_) { + ReplacePresavedPasswordWithPendingCredentials(password_store); + } else if (!selected_username_.empty()) { // Username has changed. We set this selected username as the real // username. Given that |username_value| is part of the Sync and // PasswordStore primary key, the old primary key must be supplied. @@ -1400,4 +1405,40 @@ } } +void PasswordFormManager::PresaveGeneratedPassword( + const autofill::PasswordForm& form) { + PasswordStore* store = client_->GetPasswordStore(); + if (!store) { + NOTREACHED(); + return; + } + if (presaved_form_) + store->UpdateLoginWithPrimaryKey(form, *presaved_form_); + else + store->AddLogin(form); + presaved_form_.reset(new autofill::PasswordForm(form)); +} + +void PasswordFormManager::RemovePresavedPassword() { + if (!presaved_form_) + return; + + PasswordStore* store = client_->GetPasswordStore(); + if (!store) { + NOTREACHED(); + return; + } + store->RemoveLogin(*presaved_form_); + presaved_form_.reset(); +} + +void PasswordFormManager::ReplacePresavedPasswordWithPendingCredentials( + PasswordStore* store) { + DCHECK(store); + DCHECK(presaved_form_); + + store->UpdateLoginWithPrimaryKey(pending_credentials_, *presaved_form_); + presaved_form_.reset(); +} + } // namespace password_manager
diff --git a/components/password_manager/core/browser/password_form_manager.h b/components/password_manager/core/browser/password_form_manager.h index 0cf54a3..c3421b8 100644 --- a/components/password_manager/core/browser/password_form_manager.h +++ b/components/password_manager/core/browser/password_form_manager.h
@@ -254,6 +254,15 @@ // Called when the user didn't interact with Update UI. void OnNoInteractionOnUpdate(); + // Called when the user accepts a generated password or change it. + void PresaveGeneratedPassword(const autofill::PasswordForm& form); + + // Called when the user removes the generated password. + void RemovePresavedPassword(); + + // Called after successful login on the form with a generated password. + void ReplacePresavedPasswordWithPendingCredentials(PasswordStore* store); + private: // ManagerAction - What does the manager do with this form? Either it // fills it, or it doesn't. If it doesn't fill it, that's either @@ -493,6 +502,10 @@ // |provisionally_saved_form_| and |best_matches_|. autofill::PasswordForm pending_credentials_; + // Stores the form with generated password till the user makes successful + // login or removes the generated password. + std::unique_ptr<autofill::PasswordForm> presaved_form_; + // Whether pending_credentials_ stores a new login or is an update // to an existing one. bool is_new_login_;
diff --git a/components/password_manager/core/browser/password_manager.cc b/components/password_manager/core/browser/password_manager.cc index f4a5750..7b53036d 100644 --- a/components/password_manager/core/browser/password_manager.cc +++ b/components/password_manager/core/browser/password_manager.cc
@@ -178,6 +178,16 @@ } } +void PasswordManager::OnPresaveGeneratedPassword( + const autofill::PasswordForm& form) { + DCHECK(client_->IsSavingAndFillingEnabledForCurrentPage()); + PasswordFormManager* form_manager = GetMatchingPendingManager(form); + if (form_manager) { + form_manager->PresaveGeneratedPassword(form); + return; + } +} + void PasswordManager::SetHasGeneratedPasswordForForm( password_manager::PasswordManagerDriver* driver, const PasswordForm& form, @@ -186,6 +196,8 @@ PasswordFormManager* form_manager = GetMatchingPendingManager(form); if (form_manager) { + if (!password_is_generated) + form_manager->RemovePresavedPassword(); form_manager->set_has_generated_password(password_is_generated); return; }
diff --git a/components/password_manager/core/browser/password_manager.h b/components/password_manager/core/browser/password_manager.h index 99d8be8e..1adc983 100644 --- a/components/password_manager/core/browser/password_manager.h +++ b/components/password_manager/core/browser/password_manager.h
@@ -84,7 +84,11 @@ void GenerationAvailableForForm(const autofill::PasswordForm& form); + // Presaves the form with generated password. + void OnPresaveGeneratedPassword(const autofill::PasswordForm& password_form); + // Update the state of generation for this form. + // If |password_is_generated| == false, removes the presaved form. void SetHasGeneratedPasswordForForm( password_manager::PasswordManagerDriver* driver, const autofill::PasswordForm& form,
diff --git a/components/password_manager/core/browser/password_manager_unittest.cc b/components/password_manager/core/browser/password_manager_unittest.cc index 0433333..44f5e9d2 100644 --- a/components/password_manager/core/browser/password_manager_unittest.cc +++ b/components/password_manager/core/browser/password_manager_unittest.cc
@@ -1266,6 +1266,74 @@ EXPECT_EQ(form.new_password_value, form_to_save.password_value); } +TEST_F(PasswordManagerTest, PasswordGenerationPresavePassword) { + std::vector<PasswordForm> observed; + PasswordForm form(MakeFormWithOnlyNewPasswordField()); + observed.push_back(form); + EXPECT_CALL(client_, IsSavingAndFillingEnabledForCurrentPage()) + .WillRepeatedly(Return(true)); + EXPECT_CALL(*store_, GetLogins(_, _)) + .WillRepeatedly(WithArg<1>(InvokeEmptyConsumerWithForms())); + manager()->OnPasswordFormsParsed(&driver_, observed); + manager()->OnPasswordFormsRendered(&driver_, observed, true); + + // The user accepts a generated password. + form.password_value = base::ASCIIToUTF16("password"); + EXPECT_CALL(*store_, AddLogin(form)).WillOnce(Return()); + manager()->OnPresaveGeneratedPassword(form); + manager()->SetHasGeneratedPasswordForForm(&driver_, form, true); + + // The user updates the generated password. + PasswordForm updated_form(form); + updated_form.password_value = base::ASCIIToUTF16("password_12345"); + EXPECT_CALL(*store_, UpdateLoginWithPrimaryKey(updated_form, form)) + .WillOnce(Return()); + manager()->OnPresaveGeneratedPassword(updated_form); + + // The user removes the generated password. + EXPECT_CALL(*store_, RemoveLogin(updated_form)).WillOnce(Return()); + manager()->SetHasGeneratedPasswordForForm(&driver_, updated_form, false); +} + +TEST_F(PasswordManagerTest, PasswordGenerationPresavePasswordAndLogin) { + EXPECT_CALL(client_, IsSavingAndFillingEnabledForCurrentPage()) + .WillRepeatedly(Return(true)); + const bool kFalseTrue[] = {false, true}; + for (bool foundMatchedLoginsInStore : kFalseTrue) { + SCOPED_TRACE(testing::Message("foundMatchedLoginsInStore = ") + << foundMatchedLoginsInStore); + std::vector<PasswordForm> observed; + PasswordForm form(MakeFormWithOnlyNewPasswordField()); + observed.push_back(form); + if (foundMatchedLoginsInStore) { + EXPECT_CALL(*store_, GetLogins(_, _)) + .WillRepeatedly(WithArg<1>(InvokeConsumer(form))); + EXPECT_CALL(driver_, FillPasswordForm(_)).Times(2); + EXPECT_CALL(client_, NotifySuccessfulLoginWithExistingPassword(_)) + .Times(1); + } else { + EXPECT_CALL(*store_, GetLogins(_, _)) + .WillRepeatedly(WithArg<1>(InvokeEmptyConsumerWithForms())); + } + EXPECT_CALL(client_, PromptUserToSaveOrUpdatePasswordPtr(_, _)).Times(0); + EXPECT_CALL(client_, AutomaticPasswordSaveIndicator()).Times(1); + manager()->OnPasswordFormsParsed(&driver_, observed); + manager()->OnPasswordFormsRendered(&driver_, observed, true); + + // The user accepts generated password and makes successful login. + EXPECT_CALL(*store_, AddLogin(form)).WillOnce(Return()); + manager()->OnPresaveGeneratedPassword(form); + manager()->SetHasGeneratedPasswordForForm(&driver_, form, true); + ::testing::Mock::VerifyAndClearExpectations(store_.get()); + + EXPECT_CALL(*store_, UpdateLoginWithPrimaryKey(_, form)).WillOnce(Return()); + OnPasswordFormSubmitted(form); + observed.clear(); + manager()->OnPasswordFormsParsed(&driver_, observed); + manager()->OnPasswordFormsRendered(&driver_, observed, true); + } +} + TEST_F(PasswordManagerTest, PasswordGenerationNoCorrespondingPasswordFormManager) { // Verifies that if there is no corresponding password form manager for the
diff --git a/components/password_manager/core/common/credential_manager_types.cc b/components/password_manager/core/common/credential_manager_types.cc index 8f364867e..6d431e1a 100644 --- a/components/password_manager/core/common/credential_manager_types.cc +++ b/components/password_manager/core/common/credential_manager_types.cc
@@ -9,8 +9,16 @@ namespace password_manager { -std::ostream& operator<<(std::ostream& out, CredentialType type) { - return out << static_cast<int>(type); +std::ostream& operator<<(std::ostream& os, CredentialType value) { + switch (value) { + case CredentialType::CREDENTIAL_TYPE_EMPTY: + return os << "CredentialType::CREDENTIAL_TYPE_EMPTY"; + case CredentialType::CREDENTIAL_TYPE_PASSWORD: + return os << "CredentialType::CREDENTIAL_TYPE_PASSWORD"; + case CredentialType::CREDENTIAL_TYPE_FEDERATED: + return os << "CredentialType::CREDENTIAL_TYPE_FEDERATED"; + } + return os << "Unknown CredentialType value: " << static_cast<int32_t>(value); } CredentialInfo::CredentialInfo() : type(CredentialType::CREDENTIAL_TYPE_EMPTY) {
diff --git a/components/password_manager/core/common/credential_manager_types.h b/components/password_manager/core/common/credential_manager_types.h index dbe84fd..2b98e3f 100644 --- a/components/password_manager/core/common/credential_manager_types.h +++ b/components/password_manager/core/common/credential_manager_types.h
@@ -8,6 +8,7 @@ #include <stddef.h> #include <memory> +#include <ostream> #include <string> #include "base/compiler_specific.h" @@ -32,7 +33,7 @@ CREDENTIAL_TYPE_LAST = CREDENTIAL_TYPE_FEDERATED }; -std::ostream& operator<<(std::ostream& out, CredentialType type); +std::ostream& operator<<(std::ostream& os, CredentialType value); struct CredentialInfo { CredentialInfo();
diff --git a/content/browser/accessibility/accessibility_tree_formatter.cc b/content/browser/accessibility/accessibility_tree_formatter.cc index 70a00f4..0aa5bdf 100644 --- a/content/browser/accessibility/accessibility_tree_formatter.cc +++ b/content/browser/accessibility/accessibility_tree_formatter.cc
@@ -6,8 +6,9 @@ #include <stddef.h> +#include <memory> + #include "base/logging.h" -#include "base/memory/scoped_ptr.h" #include "base/strings/pattern.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" @@ -34,18 +35,17 @@ AccessibilityTreeFormatter::~AccessibilityTreeFormatter() { } -scoped_ptr<base::DictionaryValue> -AccessibilityTreeFormatter::BuildAccessibilityTree( - BrowserAccessibility* root) { +std::unique_ptr<base::DictionaryValue> +AccessibilityTreeFormatter::BuildAccessibilityTree(BrowserAccessibility* root) { CHECK(root); - scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); + std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue); RecursiveBuildAccessibilityTree(*root, dict.get()); return dict; } void AccessibilityTreeFormatter::FormatAccessibilityTree( BrowserAccessibility* root, base::string16* contents) { - scoped_ptr<base::DictionaryValue> dict = BuildAccessibilityTree(root); + std::unique_ptr<base::DictionaryValue> dict = BuildAccessibilityTree(root); RecursiveFormatAccessibilityTree(*(dict.get()), contents); }
diff --git a/content/browser/accessibility/accessibility_tree_formatter.h b/content/browser/accessibility/accessibility_tree_formatter.h index fd86f91..dc8961e 100644 --- a/content/browser/accessibility/accessibility_tree_formatter.h +++ b/content/browser/accessibility/accessibility_tree_formatter.h
@@ -73,7 +73,7 @@ // "children": [ ] // } ] // } - scoped_ptr<base::DictionaryValue> BuildAccessibilityTree( + std::unique_ptr<base::DictionaryValue> BuildAccessibilityTree( BrowserAccessibility* root); // Dumps a BrowserAccessibility tree into a string.
diff --git a/content/browser/accessibility/accessibility_tree_formatter_mac.mm b/content/browser/accessibility/accessibility_tree_formatter_mac.mm index 48b9d883..41126020 100644 --- a/content/browser/accessibility/accessibility_tree_formatter_mac.mm +++ b/content/browser/accessibility/accessibility_tree_formatter_mac.mm
@@ -34,9 +34,9 @@ const char* kRangeLocDictAttr = "loc"; const char* kRangeLenDictAttr = "len"; -scoped_ptr<base::DictionaryValue> PopulatePosition( +std::unique_ptr<base::DictionaryValue> PopulatePosition( const BrowserAccessibility& node) { - scoped_ptr<base::DictionaryValue> position(new base::DictionaryValue); + std::unique_ptr<base::DictionaryValue> position(new base::DictionaryValue); // The NSAccessibility position of an object is in global coordinates and // based on the lower-left corner of the object. To make this easier and less // confusing, convert it to local window coordinates using the top-left @@ -60,17 +60,17 @@ return position; } -scoped_ptr<base::DictionaryValue> -PopulateSize(const BrowserAccessibilityCocoa* cocoa_node) { - scoped_ptr<base::DictionaryValue> size(new base::DictionaryValue); +std::unique_ptr<base::DictionaryValue> PopulateSize( + const BrowserAccessibilityCocoa* cocoa_node) { + std::unique_ptr<base::DictionaryValue> size(new base::DictionaryValue); NSSize node_size = [[cocoa_node size] sizeValue]; size->SetInteger(kHeightDictAttr, static_cast<int>(node_size.height)); size->SetInteger(kWidthDictAttr, static_cast<int>(node_size.width)); return size; } -scoped_ptr<base::DictionaryValue> PopulateRange(NSRange range) { - scoped_ptr<base::DictionaryValue> rangeDict(new base::DictionaryValue); +std::unique_ptr<base::DictionaryValue> PopulateRange(NSRange range) { + std::unique_ptr<base::DictionaryValue> rangeDict(new base::DictionaryValue); rangeDict->SetInteger(kRangeLocDictAttr, static_cast<int>(range.location)); rangeDict->SetInteger(kRangeLenDictAttr, static_cast<int>(range.length)); return rangeDict; @@ -83,16 +83,16 @@ return 0 == strcmp([value objCType], @encode(NSRange)); } -scoped_ptr<base::Value> PopulateObject(id value); +std::unique_ptr<base::Value> PopulateObject(id value); -scoped_ptr<base::ListValue> PopulateArray(NSArray* array) { - scoped_ptr<base::ListValue> list(new base::ListValue); +std::unique_ptr<base::ListValue> PopulateArray(NSArray* array) { + std::unique_ptr<base::ListValue> list(new base::ListValue); for (NSUInteger i = 0; i < [array count]; i++) list->Append(PopulateObject([array objectAtIndex:i]).release()); return list; } -scoped_ptr<base::StringValue> StringForBrowserAccessibility( +std::unique_ptr<base::StringValue> StringForBrowserAccessibility( BrowserAccessibilityCocoa* obj) { NSMutableArray* tokens = [[NSMutableArray alloc] init]; @@ -122,23 +122,23 @@ } NSString* result = [tokens componentsJoinedByString:@" "]; - return scoped_ptr<base::StringValue>( + return std::unique_ptr<base::StringValue>( new base::StringValue(SysNSStringToUTF16(result))); } -scoped_ptr<base::Value> PopulateObject(id value) { +std::unique_ptr<base::Value> PopulateObject(id value) { if ([value isKindOfClass:[NSArray class]]) - return scoped_ptr<base::Value>(PopulateArray((NSArray*) value)); + return std::unique_ptr<base::Value>(PopulateArray((NSArray*)value)); if (IsRangeValue(value)) - return scoped_ptr<base::Value>(PopulateRange([value rangeValue])); + return std::unique_ptr<base::Value>(PopulateRange([value rangeValue])); if ([value isKindOfClass:[BrowserAccessibilityCocoa class]]) { std::string str; StringForBrowserAccessibility(value)->GetAsString(&str); - return scoped_ptr<base::Value>(StringForBrowserAccessibility( - (BrowserAccessibilityCocoa*) value)); + return std::unique_ptr<base::Value>( + StringForBrowserAccessibility((BrowserAccessibilityCocoa*)value)); } - return scoped_ptr<base::Value>(new base::StringValue( + return std::unique_ptr<base::Value>(new base::StringValue( SysNSStringToUTF16([NSString stringWithFormat:@"%@", value]))); }
diff --git a/content/browser/accessibility/accessibility_tree_formatter_win.cc b/content/browser/accessibility/accessibility_tree_formatter_win.cc index eaf4fc8f4..6e70d53 100644 --- a/content/browser/accessibility/accessibility_tree_formatter_win.cc +++ b/content/browser/accessibility/accessibility_tree_formatter_win.cc
@@ -189,14 +189,14 @@ IAccessibleStateToStringVector(ia_state, &state_strings); IAccessible2StateToStringVector(ax_object->ia2_state(), &state_strings); - scoped_ptr<base::ListValue> states(new base::ListValue()); + std::unique_ptr<base::ListValue> states(new base::ListValue()); for (const base::string16& state_string : state_strings) states->AppendString(base::UTF16ToUTF8(state_string)); dict->Set("states", std::move(states)); const std::vector<base::string16>& ia2_attributes = ax_object->ia2_attributes(); - scoped_ptr<base::ListValue> attributes(new base::ListValue()); + std::unique_ptr<base::ListValue> attributes(new base::ListValue()); for (const base::string16& ia2_attribute : ia2_attributes) attributes->AppendString(base::UTF16ToUTF8(ia2_attribute)); dict->Set("attributes", std::move(attributes)); @@ -204,7 +204,7 @@ ax_object->ComputeStylesIfNeeded(); const std::map<int, std::vector<base::string16>>& ia2_text_attributes = ax_object->offset_to_text_attributes(); - scoped_ptr<base::ListValue> text_attributes(new base::ListValue()); + std::unique_ptr<base::ListValue> text_attributes(new base::ListValue()); for (const auto& style_span : ia2_text_attributes) { int start_offset = style_span.first; text_attributes->AppendString("offset:" + base::IntToString(start_offset));
diff --git a/content/browser/accessibility/accessibility_ui.cc b/content/browser/accessibility/accessibility_ui.cc index dd23bc1..05f49de 100644 --- a/content/browser/accessibility/accessibility_ui.cc +++ b/content/browser/accessibility/accessibility_ui.cc
@@ -99,9 +99,9 @@ const WebUIDataSource::GotDataCallback& callback) { if (path != kDataFile) return false; - scoped_ptr<base::ListValue> rvh_list(new base::ListValue()); + std::unique_ptr<base::ListValue> rvh_list(new base::ListValue()); - scoped_ptr<RenderWidgetHostIterator> widgets( + std::unique_ptr<RenderWidgetHostIterator> widgets( RenderWidgetHost::GetRenderWidgetHosts()); while (RenderWidgetHost* widget = widgets->GetNextHost()) { @@ -226,7 +226,7 @@ RenderViewHost* rvh = RenderViewHost::FromID(process_id, route_id); if (!rvh) { - scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); result->SetInteger(kProcessIdField, process_id); result->SetInteger(kRouteIdField, route_id); result->Set("error", new base::StringValue("Renderer no longer exists.")); @@ -234,10 +234,10 @@ return; } - scoped_ptr<base::DictionaryValue> result(BuildTargetDescriptor(rvh)); + std::unique_ptr<base::DictionaryValue> result(BuildTargetDescriptor(rvh)); auto web_contents = static_cast<WebContentsImpl*>( WebContents::FromRenderViewHost(rvh)); - scoped_ptr<AccessibilityTreeFormatter> formatter; + std::unique_ptr<AccessibilityTreeFormatter> formatter; if (g_show_internal_accessibility_tree) formatter.reset(new AccessibilityTreeFormatterBlink()); else
diff --git a/content/browser/accessibility/accessibility_win_browsertest.cc b/content/browser/accessibility/accessibility_win_browsertest.cc index f6805bc..9e62aba 100644 --- a/content/browser/accessibility/accessibility_win_browsertest.cc +++ b/content/browser/accessibility/accessibility_win_browsertest.cc
@@ -5,10 +5,10 @@ #include <stddef.h> #include <stdint.h> +#include <memory> #include <vector> #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/strings/string_number_conversions.h" #include "base/strings/sys_string_conversions.h" #include "base/win/scoped_bstr.h" @@ -367,7 +367,7 @@ if (child_count <= 0) return std::vector<base::win::ScopedVariant>(); - scoped_ptr<VARIANT[]> children_array(new VARIANT[child_count]); + std::unique_ptr<VARIANT[]> children_array(new VARIANT[child_count]); LONG obtained_count = 0; hr = AccessibleChildren( element, 0, child_count, children_array.get(), &obtained_count); @@ -667,10 +667,9 @@ document_checker.CheckAccessible(GetRendererAccessible()); // Set focus to the radio group. - scoped_ptr<AccessibilityNotificationWaiter> waiter( - new AccessibilityNotificationWaiter( - shell(), AccessibilityModeComplete, - ui::AX_EVENT_FOCUS)); + std::unique_ptr<AccessibilityNotificationWaiter> waiter( + new AccessibilityNotificationWaiter(shell(), AccessibilityModeComplete, + ui::AX_EVENT_FOCUS)); ExecuteScript(L"document.body.children[0].focus()"); waiter->WaitForNotification(); @@ -712,10 +711,9 @@ document_checker.CheckAccessible(GetRendererAccessible()); // Check the checkbox. - scoped_ptr<AccessibilityNotificationWaiter> waiter( - new AccessibilityNotificationWaiter( - shell(), AccessibilityModeComplete, - ui::AX_EVENT_CHECKED_STATE_CHANGED)); + std::unique_ptr<AccessibilityNotificationWaiter> waiter( + new AccessibilityNotificationWaiter(shell(), AccessibilityModeComplete, + ui::AX_EVENT_CHECKED_STATE_CHANGED)); ExecuteScript(L"document.body.children[0].checked=true"); waiter->WaitForNotification(); @@ -739,11 +737,9 @@ document_checker.CheckAccessible(GetRendererAccessible()); // Change the children of the document body. - scoped_ptr<AccessibilityNotificationWaiter> waiter( - new AccessibilityNotificationWaiter( - shell(), - AccessibilityModeComplete, - ui::AX_EVENT_CHILDREN_CHANGED)); + std::unique_ptr<AccessibilityNotificationWaiter> waiter( + new AccessibilityNotificationWaiter(shell(), AccessibilityModeComplete, + ui::AX_EVENT_CHILDREN_CHANGED)); ExecuteScript(L"document.body.innerHTML='<b>new text</b>'"); waiter->WaitForNotification(); @@ -766,10 +762,9 @@ document_checker.CheckAccessible(GetRendererAccessible()); // Change the children of the document body. - scoped_ptr<AccessibilityNotificationWaiter> waiter( - new AccessibilityNotificationWaiter( - shell(), AccessibilityModeComplete, - ui::AX_EVENT_CHILDREN_CHANGED)); + std::unique_ptr<AccessibilityNotificationWaiter> waiter( + new AccessibilityNotificationWaiter(shell(), AccessibilityModeComplete, + ui::AX_EVENT_CHILDREN_CHANGED)); ExecuteScript(L"document.body.children[0].style.visibility='visible'"); waiter->WaitForNotification(); @@ -799,10 +794,9 @@ document_checker.CheckAccessible(GetRendererAccessible()); // Focus the div in the document - scoped_ptr<AccessibilityNotificationWaiter> waiter( - new AccessibilityNotificationWaiter( - shell(), AccessibilityModeComplete, - ui::AX_EVENT_FOCUS)); + std::unique_ptr<AccessibilityNotificationWaiter> waiter( + new AccessibilityNotificationWaiter(shell(), AccessibilityModeComplete, + ui::AX_EVENT_FOCUS)); ExecuteScript(L"document.body.children[0].focus()"); waiter->WaitForNotification(); @@ -849,10 +843,9 @@ document_checker.CheckAccessible(GetRendererAccessible()); // Set the value of the text control - scoped_ptr<AccessibilityNotificationWaiter> waiter( - new AccessibilityNotificationWaiter( - shell(), AccessibilityModeComplete, - ui::AX_EVENT_VALUE_CHANGED)); + std::unique_ptr<AccessibilityNotificationWaiter> waiter( + new AccessibilityNotificationWaiter(shell(), AccessibilityModeComplete, + ui::AX_EVENT_VALUE_CHANGED)); ExecuteScript(L"document.body.children[0].value='new value'"); waiter->WaitForNotification();
diff --git a/content/browser/accessibility/browser_accessibility_mac_unittest.mm b/content/browser/accessibility/browser_accessibility_mac_unittest.mm index 0b2511d..a76f2fe 100644 --- a/content/browser/accessibility/browser_accessibility_mac_unittest.mm +++ b/content/browser/accessibility/browser_accessibility_mac_unittest.mm
@@ -2,13 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/browser/accessibility/browser_accessibility_mac.h" + #import <Cocoa/Cocoa.h> -#include "base/memory/scoped_ptr.h" +#include <memory> + #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "content/browser/accessibility/browser_accessibility_cocoa.h" -#include "content/browser/accessibility/browser_accessibility_mac.h" #include "content/browser/accessibility/browser_accessibility_manager.h" #include "content/browser/accessibility/browser_accessibility_manager_mac.h" #include "testing/gtest/include/gtest/gtest.h" @@ -59,7 +61,7 @@ } base::scoped_nsobject<BrowserAccessibilityCocoa> accessibility_; - scoped_ptr<BrowserAccessibilityManager> manager_; + std::unique_ptr<BrowserAccessibilityManager> manager_; }; // Standard hit test.
diff --git a/content/browser/accessibility/browser_accessibility_manager.cc b/content/browser/accessibility/browser_accessibility_manager.cc index f7714fa..17c72919 100644 --- a/content/browser/accessibility/browser_accessibility_manager.cc +++ b/content/browser/accessibility/browser_accessibility_manager.cc
@@ -844,10 +844,9 @@ ui::AXTreeUpdate BrowserAccessibilityManager::SnapshotAXTreeForTesting() { - scoped_ptr<ui::AXTreeSource<const ui::AXNode*, - ui::AXNodeData, - ui::AXTreeData> > tree_source( - tree_->CreateTreeSource()); + std::unique_ptr< + ui::AXTreeSource<const ui::AXNode*, ui::AXNodeData, ui::AXTreeData>> + tree_source(tree_->CreateTreeSource()); ui::AXTreeSerializer<const ui::AXNode*, ui::AXNodeData, ui::AXTreeData> serializer(tree_source.get());
diff --git a/content/browser/accessibility/browser_accessibility_manager.h b/content/browser/accessibility/browser_accessibility_manager.h index d3d4f03..55530761 100644 --- a/content/browser/accessibility/browser_accessibility_manager.h +++ b/content/browser/accessibility/browser_accessibility_manager.h
@@ -7,12 +7,12 @@ #include <stdint.h> +#include <memory> #include <vector> #include "base/callback_forward.h" #include "base/containers/hash_tables.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "build/build_config.h" #include "content/browser/accessibility/ax_tree_id_registry.h" #include "content/common/content_export.h" @@ -394,10 +394,10 @@ BrowserAccessibilityDelegate* delegate_; // Factory to create BrowserAccessibility objects (for dependency injection). - scoped_ptr<BrowserAccessibilityFactory> factory_; + std::unique_ptr<BrowserAccessibilityFactory> factory_; // The underlying tree of accessibility objects. - scoped_ptr<ui::AXSerializableTree> tree_; + std::unique_ptr<ui::AXSerializableTree> tree_; // A mapping from a node id to its wrapper of type BrowserAccessibility. base::hash_map<int32_t, BrowserAccessibility*> id_wrapper_map_;
diff --git a/content/browser/accessibility/browser_accessibility_manager_unittest.cc b/content/browser/accessibility/browser_accessibility_manager_unittest.cc index b13338f..609a4b66 100644 --- a/content/browser/accessibility/browser_accessibility_manager_unittest.cc +++ b/content/browser/accessibility/browser_accessibility_manager_unittest.cc
@@ -588,9 +588,9 @@ CountedBrowserAccessibilityFactory* factory = new CountedBrowserAccessibilityFactory(); - scoped_ptr<TestBrowserAccessibilityDelegate> delegate( + std::unique_ptr<TestBrowserAccessibilityDelegate> delegate( new TestBrowserAccessibilityDelegate()); - scoped_ptr<BrowserAccessibilityManager> manager; + std::unique_ptr<BrowserAccessibilityManager> manager; ASSERT_FALSE(delegate->got_fatal_error()); manager.reset(BrowserAccessibilityManager::Create( MakeAXTreeUpdate(root), @@ -682,11 +682,10 @@ ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets2); static_text.child_ids.push_back(4); - scoped_ptr<BrowserAccessibilityManager> manager( + std::unique_ptr<BrowserAccessibilityManager> manager( BrowserAccessibilityManager::Create( MakeAXTreeUpdate(root, static_text, inline_text1, inline_text2), - nullptr, - new CountedBrowserAccessibilityFactory())); + nullptr, new CountedBrowserAccessibilityFactory())); BrowserAccessibility* root_accessible = manager->GetRoot(); ASSERT_NE(nullptr, root_accessible); @@ -769,11 +768,10 @@ ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets2); static_text.child_ids.push_back(4); - scoped_ptr<BrowserAccessibilityManager> manager( + std::unique_ptr<BrowserAccessibilityManager> manager( BrowserAccessibilityManager::Create( MakeAXTreeUpdate(root, static_text, inline_text1, inline_text2), - nullptr, - new CountedBrowserAccessibilityFactory())); + nullptr, new CountedBrowserAccessibilityFactory())); BrowserAccessibility* root_accessible = manager->GetRoot(); ASSERT_NE(nullptr, root_accessible); @@ -831,10 +829,9 @@ ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); static_text.child_ids.push_back(3); - scoped_ptr<BrowserAccessibilityManager> manager( + std::unique_ptr<BrowserAccessibilityManager> manager( BrowserAccessibilityManager::Create( - MakeAXTreeUpdate(root, static_text, inline_text), - nullptr, + MakeAXTreeUpdate(root, static_text, inline_text), nullptr, new CountedBrowserAccessibilityFactory())); BrowserAccessibility* root_accessible = manager->GetRoot(); @@ -912,13 +909,11 @@ inline_text2.AddIntListAttribute( ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets2); - scoped_ptr<BrowserAccessibilityManager> manager( + std::unique_ptr<BrowserAccessibilityManager> manager( BrowserAccessibilityManager::Create( - MakeAXTreeUpdate( - root, div, static_text1, img, - static_text2, inline_text1, inline_text2), - nullptr, - new CountedBrowserAccessibilityFactory())); + MakeAXTreeUpdate(root, div, static_text1, img, static_text2, + inline_text1, inline_text2), + nullptr, new CountedBrowserAccessibilityFactory())); BrowserAccessibility* root_accessible = manager->GetRoot(); ASSERT_NE(nullptr, root_accessible); BrowserAccessibility* div_accessible = root_accessible->PlatformGetChild(0); @@ -964,10 +959,9 @@ node5.id = 5; root.child_ids.push_back(5); - scoped_ptr<BrowserAccessibilityManager> manager( + std::unique_ptr<BrowserAccessibilityManager> manager( BrowserAccessibilityManager::Create( - MakeAXTreeUpdate(root, node2, node3, node4, node5), - nullptr, + MakeAXTreeUpdate(root, node2, node3, node4, node5), nullptr, new CountedBrowserAccessibilityFactory())); BrowserAccessibility* root_accessible = manager->GetRoot(); @@ -1039,12 +1033,11 @@ text4.role = ui::AX_ROLE_LINE_BREAK; node5.child_ids.push_back(9); - scoped_ptr<BrowserAccessibilityManager> manager( + std::unique_ptr<BrowserAccessibilityManager> manager( BrowserAccessibilityManager::Create( - MakeAXTreeUpdate(root, node2, node3, node4, node5, - text1, text2, text3, text4), - nullptr, - new CountedBrowserAccessibilityFactory())); + MakeAXTreeUpdate(root, node2, node3, node4, node5, text1, text2, + text3, text4), + nullptr, new CountedBrowserAccessibilityFactory())); BrowserAccessibility* root_accessible = manager->GetRoot(); ASSERT_NE(nullptr, root_accessible); @@ -1149,7 +1142,7 @@ paragraph_line2.SetName("world."); paragraph_text.child_ids.push_back(paragraph_line2.id); - scoped_ptr<BrowserAccessibilityManager> manager( + std::unique_ptr<BrowserAccessibilityManager> manager( BrowserAccessibilityManager::Create( MakeAXTreeUpdate(root, div, button, button_text, line_break, paragraph, paragraph_text, paragraph_line1, @@ -1293,7 +1286,7 @@ paragraph_line2.SetName("world."); paragraph_text.child_ids.push_back(paragraph_line2.id); - scoped_ptr<BrowserAccessibilityManager> manager( + std::unique_ptr<BrowserAccessibilityManager> manager( BrowserAccessibilityManager::Create( MakeAXTreeUpdate(root, div, button, button_text, line_break, paragraph, paragraph_text, paragraph_line1, @@ -1403,11 +1396,9 @@ ui::AXTreeUpdate initial_state = MakeAXTreeUpdate(root, node2); initial_state.has_tree_data = true; initial_state.tree_data.focus_id = 2; - scoped_ptr<BrowserAccessibilityManager> manager( + std::unique_ptr<BrowserAccessibilityManager> manager( BrowserAccessibilityManager::Create( - initial_state, - nullptr, - new CountedBrowserAccessibilityFactory())); + initial_state, nullptr, new CountedBrowserAccessibilityFactory())); ASSERT_EQ(1, manager->GetRoot()->GetId()); ASSERT_EQ(2, manager->GetFocus()->GetId()); @@ -1455,11 +1446,9 @@ ui::AXTreeUpdate initial_state = MakeAXTreeUpdate(root, node2, node3, node4); initial_state.has_tree_data = true; initial_state.tree_data.focus_id = 2; - scoped_ptr<BrowserAccessibilityManager> manager( + std::unique_ptr<BrowserAccessibilityManager> manager( BrowserAccessibilityManager::Create( - initial_state, - nullptr, - new CountedBrowserAccessibilityFactory())); + initial_state, nullptr, new CountedBrowserAccessibilityFactory())); ASSERT_EQ(1, manager->GetRoot()->GetId()); ASSERT_EQ(2, manager->GetFocus()->GetId());
diff --git a/content/browser/accessibility/browser_accessibility_manager_win.h b/content/browser/accessibility/browser_accessibility_manager_win.h index 04b8aa2..669db87 100644 --- a/content/browser/accessibility/browser_accessibility_manager_win.h +++ b/content/browser/accessibility/browser_accessibility_manager_win.h
@@ -7,8 +7,9 @@ #include <oleacc.h> +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/win/scoped_comptr.h" #include "content/browser/accessibility/browser_accessibility_manager.h" #include "ui/accessibility/platform/ax_platform_node_win.h"
diff --git a/content/browser/accessibility/browser_accessibility_state_impl_win.cc b/content/browser/accessibility/browser_accessibility_state_impl_win.cc index 1267770..d7ec7f6 100644 --- a/content/browser/accessibility/browser_accessibility_state_impl_win.cc +++ b/content/browser/accessibility/browser_accessibility_state_impl_win.cc
@@ -4,13 +4,14 @@ #include "content/browser/accessibility/browser_accessibility_state_impl.h" -#include <windows.h> #include <psapi.h> #include <stddef.h> +#include <windows.h> + +#include <memory> #include "base/files/file_path.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/metrics/histogram.h" #include "base/strings/string_util.h" @@ -45,7 +46,7 @@ if (!EnumProcessModules(process, modules, 0, &bytes_required)) return; - scoped_ptr<char[]> buffer(new char[bytes_required]); + std::unique_ptr<char[]> buffer(new char[bytes_required]); modules = reinterpret_cast<HMODULE*>(buffer.get()); DWORD ignore; if (!EnumProcessModules(process, modules, bytes_required, &ignore))
diff --git a/content/browser/accessibility/browser_accessibility_win.h b/content/browser/accessibility/browser_accessibility_win.h index 82e03ca..b43eda1 100644 --- a/content/browser/accessibility/browser_accessibility_win.h +++ b/content/browser/accessibility/browser_accessibility_win.h
@@ -923,11 +923,11 @@ std::vector<int32_t> hyperlinks; }; - scoped_ptr<WinAttributes> win_attributes_; + std::unique_ptr<WinAttributes> win_attributes_; // Only valid during the scope of a IA2_EVENT_TEXT_REMOVED or // IA2_EVENT_TEXT_INSERTED event. - scoped_ptr<WinAttributes> old_win_attributes_; + std::unique_ptr<WinAttributes> old_win_attributes_; // Relationships between this node and other nodes. std::vector<BrowserAccessibilityRelation*> relations_;
diff --git a/content/browser/accessibility/browser_accessibility_win_unittest.cc b/content/browser/accessibility/browser_accessibility_win_unittest.cc index e8c236a..889fb81b73 100644 --- a/content/browser/accessibility/browser_accessibility_win_unittest.cc +++ b/content/browser/accessibility/browser_accessibility_win_unittest.cc
@@ -2,10 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/browser/accessibility/browser_accessibility_win.h" + #include <stdint.h> +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/strings/utf_string_conversions.h" #include "base/win/scoped_bstr.h" #include "base/win/scoped_comptr.h" @@ -13,7 +16,6 @@ #include "content/browser/accessibility/browser_accessibility_manager.h" #include "content/browser/accessibility/browser_accessibility_manager_win.h" #include "content/browser/accessibility/browser_accessibility_state_impl.h" -#include "content/browser/accessibility/browser_accessibility_win.h" #include "content/browser/renderer_host/legacy_render_widget_host_win.h" #include "content/common/accessibility_messages.h" #include "content/public/test/test_browser_thread_bundle.h" @@ -145,10 +147,10 @@ // BrowserAccessibility, and ensure that exactly 3 instances were // created. Note that the manager takes ownership of the factory. CountedBrowserAccessibility::reset(); - scoped_ptr<BrowserAccessibilityManager> manager( + std::unique_ptr<BrowserAccessibilityManager> manager( BrowserAccessibilityManager::Create( - MakeAXTreeUpdate(root, button, checkbox), - NULL, new CountedBrowserAccessibilityFactory())); + MakeAXTreeUpdate(root, button, checkbox), NULL, + new CountedBrowserAccessibilityFactory())); ASSERT_EQ(3, CountedBrowserAccessibility::num_instances()); // Delete the manager and test that all 3 instances are deleted. @@ -205,10 +207,10 @@ // ui::AXNodeData tree and a factory for an instance-counting // BrowserAccessibility. CountedBrowserAccessibility::reset(); - scoped_ptr<BrowserAccessibilityManager> manager( + std::unique_ptr<BrowserAccessibilityManager> manager( BrowserAccessibilityManager::Create( - MakeAXTreeUpdate(root, text), - NULL, new CountedBrowserAccessibilityFactory())); + MakeAXTreeUpdate(root, text), NULL, + new CountedBrowserAccessibilityFactory())); // Query for the text IAccessible and verify that it returns "old text" as its // value. @@ -301,10 +303,10 @@ // BrowserAccessibility and ensure that exactly 4 instances were // created. Note that the manager takes ownership of the factory. CountedBrowserAccessibility::reset(); - scoped_ptr<BrowserAccessibilityManager> manager( + std::unique_ptr<BrowserAccessibilityManager> manager( BrowserAccessibilityManager::Create( - MakeAXTreeUpdate(root, div, text3, text4), - NULL, new CountedBrowserAccessibilityFactory())); + MakeAXTreeUpdate(root, div, text3, text4), NULL, + new CountedBrowserAccessibilityFactory())); ASSERT_EQ(4, CountedBrowserAccessibility::num_instances()); // Notify the BrowserAccessibilityManager that the div node and its children @@ -387,10 +389,10 @@ ui::AX_ATTR_WORD_STARTS, word_start_offsets2); CountedBrowserAccessibility::reset(); - scoped_ptr<BrowserAccessibilityManager> manager( + std::unique_ptr<BrowserAccessibilityManager> manager( BrowserAccessibilityManager::Create( MakeAXTreeUpdate(root, text_field, static_text1, inline_box1, - line_break, static_text2, inline_box2), + line_break, static_text2, inline_box2), nullptr, new CountedBrowserAccessibilityFactory())); ASSERT_EQ(7, CountedBrowserAccessibility::num_instances()); @@ -508,7 +510,7 @@ root.child_ids.push_back(text2.id); CountedBrowserAccessibility::reset(); - scoped_ptr<BrowserAccessibilityManager> manager( + std::unique_ptr<BrowserAccessibilityManager> manager( BrowserAccessibilityManager::Create( MakeAXTreeUpdate(root, text1, text2), nullptr, new CountedBrowserAccessibilityFactory())); @@ -628,7 +630,7 @@ root.child_ids.push_back(link.id); CountedBrowserAccessibility::reset(); - scoped_ptr<BrowserAccessibilityManager> manager( + std::unique_ptr<BrowserAccessibilityManager> manager( BrowserAccessibilityManager::Create( MakeAXTreeUpdate(root, text1, combo_box, text2, check_box, button, button_text, link, link_text), @@ -725,10 +727,9 @@ const int32_t busy_state = 1 << ui::AX_STATE_BUSY; const int32_t readonly_state = 1 << ui::AX_STATE_READ_ONLY; const int32_t enabled_state = 1 << ui::AX_STATE_ENABLED; - scoped_ptr<BrowserAccessibilityManager> manager( + std::unique_ptr<BrowserAccessibilityManager> manager( new BrowserAccessibilityManagerWin( - BrowserAccessibilityManagerWin::GetEmptyDocument(), - NULL, + BrowserAccessibilityManagerWin::GetEmptyDocument(), NULL, new CountedBrowserAccessibilityFactory())); // Verify the root is as we expect by default. @@ -805,10 +806,9 @@ // BrowserAccessibilityManager code before BrowserAccessibilityManagerWin // was initialized. TEST_F(BrowserAccessibilityTest, EmptyDocHasUniqueIdWin) { - scoped_ptr<BrowserAccessibilityManagerWin> manager( + std::unique_ptr<BrowserAccessibilityManagerWin> manager( new BrowserAccessibilityManagerWin( - BrowserAccessibilityManagerWin::GetEmptyDocument(), - NULL, + BrowserAccessibilityManagerWin::GetEmptyDocument(), NULL, new CountedBrowserAccessibilityFactory())); // Verify the root is as we expect by default. @@ -846,7 +846,7 @@ root.child_ids.push_back(3); CountedBrowserAccessibility::reset(); - scoped_ptr<BrowserAccessibilityManager> manager( + std::unique_ptr<BrowserAccessibilityManager> manager( BrowserAccessibilityManager::Create( MakeAXTreeUpdate(root, pseudo_before, checkbox), nullptr, new CountedBrowserAccessibilityFactory())); @@ -951,7 +951,7 @@ root.child_ids.push_back(10); // Slider. CountedBrowserAccessibility::reset(); - scoped_ptr<BrowserAccessibilityManager> manager( + std::unique_ptr<BrowserAccessibilityManager> manager( BrowserAccessibilityManager::Create( MakeAXTreeUpdate(root, combo_box, combo_box_text, search_box, search_box_text, new_line, text_field, link, @@ -1113,7 +1113,7 @@ root.child_ids.push_back(7); // Text field. CountedBrowserAccessibility::reset(); - scoped_ptr<BrowserAccessibilityManager> manager( + std::unique_ptr<BrowserAccessibilityManager> manager( BrowserAccessibilityManager::Create( MakeAXTreeUpdate(root, textarea, textarea_div, textarea_text, textarea_line1, textarea_line2, text_field, @@ -1214,10 +1214,10 @@ root.child_ids.push_back(3); CountedBrowserAccessibility::reset(); - scoped_ptr<BrowserAccessibilityManager> manager( + std::unique_ptr<BrowserAccessibilityManager> manager( BrowserAccessibilityManager::Create( - MakeAXTreeUpdate(root, combo_box, text_field), - nullptr, new CountedBrowserAccessibilityFactory())); + MakeAXTreeUpdate(root, combo_box, text_field), nullptr, + new CountedBrowserAccessibilityFactory())); ASSERT_EQ(3, CountedBrowserAccessibility::num_instances()); ASSERT_NE(nullptr, manager->GetRoot()); @@ -1334,10 +1334,9 @@ update.tree_data.sel_focus_offset = 1; CountedBrowserAccessibility::reset(); - scoped_ptr<BrowserAccessibilityManager> manager( + std::unique_ptr<BrowserAccessibilityManager> manager( BrowserAccessibilityManager::Create( - update, - nullptr, new CountedBrowserAccessibilityFactory())); + update, nullptr, new CountedBrowserAccessibilityFactory())); ASSERT_EQ(5, CountedBrowserAccessibility::num_instances()); ASSERT_NE(nullptr, manager->GetRoot()); @@ -1452,10 +1451,9 @@ update.tree_data.sel_focus_offset = 4; CountedBrowserAccessibility::reset(); - scoped_ptr<BrowserAccessibilityManager> manager( + std::unique_ptr<BrowserAccessibilityManager> manager( BrowserAccessibilityManager::Create( - update, - nullptr, new CountedBrowserAccessibilityFactory())); + update, nullptr, new CountedBrowserAccessibilityFactory())); ASSERT_EQ(5, CountedBrowserAccessibility::num_instances()); ASSERT_NE(nullptr, manager->GetRoot()); @@ -1588,7 +1586,7 @@ div.child_ids.push_back(4); CountedBrowserAccessibility::reset(); - scoped_ptr<BrowserAccessibilityManager> manager( + std::unique_ptr<BrowserAccessibilityManager> manager( BrowserAccessibilityManager::Create( MakeAXTreeUpdate(root, div, link, text), nullptr, new CountedBrowserAccessibilityFactory())); @@ -1739,7 +1737,7 @@ child2_child2.role = ui::AX_ROLE_INLINE_TEXT_BOX; child2.child_ids.push_back(5); - scoped_ptr<BrowserAccessibilityManager> manager( + std::unique_ptr<BrowserAccessibilityManager> manager( BrowserAccessibilityManager::Create( MakeAXTreeUpdate(root, child1, child2, child2_child1, child2_child2), nullptr, new CountedBrowserAccessibilityFactory())); @@ -1822,7 +1820,7 @@ child2_child2.role = ui::AX_ROLE_INLINE_TEXT_BOX; child2.child_ids.push_back(5); - scoped_ptr<BrowserAccessibilityManager> manager( + std::unique_ptr<BrowserAccessibilityManager> manager( BrowserAccessibilityManager::Create( MakeAXTreeUpdate(root, child1, child2, child2_child1, child2_child2), nullptr, new CountedBrowserAccessibilityFactory())); @@ -1924,10 +1922,9 @@ child_node.id = 2; root_node.child_ids.push_back(2); - scoped_ptr<BrowserAccessibilityManagerWin> manager( + std::unique_ptr<BrowserAccessibilityManagerWin> manager( new BrowserAccessibilityManagerWin( - MakeAXTreeUpdate(root_node, child_node), - nullptr, + MakeAXTreeUpdate(root_node, child_node), nullptr, new CountedBrowserAccessibilityFactory())); BrowserAccessibility* root = manager->GetRoot(); @@ -1986,10 +1983,9 @@ child_node.id = 2; root_node.child_ids.push_back(2); - scoped_ptr<BrowserAccessibilityManagerWin> manager( + std::unique_ptr<BrowserAccessibilityManagerWin> manager( new BrowserAccessibilityManagerWin( - MakeAXTreeUpdate(root_node, child_node), - nullptr, + MakeAXTreeUpdate(root_node, child_node), nullptr, new CountedBrowserAccessibilityFactory())); BrowserAccessibility* root = manager->GetRoot();
diff --git a/content/browser/accessibility/cross_platform_accessibility_browsertest.cc b/content/browser/accessibility/cross_platform_accessibility_browsertest.cc index 9866b326..fb5526b 100644 --- a/content/browser/accessibility/cross_platform_accessibility_browsertest.cc +++ b/content/browser/accessibility/cross_platform_accessibility_browsertest.cc
@@ -75,7 +75,7 @@ private: #if defined(OS_WIN) - scoped_ptr<base::win::ScopedCOMInitializer> com_initializer_; + std::unique_ptr<base::win::ScopedCOMInitializer> com_initializer_; #endif DISALLOW_COPY_AND_ASSIGN(CrossPlatformAccessibilityBrowserTest);
diff --git a/content/browser/accessibility/dump_accessibility_browsertest_base.cc b/content/browser/accessibility/dump_accessibility_browsertest_base.cc index 986fdc06..51a03a0 100644 --- a/content/browser/accessibility/dump_accessibility_browsertest_base.cc +++ b/content/browser/accessibility/dump_accessibility_browsertest_base.cc
@@ -93,7 +93,7 @@ base::string16 DumpAccessibilityTestBase::DumpUnfilteredAccessibilityTreeAsString() { - scoped_ptr<AccessibilityTreeFormatter> formatter( + std::unique_ptr<AccessibilityTreeFormatter> formatter( CreateAccessibilityTreeFormatter()); std::vector<Filter> filters; filters.push_back(Filter(base::ASCIIToUTF16("*"), Filter::ALLOW));
diff --git a/content/browser/accessibility/dump_accessibility_browsertest_base.h b/content/browser/accessibility/dump_accessibility_browsertest_base.h index 5e93b9be..58a69bc 100644 --- a/content/browser/accessibility/dump_accessibility_browsertest_base.h +++ b/content/browser/accessibility/dump_accessibility_browsertest_base.h
@@ -103,7 +103,7 @@ #endif // The current AccessibilityTreeFormatter. - scoped_ptr<AccessibilityTreeFormatter> formatter_; + std::unique_ptr<AccessibilityTreeFormatter> formatter_; // Whether we're doing a native pass or internal/blink tree pass. bool is_blink_pass_;
diff --git a/content/browser/accessibility/dump_accessibility_events_browsertest.cc b/content/browser/accessibility/dump_accessibility_events_browsertest.cc index 40d3336..637158c 100644 --- a/content/browser/accessibility/dump_accessibility_events_browsertest.cc +++ b/content/browser/accessibility/dump_accessibility_events_browsertest.cc
@@ -75,7 +75,7 @@ std::vector<std::string> DumpAccessibilityEventsTest::Dump() { WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( shell()->web_contents()); - scoped_ptr<AccessibilityEventRecorder> event_recorder( + std::unique_ptr<AccessibilityEventRecorder> event_recorder( AccessibilityEventRecorder::Create( web_contents->GetRootBrowserAccessibilityManager())); @@ -87,7 +87,7 @@ // This will ensure that after calling the go() function, we // block until we've received an accessibility event generated as // a result of this function. - scoped_ptr<AccessibilityNotificationWaiter> waiter; + std::unique_ptr<AccessibilityNotificationWaiter> waiter; waiter.reset(new AccessibilityNotificationWaiter( shell(), AccessibilityModeComplete, ui::AX_EVENT_NONE));
diff --git a/content/browser/accessibility/dump_accessibility_tree_browsertest.cc b/content/browser/accessibility/dump_accessibility_tree_browsertest.cc index e1aa6a4..0c66be2 100644 --- a/content/browser/accessibility/dump_accessibility_tree_browsertest.cc +++ b/content/browser/accessibility/dump_accessibility_tree_browsertest.cc
@@ -102,7 +102,7 @@ } std::vector<std::string> Dump() override { - scoped_ptr<AccessibilityTreeFormatter> formatter( + std::unique_ptr<AccessibilityTreeFormatter> formatter( CreateAccessibilityTreeFormatter()); formatter->SetFilters(filters_); base::string16 actual_contents_utf16;
diff --git a/content/browser/accessibility/one_shot_accessibility_tree_search_unittest.cc b/content/browser/accessibility/one_shot_accessibility_tree_search_unittest.cc index be30284..21dc1c5 100644 --- a/content/browser/accessibility/one_shot_accessibility_tree_search_unittest.cc +++ b/content/browser/accessibility/one_shot_accessibility_tree_search_unittest.cc
@@ -2,11 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/browser/accessibility/one_shot_accessibility_tree_search.h" + +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/accessibility/browser_accessibility.h" #include "content/browser/accessibility/browser_accessibility_manager.h" -#include "content/browser/accessibility/one_shot_accessibility_tree_search.h" #include "testing/gtest/include/gtest/gtest.h" namespace content { @@ -38,7 +40,7 @@ protected: void SetUp() override; - scoped_ptr<BrowserAccessibilityManager> tree_; + std::unique_ptr<BrowserAccessibilityManager> tree_; private: DISALLOW_COPY_AND_ASSIGN(MAYBE_OneShotAccessibilityTreeSearchTest);
diff --git a/content/browser/accessibility/touch_accessibility_aura_browsertest.cc b/content/browser/accessibility/touch_accessibility_aura_browsertest.cc index 0e2e0cc..89bc0db4d0 100644 --- a/content/browser/accessibility/touch_accessibility_aura_browsertest.cc +++ b/content/browser/accessibility/touch_accessibility_aura_browsertest.cc
@@ -84,9 +84,9 @@ gfx::Point location(bounds.x() + 50 * col + 25, bounds.y() + 50 * row + 25); int flags = ui::EF_TOUCH_ACCESSIBILITY; - scoped_ptr<ui::Event> mouse_move_event(new ui::MouseEvent( - ui::ET_MOUSE_MOVED, location, location, ui::EventTimeForNow(), - flags, 0)); + std::unique_ptr<ui::Event> mouse_move_event( + new ui::MouseEvent(ui::ET_MOUSE_MOVED, location, location, + ui::EventTimeForNow(), flags, 0)); ignore_result(dispatcher->OnEventFromSource(mouse_move_event.get())); // Wait until we get a hover event in the expected grid cell.
diff --git a/content/browser/android/child_process_launcher_android.cc b/content/browser/android/child_process_launcher_android.cc index 11bb6de41..05960344 100644 --- a/content/browser/android/child_process_launcher_android.cc +++ b/content/browser/android/child_process_launcher_android.cc
@@ -6,13 +6,14 @@ #include <stddef.h> #include <stdint.h> + +#include <memory> #include <utility> #include "base/android/context_utils.h" #include "base/android/jni_android.h" #include "base/android/jni_array.h" #include "base/logging.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/file_descriptor_info_impl.h" #include "content/browser/frame_host/render_frame_host_impl.h" #include "content/browser/media/android/browser_media_player_manager.h" @@ -89,7 +90,7 @@ } void LaunchDownloadProcess(base::CommandLine* cmd_line) { - scoped_ptr<base::CommandLine> cmd_line_deleter(cmd_line); + std::unique_ptr<base::CommandLine> cmd_line_deleter(cmd_line); JNIEnv* env = AttachCurrentThread(); DCHECK(env); @@ -151,7 +152,7 @@ void StartChildProcess( const base::CommandLine::StringVector& argv, int child_process_id, - scoped_ptr<content::FileDescriptorInfo> files_to_register, + std::unique_ptr<content::FileDescriptorInfo> files_to_register, const std::map<int, base::MemoryMappedFile::Region>& regions, const StartChildProcessCallback& callback) { JNIEnv* env = AttachCurrentThread();
diff --git a/content/browser/android/child_process_launcher_android.h b/content/browser/android/child_process_launcher_android.h index f81c5c3..a8ea904 100644 --- a/content/browser/android/child_process_launcher_android.h +++ b/content/browser/android/child_process_launcher_android.h
@@ -8,11 +8,11 @@ #include <jni.h> #include <map> +#include <memory> #include "base/callback.h" #include "base/command_line.h" #include "base/files/memory_mapped_file.h" -#include "base/memory/scoped_ptr.h" #include "base/process/process.h" #include "content/public/browser/file_descriptor_info.h" #include "ui/gl/android/scoped_java_surface.h" @@ -27,7 +27,7 @@ void StartChildProcess( const base::CommandLine::StringVector& argv, int child_process_id, - const scoped_ptr<FileDescriptorInfo> files_to_register, + const std::unique_ptr<FileDescriptorInfo> files_to_register, const std::map<int, base::MemoryMappedFile::Region>& regions, const StartChildProcessCallback& callback);
diff --git a/content/browser/android/content_protocol_handler_impl.cc b/content/browser/android/content_protocol_handler_impl.cc index 8f8b13a..143dc30 100644 --- a/content/browser/android/content_protocol_handler_impl.cc +++ b/content/browser/android/content_protocol_handler_impl.cc
@@ -4,6 +4,7 @@ #include "content/browser/android/content_protocol_handler_impl.h" +#include "base/memory/ptr_util.h" #include "base/task_runner.h" #include "content/browser/android/url_request_content_job.h" #include "net/base/net_errors.h" @@ -13,9 +14,9 @@ namespace content { // static -scoped_ptr<ContentProtocolHandler> ContentProtocolHandler::Create( +std::unique_ptr<ContentProtocolHandler> ContentProtocolHandler::Create( const scoped_refptr<base::TaskRunner>& content_task_runner) { - return make_scoped_ptr(new ContentProtocolHandlerImpl(content_task_runner)); + return base::WrapUnique(new ContentProtocolHandlerImpl(content_task_runner)); } ContentProtocolHandlerImpl::ContentProtocolHandlerImpl(
diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc index f535101..82c2b5e 100644 --- a/content/browser/android/content_view_core_impl.cc +++ b/content/browser/android/content_view_core_impl.cc
@@ -505,7 +505,7 @@ // given |selected_item| as is. ScopedJavaLocalRef<jintArray> selected_array; if (multiple) { - scoped_ptr<jint[]> native_selected_array(new jint[items.size()]); + std::unique_ptr<jint[]> native_selected_array(new jint[items.size()]); size_t selected_count = 0; for (size_t i = 0; i < items.size(); ++i) { if (items[i].checked)
diff --git a/content/browser/android/content_view_core_impl.h b/content/browser/android/content_view_core_impl.h index 8f8c694..b022e7e 100644 --- a/content/browser/android/content_view_core_impl.h +++ b/content/browser/android/content_view_core_impl.h
@@ -7,6 +7,7 @@ #include <stdint.h> +#include <memory> #include <vector> #include "base/android/jni_android.h" @@ -14,7 +15,6 @@ #include "base/compiler_specific.h" #include "base/i18n/rtl.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/process/process.h" #include "content/browser/android/content_view_core_impl_observer.h" #include "content/browser/renderer_host/render_widget_host_view_android.h"
diff --git a/content/browser/android/content_view_render_view.cc b/content/browser/android/content_view_render_view.cc index be3064e0..ed6a19c 100644 --- a/content/browser/android/content_view_render_view.cc +++ b/content/browser/android/content_view_render_view.cc
@@ -4,12 +4,16 @@ #include "content/browser/android/content_view_render_view.h" +#include <android/bitmap.h> +#include <android/native_window_jni.h> + +#include <memory> + #include "base/android/jni_android.h" #include "base/android/jni_string.h" #include "base/android/scoped_java_ref.h" #include "base/bind.h" #include "base/lazy_instance.h" -#include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" #include "cc/layers/layer.h" #include "content/browser/android/content_view_core_impl.h" @@ -19,9 +23,6 @@ #include "ui/gfx/android/java_bitmap.h" #include "ui/gfx/geometry/size.h" -#include <android/bitmap.h> -#include <android/native_window_jni.h> - using base::android::ScopedJavaLocalRef; namespace content {
diff --git a/content/browser/android/content_view_render_view.h b/content/browser/android/content_view_render_view.h index 50f3b9c..57fee7e2 100644 --- a/content/browser/android/content_view_render_view.h +++ b/content/browser/android/content_view_render_view.h
@@ -5,10 +5,11 @@ #ifndef CONTENT_BROWSER_ANDROID_CONTENT_VIEW_RENDER_VIEW_H_ #define CONTENT_BROWSER_ANDROID_CONTENT_VIEW_RENDER_VIEW_H_ +#include <memory> + #include "base/android/jni_weak_ref.h" #include "base/logging.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "content/public/browser/android/compositor_client.h" #include "ui/gfx/native_widget_types.h" @@ -60,7 +61,7 @@ base::android::ScopedJavaGlobalRef<jobject> java_obj_; - scoped_ptr<content::Compositor> compositor_; + std::unique_ptr<content::Compositor> compositor_; gfx::NativeWindow root_window_; int current_surface_format_;
diff --git a/content/browser/android/date_time_chooser_android.h b/content/browser/android/date_time_chooser_android.h index 05a8bdd3..07d5210 100644 --- a/content/browser/android/date_time_chooser_android.h +++ b/content/browser/android/date_time_chooser_android.h
@@ -5,12 +5,12 @@ #ifndef CONTENT_BROWSER_ANDROID_DATE_TIME_CHOOSER_ANDROID_H_ #define CONTENT_BROWSER_ANDROID_DATE_TIME_CHOOSER_ANDROID_H_ +#include <memory> #include <string> #include <vector> #include "base/android/jni_weak_ref.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "ui/base/ime/text_input_type.h" #include "ui/gfx/native_widget_types.h"
diff --git a/content/browser/android/deferred_download_observer.cc b/content/browser/android/deferred_download_observer.cc index b1c6c7d..e41e4847 100644 --- a/content/browser/android/deferred_download_observer.cc +++ b/content/browser/android/deferred_download_observer.cc
@@ -4,7 +4,8 @@ #include "content/browser/android/deferred_download_observer.h" -#include "base/memory/scoped_ptr.h" +#include <memory> + #include "content/browser/android/download_controller_android_impl.h" #include "content/public/browser/web_contents.h"
diff --git a/content/browser/android/download_controller_android_impl.cc b/content/browser/android/download_controller_android_impl.cc index e0492d1..04542bb 100644 --- a/content/browser/android/download_controller_android_impl.cc +++ b/content/browser/android/download_controller_android_impl.cc
@@ -4,6 +4,7 @@ #include "content/browser/android/download_controller_android_impl.h" +#include <memory> #include <utility> #include "base/android/context_utils.h" @@ -12,7 +13,6 @@ #include "base/bind.h" #include "base/lazy_instance.h" #include "base/logging.h" -#include "base/memory/scoped_ptr.h" #include "base/synchronization/lock.h" #include "base/time/time.h" #include "content/browser/android/content_view_core_impl.h" @@ -80,7 +80,7 @@ static_cast<content::DownloadManagerImpl*>( content::BrowserContext::GetDownloadManager( web_contents->GetBrowserContext())); - scoped_ptr<content::DownloadUrlParameters> dl_params( + std::unique_ptr<content::DownloadUrlParameters> dl_params( content::DownloadUrlParameters::FromWebContents(web_contents, url)); content::Referrer referrer = content::Referrer::SanitizeForRequest( url, @@ -126,10 +126,11 @@ DCHECK(callback_id); // Convert java long long int to c++ pointer, take ownership. - scoped_ptr<DownloadControllerAndroid::AcquireFileAccessPermissionCallback> cb( - reinterpret_cast< - DownloadControllerAndroid::AcquireFileAccessPermissionCallback*>( - callback_id)); + std::unique_ptr< + DownloadControllerAndroid::AcquireFileAccessPermissionCallback> + cb(reinterpret_cast< + DownloadControllerAndroid::AcquireFileAccessPermissionCallback*>( + callback_id)); cb->Run(granted); } @@ -479,8 +480,7 @@ item->GetReceivedBytes(), item->GetId(), jguid.obj(), item->PercentComplete(), time_delta.InMilliseconds(), item->HasUserGesture(), item->IsPaused(), - // Get all requirements that allows a download to be resumable. - !item->GetBrowserContext()->IsOffTheRecord()); + item->GetBrowserContext()->IsOffTheRecord()); break; } case DownloadItem::COMPLETE: @@ -508,7 +508,8 @@ env, GetJavaObject()->Controller(env).obj(), jurl.obj(), jmime_type.obj(), jfilename.obj(), jpath.obj(), item->GetReceivedBytes(), item->GetId(), jguid.obj(), - item->CanResume(), IsInterruptedDownloadAutoResumable(item)); + item->CanResume(), IsInterruptedDownloadAutoResumable(item), + item->GetBrowserContext()->IsOffTheRecord()); item->RemoveObserver(this); break; case DownloadItem::MAX_DOWNLOAD_STATE:
diff --git a/content/browser/android/in_process/context_provider_in_process.cc b/content/browser/android/in_process/context_provider_in_process.cc index e7cbb65e..7dd5f40 100644 --- a/content/browser/android/in_process/context_provider_in_process.cc +++ b/content/browser/android/in_process/context_provider_in_process.cc
@@ -42,7 +42,7 @@ // static scoped_refptr<ContextProviderInProcess> ContextProviderInProcess::Create( - scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d, + std::unique_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d, const std::string& debug_name) { if (!context3d) return nullptr; @@ -50,7 +50,7 @@ } ContextProviderInProcess::ContextProviderInProcess( - scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d, + std::unique_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d, const std::string& debug_name) : context3d_(std::move(context3d)), debug_name_(debug_name) { DCHECK(main_thread_checker_.CalledOnValidThread());
diff --git a/content/browser/android/in_process/context_provider_in_process.h b/content/browser/android/in_process/context_provider_in_process.h index 37f494a..beeaf727 100644 --- a/content/browser/android/in_process/context_provider_in_process.h +++ b/content/browser/android/in_process/context_provider_in_process.h
@@ -7,10 +7,10 @@ #include <stdint.h> +#include <memory> #include <string> #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/synchronization/lock.h" #include "base/threading/thread_checker.h" #include "cc/blink/context_provider_web_context.h" @@ -29,13 +29,13 @@ : NON_EXPORTED_BASE(public cc_blink::ContextProviderWebContext) { public: static scoped_refptr<ContextProviderInProcess> Create( - scoped_ptr<gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl> + std::unique_ptr<gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl> context3d, const std::string& debug_name); private: ContextProviderInProcess( - scoped_ptr<gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl> + std::unique_ptr<gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl> context3d, const std::string& debug_name); ~ContextProviderInProcess() override; @@ -63,16 +63,16 @@ base::ThreadChecker main_thread_checker_; base::ThreadChecker context_thread_checker_; - scoped_ptr<gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl> + std::unique_ptr<gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl> context3d_; - scoped_ptr<GrContextForGLES2Interface> gr_context_; + std::unique_ptr<GrContextForGLES2Interface> gr_context_; LostContextCallback lost_context_callback_; base::Lock context_lock_; std::string debug_name_; class LostContextCallbackProxy; - scoped_ptr<LostContextCallbackProxy> lost_context_callback_proxy_; + std::unique_ptr<LostContextCallbackProxy> lost_context_callback_proxy_; cc::ContextProvider::Capabilities capabilities_;
diff --git a/content/browser/android/in_process/synchronous_compositor_factory_impl.cc b/content/browser/android/in_process/synchronous_compositor_factory_impl.cc index 4e5f3f1..720c56d 100644 --- a/content/browser/android/in_process/synchronous_compositor_factory_impl.cc +++ b/content/browser/android/in_process/synchronous_compositor_factory_impl.cc
@@ -5,10 +5,12 @@ #include "content/browser/android/in_process/synchronous_compositor_factory_impl.h" #include <stdint.h> + #include <utility> #include "base/command_line.h" #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/observer_list.h" #include "base/sys_info.h" #include "base/thread_task_runner_handle.h" @@ -42,7 +44,8 @@ namespace { struct ContextHolder { - scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> command_buffer; + std::unique_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> + command_buffer; gpu::GLInProcessContext* gl_in_process_context; }; @@ -51,17 +54,18 @@ scoped_refptr<gpu::InProcessCommandBuffer::Service> service, const gpu::GLInProcessContextSharedMemoryLimits& mem_limits) { bool is_offscreen = true; - scoped_ptr<gpu::GLInProcessContext> context(gpu::GLInProcessContext::Create( - service, nullptr /* surface */, is_offscreen, gfx::kNullAcceleratedWidget, - gfx::Size(1, 1), nullptr /* share_context */, attributes, - gfx::PreferDiscreteGpu, mem_limits, - BrowserGpuMemoryBufferManager::current(), nullptr)); + std::unique_ptr<gpu::GLInProcessContext> context( + gpu::GLInProcessContext::Create( + service, nullptr /* surface */, is_offscreen, + gfx::kNullAcceleratedWidget, gfx::Size(1, 1), + nullptr /* share_context */, attributes, gfx::PreferDiscreteGpu, + mem_limits, BrowserGpuMemoryBufferManager::current(), nullptr)); gpu::GLInProcessContext* context_ptr = context.get(); ContextHolder holder; holder.command_buffer = - scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>( + std::unique_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>( WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext( std::move(context), attributes)); holder.gl_in_process_context = context_ptr; @@ -86,14 +90,14 @@ return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI); } -scoped_ptr<cc::OutputSurface> +std::unique_ptr<cc::OutputSurface> SynchronousCompositorFactoryImpl::CreateOutputSurface( int routing_id, uint32_t output_surface_id, const scoped_refptr<FrameSwapMessageQueue>& frame_swap_message_queue, const scoped_refptr<cc::ContextProvider>& onscreen_context, const scoped_refptr<cc::ContextProvider>& worker_context) { - return make_scoped_ptr(new SynchronousCompositorOutputSurface( + return base::WrapUnique(new SynchronousCompositorOutputSurface( onscreen_context, worker_context, routing_id, output_surface_id, SynchronousCompositorRegistryInProc::GetInstance(), frame_swap_message_queue)); @@ -109,10 +113,10 @@ return synchronous_input_event_filter(); } -scoped_ptr<cc::BeginFrameSource> +std::unique_ptr<cc::BeginFrameSource> SynchronousCompositorFactoryImpl::CreateExternalBeginFrameSource( int routing_id) { - return make_scoped_ptr(new SynchronousCompositorExternalBeginFrameSource( + return base::WrapUnique(new SynchronousCompositorExternalBeginFrameSource( routing_id, SynchronousCompositorRegistryInProc::GetInstance())); }
diff --git a/content/browser/android/in_process/synchronous_compositor_factory_impl.h b/content/browser/android/in_process/synchronous_compositor_factory_impl.h index 4842e85..372c617 100644 --- a/content/browser/android/in_process/synchronous_compositor_factory_impl.h +++ b/content/browser/android/in_process/synchronous_compositor_factory_impl.h
@@ -39,7 +39,7 @@ // SynchronousCompositorFactory scoped_refptr<base::SingleThreadTaskRunner> GetCompositorTaskRunner() override; - scoped_ptr<cc::OutputSurface> CreateOutputSurface( + std::unique_ptr<cc::OutputSurface> CreateOutputSurface( int routing_id, uint32_t output_surface_id, const scoped_refptr<FrameSwapMessageQueue>& frame_swap_message_queue, @@ -48,7 +48,7 @@ InputHandlerManagerClient* GetInputHandlerManagerClient() override; SynchronousInputHandlerProxyClient* GetSynchronousInputHandlerProxyClient() override; - scoped_ptr<cc::BeginFrameSource> CreateExternalBeginFrameSource( + std::unique_ptr<cc::BeginFrameSource> CreateExternalBeginFrameSource( int routing_id) override; SynchronousInputEventFilter* synchronous_input_event_filter() {
diff --git a/content/browser/android/in_process/synchronous_compositor_impl.cc b/content/browser/android/in_process/synchronous_compositor_impl.cc index f182989..af54f80 100644 --- a/content/browser/android/in_process/synchronous_compositor_impl.cc +++ b/content/browser/android/in_process/synchronous_compositor_impl.cc
@@ -334,7 +334,7 @@ } void SynchronousCompositorImpl::DeliverMessages() { - std::vector<scoped_ptr<IPC::Message>> messages; + std::vector<std::unique_ptr<IPC::Message>> messages; output_surface_->GetMessagesToDeliver(&messages); RenderProcessHost* rph = rwhva_->GetRenderWidgetHost()->GetProcess(); for (const auto& msg : messages) {
diff --git a/content/browser/android/in_process/synchronous_compositor_impl.h b/content/browser/android/in_process/synchronous_compositor_impl.h index 29f48d2..3d071c07 100644 --- a/content/browser/android/in_process/synchronous_compositor_impl.h +++ b/content/browser/android/in_process/synchronous_compositor_impl.h
@@ -7,11 +7,11 @@ #include <stddef.h> +#include <memory> #include <vector> #include "base/compiler_specific.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/android/synchronous_compositor_base.h" #include "content/renderer/android/synchronous_compositor_external_begin_frame_source.h" #include "content/renderer/android/synchronous_compositor_output_surface.h"
diff --git a/content/browser/android/in_process_surface_texture_manager.cc b/content/browser/android/in_process_surface_texture_manager.cc index 23dc67c2..1b46c11 100644 --- a/content/browser/android/in_process_surface_texture_manager.cc +++ b/content/browser/android/in_process_surface_texture_manager.cc
@@ -10,6 +10,7 @@ #include "base/android/jni_android.h" #include "base/containers/scoped_ptr_hash_map.h" #include "base/logging.h" +#include "base/memory/ptr_util.h" #include "content/browser/media/android/browser_media_player_manager.h" #include "content/public/browser/browser_thread.h" @@ -31,7 +32,7 @@ DCHECK(surface_textures_.find(surface_texture_id) == surface_textures_.end()); surface_textures_.add( surface_texture_id, - make_scoped_ptr(new gfx::ScopedJavaSurface(surface_texture))); + base::WrapUnique(new gfx::ScopedJavaSurface(surface_texture))); } void InProcessSurfaceTextureManager::UnregisterSurfaceTexture(
diff --git a/content/browser/android/in_process_surface_texture_manager.h b/content/browser/android/in_process_surface_texture_manager.h index 8cf4d2ee..871c06d 100644 --- a/content/browser/android/in_process_surface_texture_manager.h +++ b/content/browser/android/in_process_surface_texture_manager.h
@@ -7,9 +7,10 @@ #include "gpu/ipc/common/android/surface_texture_manager.h" +#include <memory> + #include "base/containers/scoped_ptr_hash_map.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/singleton.h" #include "base/synchronization/lock.h" #include "content/common/content_export.h" @@ -46,7 +47,7 @@ ~InProcessSurfaceTextureManager() override; using SurfaceTextureMap = - base::ScopedPtrHashMap<int, scoped_ptr<gfx::ScopedJavaSurface>>; + base::ScopedPtrHashMap<int, std::unique_ptr<gfx::ScopedJavaSurface>>; SurfaceTextureMap surface_textures_; base::Lock lock_;
diff --git a/content/browser/android/java/gin_java_bridge_dispatcher_host.cc b/content/browser/android/java/gin_java_bridge_dispatcher_host.cc index 2de4f9fe..91c6107 100644 --- a/content/browser/android/java/gin_java_bridge_dispatcher_host.cc +++ b/content/browser/android/java/gin_java_bridge_dispatcher_host.cc
@@ -6,6 +6,7 @@ #include "base/android/jni_android.h" #include "base/android/scoped_java_ref.h" +#include "base/memory/ptr_util.h" #include "build/build_config.h" #include "content/browser/android/java/gin_java_bound_object_delegate.h" #include "content/browser/android/java/gin_java_bridge_message_filter.h" @@ -334,14 +335,13 @@ } scoped_refptr<GinJavaMethodInvocationHelper> result = new GinJavaMethodInvocationHelper( - make_scoped_ptr(new GinJavaBoundObjectDelegate(object)), - method_name, + base::WrapUnique(new GinJavaBoundObjectDelegate(object)), method_name, arguments); result->Init(this); result->Invoke(); *error_code = result->GetInvocationError(); if (result->HoldsPrimitiveResult()) { - scoped_ptr<base::ListValue> result_copy( + std::unique_ptr<base::ListValue> result_copy( result->GetPrimitiveResult().DeepCopy()); wrapped_result->Swap(result_copy.get()); } else if (!result->GetObjectResult().is_null()) {
diff --git a/content/browser/android/java/gin_java_method_invocation_helper.cc b/content/browser/android/java/gin_java_method_invocation_helper.cc index 904926f..7810057 100644 --- a/content/browser/android/java/gin_java_method_invocation_helper.cc +++ b/content/browser/android/java/gin_java_method_invocation_helper.cc
@@ -30,7 +30,7 @@ } // namespace GinJavaMethodInvocationHelper::GinJavaMethodInvocationHelper( - scoped_ptr<ObjectDelegate> object, + std::unique_ptr<ObjectDelegate> object, const std::string& method_name, const base::ListValue& arguments) : object_(std::move(object)), @@ -92,7 +92,7 @@ const base::Value* raw_value) { if (!GinJavaBridgeValue::ContainsGinJavaBridgeValue(raw_value)) return false; - scoped_ptr<const GinJavaBridgeValue> value( + std::unique_ptr<const GinJavaBridgeValue> value( GinJavaBridgeValue::FromValue(raw_value)); if (!value->IsType(GinJavaBridgeValue::TYPE_OBJECT_ID)) return false;
diff --git a/content/browser/android/java/gin_java_method_invocation_helper.h b/content/browser/android/java/gin_java_method_invocation_helper.h index b61fdfd..b2c0992 100644 --- a/content/browser/android/java/gin_java_method_invocation_helper.h +++ b/content/browser/android/java/gin_java_method_invocation_helper.h
@@ -55,7 +55,7 @@ DISALLOW_COPY_AND_ASSIGN(ObjectDelegate); }; - GinJavaMethodInvocationHelper(scoped_ptr<ObjectDelegate> object, + GinJavaMethodInvocationHelper(std::unique_ptr<ObjectDelegate> object, const std::string& method_name, const base::ListValue& arguments); void Init(DispatcherDelegate* dispatcher); @@ -94,12 +94,12 @@ typedef std::map<GinJavaBoundObject::ObjectID, JavaObjectWeakGlobalRef> ObjectRefs; - scoped_ptr<ObjectDelegate> object_; + std::unique_ptr<ObjectDelegate> object_; const std::string method_name_; - scoped_ptr<base::ListValue> arguments_; + std::unique_ptr<base::ListValue> arguments_; ObjectRefs object_refs_; bool holds_primitive_result_; - scoped_ptr<base::ListValue> primitive_result_; + std::unique_ptr<base::ListValue> primitive_result_; GinJavaBridgeError invocation_error_; base::android::ScopedJavaGlobalRef<jobject> object_result_; base::android::ScopedJavaGlobalRef<jclass> safe_annotation_clazz_;
diff --git a/content/browser/android/java/gin_java_method_invocation_helper_unittest.cc b/content/browser/android/java/gin_java_method_invocation_helper_unittest.cc index 395df88f..113cee35 100644 --- a/content/browser/android/java/gin_java_method_invocation_helper_unittest.cc +++ b/content/browser/android/java/gin_java_method_invocation_helper_unittest.cc
@@ -113,10 +113,9 @@ scoped_refptr<GinJavaMethodInvocationHelper> helper = new GinJavaMethodInvocationHelper( - scoped_ptr<GinJavaMethodInvocationHelper::ObjectDelegate>( + std::unique_ptr<GinJavaMethodInvocationHelper::ObjectDelegate>( new NullObjectDelegate()), - "foo", - no_objects); + "foo", no_objects); CountingDispatcherDelegate counter; helper->Init(&counter); counter.AssertInvocationsCount(0, 0); @@ -147,10 +146,9 @@ scoped_refptr<GinJavaMethodInvocationHelper> helper = new GinJavaMethodInvocationHelper( - scoped_ptr<GinJavaMethodInvocationHelper::ObjectDelegate>( + std::unique_ptr<GinJavaMethodInvocationHelper::ObjectDelegate>( new NullObjectDelegate()), - "foo", - objects); + "foo", objects); CountingDispatcherDelegate counter; helper->Init(&counter); counter.AssertInvocationsCount(1, 6); @@ -194,7 +192,7 @@ const std::string& get_method_name() { return method_->name(); } protected: - scoped_ptr<JavaMethod> method_; + std::unique_ptr<JavaMethod> method_; bool get_local_ref_called_; private: @@ -209,10 +207,9 @@ new ObjectIsGoneObjectDelegate(); scoped_refptr<GinJavaMethodInvocationHelper> helper = new GinJavaMethodInvocationHelper( - scoped_ptr<GinJavaMethodInvocationHelper::ObjectDelegate>( + std::unique_ptr<GinJavaMethodInvocationHelper::ObjectDelegate>( object_delegate), - object_delegate->get_method_name(), - no_objects); + object_delegate->get_method_name(), no_objects); NullDispatcherDelegate dispatcher; helper->Init(&dispatcher); EXPECT_FALSE(object_delegate->get_local_ref_called()); @@ -260,10 +257,9 @@ new MethodNotFoundObjectDelegate(); scoped_refptr<GinJavaMethodInvocationHelper> helper = new GinJavaMethodInvocationHelper( - scoped_ptr<GinJavaMethodInvocationHelper::ObjectDelegate>( + std::unique_ptr<GinJavaMethodInvocationHelper::ObjectDelegate>( object_delegate), - "foo", - no_objects); + "foo", no_objects); NullDispatcherDelegate dispatcher; helper->Init(&dispatcher); EXPECT_FALSE(object_delegate->find_method_called()); @@ -317,10 +313,9 @@ new GetClassObjectDelegate(); scoped_refptr<GinJavaMethodInvocationHelper> helper = new GinJavaMethodInvocationHelper( - scoped_ptr<GinJavaMethodInvocationHelper::ObjectDelegate>( + std::unique_ptr<GinJavaMethodInvocationHelper::ObjectDelegate>( object_delegate), - "foo", - no_objects); + "foo", no_objects); NullDispatcherDelegate dispatcher; helper->Init(&dispatcher); EXPECT_FALSE(object_delegate->find_method_called());
diff --git a/content/browser/android/java/gin_java_script_to_java_types_coercion.cc b/content/browser/android/java/gin_java_script_to_java_types_coercion.cc index f65a96ae..2af118d 100644 --- a/content/browser/android/java/gin_java_script_to_java_types_coercion.cc +++ b/content/browser/android/java/gin_java_script_to_java_types_coercion.cc
@@ -392,7 +392,7 @@ bool coerce_to_string, GinJavaBridgeError* error) { bool is_undefined = false; - scoped_ptr<const GinJavaBridgeValue> gin_value; + std::unique_ptr<const GinJavaBridgeValue> gin_value; if (GinJavaBridgeValue::ContainsGinJavaBridgeValue(value)) { gin_value = GinJavaBridgeValue::FromValue(value); if (gin_value->IsType(GinJavaBridgeValue::TYPE_UNDEFINED)) { @@ -465,7 +465,7 @@ if (!result) { return NULL; } - scoped_ptr<base::Value> null_value = base::Value::CreateNullValue(); + std::unique_ptr<base::Value> null_value = base::Value::CreateNullValue(); for (jsize i = 0; i < length; ++i) { const base::Value* value_element = null_value.get(); list_value->Get(i, &value_element); @@ -537,7 +537,7 @@ if (!result) { return NULL; } - scoped_ptr<base::Value> null_value = base::Value::CreateNullValue(); + std::unique_ptr<base::Value> null_value = base::Value::CreateNullValue(); for (jsize i = 0; i < length; ++i) { const std::string key(base::IntToString(i)); const base::Value* value_element = null_value.get(); @@ -573,7 +573,7 @@ switch (target_type.type) { case JavaType::TypeObject: { if (GinJavaBridgeValue::ContainsGinJavaBridgeValue(value)) { - scoped_ptr<const GinJavaBridgeValue> gin_value( + std::unique_ptr<const GinJavaBridgeValue> gin_value( GinJavaBridgeValue::FromValue(value)); DCHECK(gin_value); DCHECK(gin_value->IsType(GinJavaBridgeValue::TYPE_OBJECT_ID)); @@ -654,7 +654,7 @@ const ObjectRefs& object_refs, GinJavaBridgeError* error) { DCHECK(GinJavaBridgeValue::ContainsGinJavaBridgeValue(value)); - scoped_ptr<const GinJavaBridgeValue> gin_value( + std::unique_ptr<const GinJavaBridgeValue> gin_value( GinJavaBridgeValue::FromValue(value)); switch (gin_value->GetType()) { case GinJavaBridgeValue::TYPE_UNDEFINED:
diff --git a/content/browser/android/java/java_type.cc b/content/browser/android/java/java_type.cc index 0ebc4f30..2322cacb 100644 --- a/content/browser/android/java/java_type.cc +++ b/content/browser/android/java/java_type.cc
@@ -12,9 +12,9 @@ // Array component type names are similar to JNI type names, except for using // dots as namespace separators in class names. -scoped_ptr<JavaType> CreateFromArrayComponentTypeName( +std::unique_ptr<JavaType> CreateFromArrayComponentTypeName( const std::string& type_name) { - scoped_ptr<JavaType> result(new JavaType()); + std::unique_ptr<JavaType> result(new JavaType()); DCHECK(!type_name.empty()); switch (type_name[0]) { case 'Z':
diff --git a/content/browser/android/java/java_type.h b/content/browser/android/java/java_type.h index ee8e01a8..e5b9db5 100644 --- a/content/browser/android/java/java_type.h +++ b/content/browser/android/java/java_type.h
@@ -5,10 +5,10 @@ #ifndef CONTENT_BROWSER_ANDROID_JAVA_JAVA_TYPE_H_ #define CONTENT_BROWSER_ANDROID_JAVA_JAVA_TYPE_H_ +#include <memory> #include <string> #include "base/android/scoped_java_ref.h" -#include "base/memory/scoped_ptr.h" #include "content/common/content_export.h" namespace content { @@ -49,7 +49,7 @@ }; Type type; - scoped_ptr<JavaType> inner_type; // Used for TypeArray only. + std::unique_ptr<JavaType> inner_type; // Used for TypeArray only. std::string class_jni_name; // Used for TypeString and TypeObject only. base::android::ScopedJavaGlobalRef<jclass> class_ref; // TypeObject only. };
diff --git a/content/browser/android/java/java_type_unittest.cc b/content/browser/android/java/java_type_unittest.cc index c55d7167..44a143b3 100644 --- a/content/browser/android/java/java_type_unittest.cc +++ b/content/browser/android/java/java_type_unittest.cc
@@ -6,8 +6,9 @@ #include <stddef.h> +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "testing/gtest/include/gtest/gtest.h" namespace content {
diff --git a/content/browser/android/overscroll_controller_android.cc b/content/browser/android/overscroll_controller_android.cc index d62f232..8feda1c 100644 --- a/content/browser/android/overscroll_controller_android.cc +++ b/content/browser/android/overscroll_controller_android.cc
@@ -6,6 +6,7 @@ #include "base/android/build_info.h" #include "base/command_line.h" +#include "base/memory/ptr_util.h" #include "cc/layers/layer.h" #include "cc/output/compositor_frame_metadata.h" #include "content/browser/android/content_view_core_impl.h" @@ -62,35 +63,35 @@ return 1.01f; } -scoped_ptr<EdgeEffectBase> CreateGlowEdgeEffect( +std::unique_ptr<EdgeEffectBase> CreateGlowEdgeEffect( ui::ResourceManager* resource_manager, float dpi_scale) { DCHECK(resource_manager); if (IsAndroidLOrNewer()) - return scoped_ptr<EdgeEffectBase>(new EdgeEffectL(resource_manager)); + return std::unique_ptr<EdgeEffectBase>(new EdgeEffectL(resource_manager)); - return scoped_ptr<EdgeEffectBase>( + return std::unique_ptr<EdgeEffectBase>( new EdgeEffect(resource_manager, dpi_scale)); } -scoped_ptr<OverscrollGlow> CreateGlowEffect(OverscrollGlowClient* client, - float dpi_scale) { +std::unique_ptr<OverscrollGlow> CreateGlowEffect(OverscrollGlowClient* client, + float dpi_scale) { if (base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kDisableOverscrollEdgeEffect)) { return nullptr; } - return make_scoped_ptr(new OverscrollGlow(client)); + return base::WrapUnique(new OverscrollGlow(client)); } -scoped_ptr<OverscrollRefresh> CreateRefreshEffect( +std::unique_ptr<OverscrollRefresh> CreateRefreshEffect( OverscrollRefreshHandler* handler) { if (base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kDisablePullToRefreshEffect)) { return nullptr; } - return make_scoped_ptr(new OverscrollRefresh(handler)); + return base::WrapUnique(new OverscrollRefresh(handler)); } } // namespace @@ -268,7 +269,8 @@ } } -scoped_ptr<EdgeEffectBase> OverscrollControllerAndroid::CreateEdgeEffect() { +std::unique_ptr<EdgeEffectBase> +OverscrollControllerAndroid::CreateEdgeEffect() { return CreateGlowEdgeEffect(&compositor_->GetResourceManager(), dpi_scale_); }
diff --git a/content/browser/android/overscroll_controller_android.h b/content/browser/android/overscroll_controller_android.h index 73c1b76..3d91cb0a 100644 --- a/content/browser/android/overscroll_controller_android.h +++ b/content/browser/android/overscroll_controller_android.h
@@ -63,7 +63,7 @@ private: // OverscrollGlowClient implementation. - scoped_ptr<ui::EdgeEffectBase> CreateEdgeEffect() override; + std::unique_ptr<ui::EdgeEffectBase> CreateEdgeEffect() override; void SetNeedsAnimate(); @@ -73,8 +73,8 @@ bool enabled_; // TODO(jdduke): Factor out a common API from the two overscroll effects. - scoped_ptr<ui::OverscrollGlow> glow_effect_; - scoped_ptr<ui::OverscrollRefresh> refresh_effect_; + std::unique_ptr<ui::OverscrollGlow> glow_effect_; + std::unique_ptr<ui::OverscrollRefresh> refresh_effect_; DISALLOW_COPY_AND_ASSIGN(OverscrollControllerAndroid); };
diff --git a/content/browser/android/popup_touch_handle_drawable.cc b/content/browser/android/popup_touch_handle_drawable.cc index 28b05253..e5cce037 100644 --- a/content/browser/android/popup_touch_handle_drawable.cc +++ b/content/browser/android/popup_touch_handle_drawable.cc
@@ -10,7 +10,7 @@ namespace content { // static -scoped_ptr<PopupTouchHandleDrawable> PopupTouchHandleDrawable::Create( +std::unique_ptr<PopupTouchHandleDrawable> PopupTouchHandleDrawable::Create( ContentViewCore* content_view_core) { DCHECK(content_view_core); base::android::ScopedJavaLocalRef<jobject> content_view_core_obj = @@ -20,7 +20,7 @@ JNIEnv* env = base::android::AttachCurrentThread(); base::android::ScopedJavaLocalRef<jobject> drawable_obj( Java_PopupTouchHandleDrawable_create(env, content_view_core_obj.obj())); - return scoped_ptr<PopupTouchHandleDrawable>(new PopupTouchHandleDrawable( + return std::unique_ptr<PopupTouchHandleDrawable>(new PopupTouchHandleDrawable( env, drawable_obj.obj(), content_view_core->GetDpiScale())); }
diff --git a/content/browser/android/popup_touch_handle_drawable.h b/content/browser/android/popup_touch_handle_drawable.h index 316de0e..1c8e656 100644 --- a/content/browser/android/popup_touch_handle_drawable.h +++ b/content/browser/android/popup_touch_handle_drawable.h
@@ -18,7 +18,7 @@ // Touch handle drawable backed by an Android PopupWindow. class PopupTouchHandleDrawable : public ui::TouchHandleDrawable { public: - static scoped_ptr<PopupTouchHandleDrawable> Create( + static std::unique_ptr<PopupTouchHandleDrawable> Create( ContentViewCore* content_view_core); ~PopupTouchHandleDrawable() override;
diff --git a/content/browser/android/synchronous_compositor_base.cc b/content/browser/android/synchronous_compositor_base.cc index 0d08509..62a7a56 100644 --- a/content/browser/android/synchronous_compositor_base.cc +++ b/content/browser/android/synchronous_compositor_base.cc
@@ -5,6 +5,7 @@ #include "content/browser/android/synchronous_compositor_base.h" #include "base/command_line.h" +#include "base/memory/ptr_util.h" #include "base/supports_user_data.h" #include "content/browser/android/in_process/synchronous_compositor_factory_impl.h" #include "content/browser/android/in_process/synchronous_compositor_impl.h" @@ -55,7 +56,7 @@ } // static -scoped_ptr<SynchronousCompositorBase> SynchronousCompositorBase::Create( +std::unique_ptr<SynchronousCompositorBase> SynchronousCompositorBase::Create( RenderWidgetHostViewAndroid* rwhva, WebContents* web_contents) { DCHECK(web_contents); @@ -70,11 +71,11 @@ !command_line->HasSwitch(switches::kSyncInputForSyncCompositor); bool use_in_proc_software_draw = command_line->HasSwitch(switches::kSingleProcess); - return make_scoped_ptr(new SynchronousCompositorHost( + return base::WrapUnique(new SynchronousCompositorHost( rwhva, web_contents_android->synchronous_compositor_client(), async_input, use_in_proc_software_draw)); } - return make_scoped_ptr(new SynchronousCompositorImpl( + return base::WrapUnique(new SynchronousCompositorImpl( rwhva, web_contents_android->synchronous_compositor_client())); }
diff --git a/content/browser/android/synchronous_compositor_base.h b/content/browser/android/synchronous_compositor_base.h index 218e821..00aae21 100644 --- a/content/browser/android/synchronous_compositor_base.h +++ b/content/browser/android/synchronous_compositor_base.h
@@ -5,7 +5,8 @@ #ifndef CONTENT_BROWSER_ANDROID_SYNCHRONOUS_COMPOSITOR_BASE_H_ #define CONTENT_BROWSER_ANDROID_SYNCHRONOUS_COMPOSITOR_BASE_H_ -#include "base/memory/scoped_ptr.h" +#include <memory> + #include "content/common/input/input_event_ack_state.h" #include "content/public/browser/android/synchronous_compositor.h" @@ -30,7 +31,7 @@ class SynchronousCompositorBase : public SynchronousCompositor { public: - static scoped_ptr<SynchronousCompositorBase> Create( + static std::unique_ptr<SynchronousCompositorBase> Create( RenderWidgetHostViewAndroid* rwhva, WebContents* web_contents);
diff --git a/content/browser/android/synchronous_compositor_host.cc b/content/browser/android/synchronous_compositor_host.cc index 7f6cdfc5..f92b294 100644 --- a/content/browser/android/synchronous_compositor_host.cc +++ b/content/browser/android/synchronous_compositor_host.cc
@@ -135,7 +135,7 @@ PopulateCommonParams(&common_browser_params); SyncCompositorCommonRendererParams common_renderer_params; bool success = false; - scoped_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame); + std::unique_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame); ScopedSetSkCanvas set_sk_canvas(canvas); SyncCompositorDemandDrawSwParams params; // Unused. if (!sender_->Send(new SyncCompositorMsg_DemandDrawSw( @@ -199,7 +199,7 @@ if (!software_draw_shm_) return false; - scoped_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame); + std::unique_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame); SyncCompositorCommonBrowserParams common_browser_params; PopulateCommonParams(&common_browser_params); SyncCompositorCommonRendererParams common_renderer_params; @@ -238,7 +238,7 @@ software_draw_shm_->buffer_size == buffer_size) return; software_draw_shm_.reset(); - scoped_ptr<SharedMemoryWithSize> software_draw_shm( + std::unique_ptr<SharedMemoryWithSize> software_draw_shm( new SharedMemoryWithSize(stride, buffer_size)); { TRACE_EVENT1("browser", "AllocateSharedMemory", "buffer_size", buffer_size);
diff --git a/content/browser/android/synchronous_compositor_host.h b/content/browser/android/synchronous_compositor_host.h index b9b15986..90673482 100644 --- a/content/browser/android/synchronous_compositor_host.h +++ b/content/browser/android/synchronous_compositor_host.h
@@ -92,7 +92,7 @@ size_t bytes_limit_; uint32_t output_surface_id_from_last_draw_; cc::ReturnedResourceArray returned_resources_; - scoped_ptr<SharedMemoryWithSize> software_draw_shm_; + std::unique_ptr<SharedMemoryWithSize> software_draw_shm_; // Updated by both renderer and browser. gfx::ScrollOffset root_scroll_offset_;
diff --git a/content/browser/android/url_request_content_job.h b/content/browser/android/url_request_content_job.h index 9858eba3..2f70b5db 100644 --- a/content/browser/android/url_request_content_job.h +++ b/content/browser/android/url_request_content_job.h
@@ -88,7 +88,7 @@ // The full path of the content URI. base::FilePath content_path_; - scoped_ptr<net::FileStream> stream_; + std::unique_ptr<net::FileStream> stream_; ContentMetaInfo meta_info_; const scoped_refptr<base::TaskRunner> content_task_runner_;
diff --git a/content/browser/android/url_request_content_job_unittest.cc b/content/browser/android/url_request_content_job_unittest.cc index 124b24a..c87f7e15 100644 --- a/content/browser/android/url_request_content_job_unittest.cc +++ b/content/browser/android/url_request_content_job_unittest.cc
@@ -7,9 +7,9 @@ #include <stdint.h> #include <algorithm> +#include <memory> #include "base/files/file_util.h" -#include "base/memory/scoped_ptr.h" #include "base/run_loop.h" #include "base/strings/stringprintf.h" #include "base/test/test_file_util.h" @@ -149,7 +149,7 @@ CallbacksJobFactory factory(path, &observer_); context_.set_job_factory(&factory); - scoped_ptr<net::URLRequest> request(context_.CreateRequest( + std::unique_ptr<net::URLRequest> request(context_.CreateRequest( GURL(path.value()), net::DEFAULT_PRIORITY, &delegate_)); int expected_length = file_size; if (range) {
diff --git a/content/browser/appcache/appcache.cc b/content/browser/appcache/appcache.cc index f97d9cce..98c9e59 100644 --- a/content/browser/appcache/appcache.cc +++ b/content/browser/appcache/appcache.cc
@@ -109,9 +109,9 @@ return NULL; DCHECK(storage_->service()->handler_factory()); - scoped_ptr<AppCacheExecutableHandler> own_ptr = - storage_->service()->handler_factory()-> - CreateHandler(handler_url, handler_source); + std::unique_ptr<AppCacheExecutableHandler> own_ptr = + storage_->service()->handler_factory()->CreateHandler(handler_url, + handler_source); handler = own_ptr.release(); if (!handler) return NULL;
diff --git a/content/browser/appcache/appcache_backend_impl.cc b/content/browser/appcache/appcache_backend_impl.cc index c3bb533f..0ac9bc69 100644 --- a/content/browser/appcache/appcache_backend_impl.cc +++ b/content/browser/appcache/appcache_backend_impl.cc
@@ -143,11 +143,12 @@ host->GetResourceList(resource_infos); } -scoped_ptr<AppCacheHost> AppCacheBackendImpl::TransferHostOut(int host_id) { +std::unique_ptr<AppCacheHost> AppCacheBackendImpl::TransferHostOut( + int host_id) { HostMap::iterator found = hosts_.find(host_id); if (found == hosts_.end()) { NOTREACHED(); - return scoped_ptr<AppCacheHost>(); + return std::unique_ptr<AppCacheHost>(); } AppCacheHost* transferree = found->second; @@ -157,11 +158,11 @@ // We give up ownership. transferree->PrepareForTransfer(); - return scoped_ptr<AppCacheHost>(transferree); + return std::unique_ptr<AppCacheHost>(transferree); } -void AppCacheBackendImpl::TransferHostIn( - int new_host_id, scoped_ptr<AppCacheHost> host) { +void AppCacheBackendImpl::TransferHostIn(int new_host_id, + std::unique_ptr<AppCacheHost> host) { HostMap::iterator found = hosts_.find(new_host_id); if (found == hosts_.end()) { NOTREACHED();
diff --git a/content/browser/appcache/appcache_backend_impl.h b/content/browser/appcache/appcache_backend_impl.h index b0136b4..4585b78 100644 --- a/content/browser/appcache/appcache_backend_impl.h +++ b/content/browser/appcache/appcache_backend_impl.h
@@ -63,8 +63,8 @@ // Methods to support cross site navigations. Hosts are transferred // from process to process accordingly, deparented from the old // processes backend and reparented to the new. - scoped_ptr<AppCacheHost> TransferHostOut(int host_id); - void TransferHostIn(int new_host_id, scoped_ptr<AppCacheHost> host); + std::unique_ptr<AppCacheHost> TransferHostOut(int host_id); + void TransferHostIn(int new_host_id, std::unique_ptr<AppCacheHost> host); private: AppCacheServiceImpl* service_;
diff --git a/content/browser/appcache/appcache_database.h b/content/browser/appcache/appcache_database.h index e2b265d..47ef0b144 100644 --- a/content/browser/appcache/appcache_database.h +++ b/content/browser/appcache/appcache_database.h
@@ -8,13 +8,13 @@ #include <stdint.h> #include <map> +#include <memory> #include <set> #include <vector> #include "base/files/file_path.h" #include "base/gtest_prod_util.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/time/time.h" #include "content/common/appcache_interfaces.h" #include "content/common/content_export.h" @@ -234,8 +234,8 @@ void OnDatabaseError(int err, sql::Statement* stmt); base::FilePath db_file_path_; - scoped_ptr<sql::Connection> db_; - scoped_ptr<sql::MetaTable> meta_table_; + std::unique_ptr<sql::Connection> db_; + std::unique_ptr<sql::MetaTable> meta_table_; std::map<int64_t, base::Time> lazy_last_access_times_; bool is_disabled_; bool is_recreating_;
diff --git a/content/browser/appcache/appcache_disk_cache.cc b/content/browser/appcache/appcache_disk_cache.cc index da5475d..f5c718c7 100644 --- a/content/browser/appcache/appcache_disk_cache.cc +++ b/content/browser/appcache/appcache_disk_cache.cc
@@ -39,7 +39,7 @@ appcache_diskcache_->OnCreateBackendComplete(rv); } - scoped_ptr<disk_cache::Backend> backend_ptr_; // Accessed directly. + std::unique_ptr<disk_cache::Backend> backend_ptr_; // Accessed directly. private: friend class base::RefCounted<CreateBackendCallbackShim>;
diff --git a/content/browser/appcache/appcache_disk_cache.h b/content/browser/appcache/appcache_disk_cache.h index d06bcf5..b5d67eb 100644 --- a/content/browser/appcache/appcache_disk_cache.h +++ b/content/browser/appcache/appcache_disk_cache.h
@@ -7,11 +7,11 @@ #include <stdint.h> +#include <memory> #include <set> #include <vector> #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/appcache/appcache_response.h" #include "content/common/content_export.h" #include "net/disk_cache/disk_cache.h" @@ -120,7 +120,7 @@ scoped_refptr<CreateBackendCallbackShim> create_backend_callback_; PendingCalls pending_calls_; OpenEntries open_entries_; - scoped_ptr<disk_cache::Backend> disk_cache_; + std::unique_ptr<disk_cache::Backend> disk_cache_; base::WeakPtrFactory<AppCacheDiskCache> weak_factory_; };
diff --git a/content/browser/appcache/appcache_disk_cache_unittest.cc b/content/browser/appcache/appcache_disk_cache_unittest.cc index b9c67cf9a..a1a9841a 100644 --- a/content/browser/appcache/appcache_disk_cache_unittest.cc +++ b/content/browser/appcache/appcache_disk_cache_unittest.cc
@@ -43,7 +43,7 @@ } base::ScopedTempDir directory_; - scoped_ptr<base::MessageLoop> message_loop_; + std::unique_ptr<base::MessageLoop> message_loop_; scoped_refptr<base::SingleThreadTaskRunner> cache_thread_; net::CompletionCallback completion_callback_; std::vector<int> completion_results_; @@ -56,7 +56,7 @@ // Create an instance and start it initializing, queue up // one of each kind of "entry" function. - scoped_ptr<AppCacheDiskCache> disk_cache(new AppCacheDiskCache); + std::unique_ptr<AppCacheDiskCache> disk_cache(new AppCacheDiskCache); EXPECT_FALSE(disk_cache->is_disabled()); disk_cache->InitWithDiskBackend( directory_.path(), k10MBytes, false, cache_thread_, completion_callback_); @@ -87,7 +87,7 @@ TEST_F(AppCacheDiskCacheTest, DisableAfterInitted) { // Create an instance and let it fully init. - scoped_ptr<AppCacheDiskCache> disk_cache(new AppCacheDiskCache); + std::unique_ptr<AppCacheDiskCache> disk_cache(new AppCacheDiskCache); EXPECT_FALSE(disk_cache->is_disabled()); disk_cache->InitWithDiskBackend( directory_.path(), k10MBytes, false, cache_thread_, completion_callback_); @@ -122,7 +122,7 @@ // Flaky on Android: http://crbug.com/339534 TEST_F(AppCacheDiskCacheTest, DISABLED_DisableWithEntriesOpen) { // Create an instance and let it fully init. - scoped_ptr<AppCacheDiskCache> disk_cache(new AppCacheDiskCache); + std::unique_ptr<AppCacheDiskCache> disk_cache(new AppCacheDiskCache); EXPECT_FALSE(disk_cache->is_disabled()); disk_cache->InitWithDiskBackend( directory_.path(), k10MBytes, false, cache_thread_, completion_callback_);
diff --git a/content/browser/appcache/appcache_dispatcher_host.h b/content/browser/appcache/appcache_dispatcher_host.h index 4181b439..9b882c8 100644 --- a/content/browser/appcache/appcache_dispatcher_host.h +++ b/content/browser/appcache/appcache_dispatcher_host.h
@@ -7,11 +7,11 @@ #include <stdint.h> +#include <memory> #include <vector> #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/process/process.h" #include "content/browser/appcache/appcache_backend_impl.h" @@ -70,7 +70,7 @@ content::GetStatusCallback get_status_callback_; content::StartUpdateCallback start_update_callback_; content::SwapCacheCallback swap_cache_callback_; - scoped_ptr<IPC::Message> pending_reply_msg_; + std::unique_ptr<IPC::Message> pending_reply_msg_; // The corresponding ChildProcessHost object's id(). int process_id_;
diff --git a/content/browser/appcache/appcache_executable_handler.h b/content/browser/appcache/appcache_executable_handler.h index 445a6cd..a19201f2 100644 --- a/content/browser/appcache/appcache_executable_handler.h +++ b/content/browser/appcache/appcache_executable_handler.h
@@ -5,8 +5,9 @@ #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_EXECUTABLE_HANDLER_H_ #define CONTENT_BROWSER_APPCACHE_APPCACHE_EXECUTABLE_HANDLER_H_ +#include <memory> + #include "base/callback.h" -#include "base/memory/scoped_ptr.h" #include "content/common/content_export.h" #include "url/gurl.h" @@ -42,8 +43,9 @@ // A factory to produce instances. class CONTENT_EXPORT AppCacheExecutableHandlerFactory { public: - virtual scoped_ptr<AppCacheExecutableHandler> CreateHandler( - const GURL& handler_url, net::IOBuffer* handler_source) = 0; + virtual std::unique_ptr<AppCacheExecutableHandler> CreateHandler( + const GURL& handler_url, + net::IOBuffer* handler_source) = 0; protected: virtual ~AppCacheExecutableHandlerFactory() {}
diff --git a/content/browser/appcache/appcache_group.h b/content/browser/appcache/appcache_group.h index 626deb7b..c9ee22ee 100644 --- a/content/browser/appcache/appcache_group.h +++ b/content/browser/appcache/appcache_group.h
@@ -8,6 +8,7 @@ #include <stdint.h> #include <map> +#include <memory> #include <utility> #include <vector> @@ -15,7 +16,6 @@ #include "base/gtest_prod_util.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/observer_list.h" #include "base/time/time.h" #include "content/common/content_export.h" @@ -181,7 +181,7 @@ QueuedUpdates queued_updates_; base::ObserverList<UpdateObserver> queued_observers_; base::CancelableClosure restart_update_task_; - scoped_ptr<HostObserver> host_observer_; + std::unique_ptr<HostObserver> host_observer_; // True if we're in our destructor. bool is_in_dtor_;
diff --git a/content/browser/appcache/appcache_host_unittest.cc b/content/browser/appcache/appcache_host_unittest.cc index ee935c1b..1e19f24 100644 --- a/content/browser/appcache/appcache_host_unittest.cc +++ b/content/browser/appcache/appcache_host_unittest.cc
@@ -2,16 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/browser/appcache/appcache_host.h" + #include <stdint.h> +#include <memory> + #include "base/bind.h" #include "base/bind_helpers.h" -#include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" #include "content/browser/appcache/appcache.h" #include "content/browser/appcache/appcache_backend_impl.h" #include "content/browser/appcache/appcache_group.h" -#include "content/browser/appcache/appcache_host.h" #include "content/browser/appcache/mock_appcache_policy.h" #include "content/browser/appcache/mock_appcache_service.h" #include "net/url_request/url_request.h"
diff --git a/content/browser/appcache/appcache_internals_ui.cc b/content/browser/appcache/appcache_internals_ui.cc index 0c40212..1a36ddbc 100644 --- a/content/browser/appcache/appcache_internals_ui.cc +++ b/content/browser/appcache/appcache_internals_ui.cc
@@ -55,10 +55,11 @@ return lhs.url.spec() < rhs.url.spec(); } -scoped_ptr<base::DictionaryValue> GetDictionaryValueForResponseEnquiry( +std::unique_ptr<base::DictionaryValue> GetDictionaryValueForResponseEnquiry( const content::AppCacheInternalsUI::Proxy::ResponseEnquiry& response_enquiry) { - scoped_ptr<base::DictionaryValue> dict_value(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> dict_value( + new base::DictionaryValue()); dict_value->SetString("manifestURL", response_enquiry.manifest_url); dict_value->SetString("groupId", base::Int64ToString(response_enquiry.group_id)); @@ -67,9 +68,10 @@ return dict_value; } -scoped_ptr<base::DictionaryValue> GetDictionaryValueForAppCacheInfo( +std::unique_ptr<base::DictionaryValue> GetDictionaryValueForAppCacheInfo( const content::AppCacheInfo& appcache_info) { - scoped_ptr<base::DictionaryValue> dict_value(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> dict_value( + new base::DictionaryValue()); dict_value->SetString("manifestURL", appcache_info.manifest_url.spec()); dict_value->SetDouble("creationTime", appcache_info.creation_time.ToJsTime()); dict_value->SetDouble("lastUpdateTime", @@ -84,29 +86,30 @@ return dict_value; } -scoped_ptr<base::ListValue> GetListValueForAppCacheInfoVector( +std::unique_ptr<base::ListValue> GetListValueForAppCacheInfoVector( const AppCacheInfoVector& appcache_info_vector) { - scoped_ptr<base::ListValue> list(new base::ListValue()); + std::unique_ptr<base::ListValue> list(new base::ListValue()); for (const AppCacheInfo& info : appcache_info_vector) list->Append(GetDictionaryValueForAppCacheInfo(info)); return list; } -scoped_ptr<base::ListValue> GetListValueFromAppCacheInfoCollection( +std::unique_ptr<base::ListValue> GetListValueFromAppCacheInfoCollection( AppCacheInfoCollection* appcache_collection) { - scoped_ptr<base::ListValue> list(new base::ListValue()); + std::unique_ptr<base::ListValue> list(new base::ListValue()); for (const auto& key_value : appcache_collection->infos_by_origin) { base::DictionaryValue* dict = new base::DictionaryValue; dict->SetString("originURL", key_value.first.spec()); dict->Set("manifests", GetListValueForAppCacheInfoVector(key_value.second)); - list->Append(scoped_ptr<base::Value>(dict)); + list->Append(std::unique_ptr<base::Value>(dict)); } return list; } -scoped_ptr<base::DictionaryValue> GetDictionaryValueForAppCacheResourceInfo( +std::unique_ptr<base::DictionaryValue> +GetDictionaryValueForAppCacheResourceInfo( const AppCacheResourceInfo& resource_info) { - scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); + std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue); dict->SetString("url", resource_info.url.spec()); dict->SetString( "size", @@ -122,9 +125,9 @@ return dict; } -scoped_ptr<base::ListValue> GetListValueForAppCacheResourceInfoVector( +std::unique_ptr<base::ListValue> GetListValueForAppCacheResourceInfoVector( AppCacheResourceInfoVector* resource_info_vector) { - scoped_ptr<base::ListValue> list(new base::ListValue); + std::unique_ptr<base::ListValue> list(new base::ListValue); for (const AppCacheResourceInfo& res_info : *resource_info_vector) list->Append(GetDictionaryValueForAppCacheResourceInfo(res_info)); return list; @@ -233,7 +236,7 @@ void AppCacheInternalsUI::Proxy::OnGroupLoaded(AppCacheGroup* appcache_group, const GURL& manifest_gurl) { - scoped_ptr<AppCacheResourceInfoVector> resource_info_vector; + std::unique_ptr<AppCacheResourceInfoVector> resource_info_vector; if (appcache_group && appcache_group->newest_complete_cache()) { resource_info_vector.reset(new AppCacheResourceInfoVector); appcache_group->newest_complete_cache()->ToResourceInfoVector( @@ -287,7 +290,7 @@ std::min(kLimit, response_info->response_data_size()); scoped_refptr<net::IOBuffer> response_data(new net::IOBuffer( base::CheckedNumeric<size_t>(amount_to_read).ValueOrDie())); - scoped_ptr<AppCacheResponseReader> reader( + std::unique_ptr<AppCacheResponseReader> reader( appcache_service_->storage()->CreateResponseReader( GURL(response_enquiry.manifest_url), response_enquiry.group_id, response_enquiry.response_id)); @@ -304,7 +307,7 @@ void AppCacheInternalsUI::Proxy::OnResponseDataReadComplete( const ResponseEnquiry& response_enquiry, scoped_refptr<AppCacheResponseInfo> response_info, - scoped_ptr<AppCacheResponseReader> reader, + std::unique_ptr<AppCacheResponseReader> reader, scoped_refptr<net::IOBuffer> response_data, int net_result_code) { if (shutdown_called_) @@ -437,7 +440,7 @@ void AppCacheInternalsUI::OnAppCacheDetailsReady( const base::FilePath& partition_path, const std::string& manifest_url, - scoped_ptr<AppCacheResourceInfoVector> resource_info_vector) { + std::unique_ptr<AppCacheResourceInfoVector> resource_info_vector) { if (resource_info_vector) { web_ui()->CallJavascriptFunction( kFunctionOnAppCacheDetailsReady, base::StringValue(manifest_url),
diff --git a/content/browser/appcache/appcache_internals_ui.h b/content/browser/appcache/appcache_internals_ui.h index f5498dbc..f027287f 100644 --- a/content/browser/appcache/appcache_internals_ui.h +++ b/content/browser/appcache/appcache_internals_ui.h
@@ -8,10 +8,10 @@ #include <stdint.h> #include <list> +#include <memory> #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/appcache/appcache_group.h" #include "content/browser/appcache/appcache_storage.h" #include "content/browser/appcache/chrome_appcache_service.h" @@ -71,7 +71,7 @@ void OnResponseDataReadComplete( const ResponseEnquiry& response_enquiry, scoped_refptr<AppCacheResponseInfo> response_info, - scoped_ptr<AppCacheResponseReader> reader, + std::unique_ptr<AppCacheResponseReader> reader, scoped_refptr<net::IOBuffer> response_data, int net_result_code); void Initialize( @@ -109,7 +109,7 @@ void OnAppCacheDetailsReady( const base::FilePath& partition_path, const std::string& manifest_url, - scoped_ptr<AppCacheResourceInfoVector> resource_info_vector); + std::unique_ptr<AppCacheResourceInfoVector> resource_info_vector); void OnFileDetailsReady(const Proxy::ResponseEnquiry& response_enquiry, scoped_refptr<AppCacheResponseInfo> response_info, scoped_refptr<net::IOBuffer> response_data,
diff --git a/content/browser/appcache/appcache_quota_client.h b/content/browser/appcache/appcache_quota_client.h index d552831..73f2559 100644 --- a/content/browser/appcache/appcache_quota_client.h +++ b/content/browser/appcache/appcache_quota_client.h
@@ -7,11 +7,11 @@ #include <deque> #include <map> +#include <memory> #include <string> #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/appcache/appcache_storage.h" #include "content/common/content_export.h" #include "net/base/completion_callback.h" @@ -80,7 +80,7 @@ // And once it's ready, we can only handle one delete request at a time, // so we queue up additional requests while one is in already in progress. DeletionCallback current_delete_request_callback_; - scoped_ptr<net::CancelableCompletionCallback> service_delete_callback_; + std::unique_ptr<net::CancelableCompletionCallback> service_delete_callback_; AppCacheServiceImpl* service_; bool appcache_is_ready_;
diff --git a/content/browser/appcache/appcache_request_handler.cc b/content/browser/appcache/appcache_request_handler.cc index 0a00878..1ea6347 100644 --- a/content/browser/appcache/appcache_request_handler.cc +++ b/content/browser/appcache/appcache_request_handler.cc
@@ -78,7 +78,7 @@ found_manifest_url_ = GURL(); found_network_namespace_ = false; - scoped_ptr<AppCacheURLRequestJob> job; + std::unique_ptr<AppCacheURLRequestJob> job; if (is_main_resource()) job = MaybeLoadMainResource(request, network_delegate); else @@ -113,7 +113,7 @@ DCHECK(!job_.get()); // our jobs never generate redirects - scoped_ptr<AppCacheURLRequestJob> job; + std::unique_ptr<AppCacheURLRequestJob> job; if (found_fallback_entry_.has_response_id()) { // 6.9.6, step 4: If this results in a redirect to another origin, // get the resource of the fallback entry. @@ -170,7 +170,8 @@ // 6.9.6, step 4: If this results in a 4xx or 5xx status code // or there were network errors, get the resource of the fallback entry. - scoped_ptr<AppCacheURLRequestJob> job = CreateJob(request, network_delegate); + std::unique_ptr<AppCacheURLRequestJob> job = + CreateJob(request, network_delegate); DeliverAppCachedResponse( found_fallback_entry_, found_cache_id_, found_group_id_, found_manifest_url_, true, found_namespace_entry_url_); @@ -277,10 +278,10 @@ job_.reset(); } -scoped_ptr<AppCacheURLRequestJob> AppCacheRequestHandler::CreateJob( +std::unique_ptr<AppCacheURLRequestJob> AppCacheRequestHandler::CreateJob( net::URLRequest* request, net::NetworkDelegate* network_delegate) { - scoped_ptr<AppCacheURLRequestJob> job(new AppCacheURLRequestJob( + std::unique_ptr<AppCacheURLRequestJob> job(new AppCacheURLRequestJob( request, network_delegate, storage(), host_, is_main_resource(), base::Bind(&AppCacheRequestHandler::OnPrepareToRestart, base::Unretained(this)))); @@ -290,7 +291,8 @@ // Main-resource handling ---------------------------------------------- -scoped_ptr<AppCacheURLRequestJob> AppCacheRequestHandler::MaybeLoadMainResource( +std::unique_ptr<AppCacheURLRequestJob> +AppCacheRequestHandler::MaybeLoadMainResource( net::URLRequest* request, net::NetworkDelegate* network_delegate) { DCHECK(!job_.get()); @@ -314,7 +316,8 @@ // We may have to wait for our storage query to complete, but // this query can also complete syncrhonously. - scoped_ptr<AppCacheURLRequestJob> job = CreateJob(request, network_delegate); + std::unique_ptr<AppCacheURLRequestJob> job = + CreateJob(request, network_delegate); storage()->FindResponseForMainRequest( request->url(), preferred_manifest_url, this); return job; @@ -392,7 +395,8 @@ // Sub-resource handling ---------------------------------------------- -scoped_ptr<AppCacheURLRequestJob> AppCacheRequestHandler::MaybeLoadSubResource( +std::unique_ptr<AppCacheURLRequestJob> +AppCacheRequestHandler::MaybeLoadSubResource( net::URLRequest* request, net::NetworkDelegate* network_delegate) { DCHECK(!job_.get()); @@ -410,7 +414,8 @@ return nullptr; } - scoped_ptr<AppCacheURLRequestJob> job = CreateJob(request, network_delegate); + std::unique_ptr<AppCacheURLRequestJob> job = + CreateJob(request, network_delegate); ContinueMaybeLoadSubResource(); return job; }
diff --git a/content/browser/appcache/appcache_request_handler.h b/content/browser/appcache/appcache_request_handler.h index 7665d10e..42d58fc 100644 --- a/content/browser/appcache/appcache_request_handler.h +++ b/content/browser/appcache/appcache_request_handler.h
@@ -7,9 +7,10 @@ #include <stdint.h> +#include <memory> + #include "base/compiler_specific.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/supports_user_data.h" #include "content/browser/appcache/appcache_entry.h" @@ -97,7 +98,7 @@ // Helper method to create an AppCacheURLRequestJob and populate job_. // Caller takes ownership of returned value. - scoped_ptr<AppCacheURLRequestJob> CreateJob( + std::unique_ptr<AppCacheURLRequestJob> CreateJob( net::URLRequest* request, net::NetworkDelegate* network_delegate); @@ -111,7 +112,7 @@ // Main-resource loading ------------------------------------- // Frame and SharedWorker main resources are handled here. - scoped_ptr<AppCacheURLRequestJob> MaybeLoadMainResource( + std::unique_ptr<AppCacheURLRequestJob> MaybeLoadMainResource( net::URLRequest* request, net::NetworkDelegate* network_delegate); @@ -127,7 +128,7 @@ // Sub-resource loading ------------------------------------- // Dedicated worker and all manner of sub-resources are handled here. - scoped_ptr<AppCacheURLRequestJob> MaybeLoadSubResource( + std::unique_ptr<AppCacheURLRequestJob> MaybeLoadSubResource( net::URLRequest* request, net::NetworkDelegate* network_delegate); void ContinueMaybeLoadSubResource(); @@ -181,7 +182,7 @@ // During a cross site navigation, we transfer ownership the AppcacheHost // from the old processes structures over to the new structures. - scoped_ptr<AppCacheHost> host_for_cross_site_transfer_; + std::unique_ptr<AppCacheHost> host_for_cross_site_transfer_; int old_process_id_; int old_host_id_;
diff --git a/content/browser/appcache/appcache_request_handler_unittest.cc b/content/browser/appcache/appcache_request_handler_unittest.cc index 46ce987..684c62e 100644 --- a/content/browser/appcache/appcache_request_handler_unittest.cc +++ b/content/browser/appcache/appcache_request_handler_unittest.cc
@@ -5,6 +5,7 @@ #include "content/browser/appcache/appcache_request_handler.h" #include <stdint.h> + #include <stack> #include <string> #include <utility> @@ -15,6 +16,7 @@ #include "base/callback.h" #include "base/location.h" #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/memory/weak_ptr.h" #include "base/single_thread_task_runner.h" #include "base/synchronization/waitable_event.h" @@ -120,7 +122,9 @@ ~MockURLRequestJobFactory() override { DCHECK(!job_); } - void SetJob(scoped_ptr<net::URLRequestJob> job) { job_ = std::move(job); } + void SetJob(std::unique_ptr<net::URLRequestJob> job) { + job_ = std::move(job); + } net::URLRequestJob* MaybeCreateJobWithProtocolHandler( const std::string& scheme, @@ -161,7 +165,7 @@ } private: - mutable scoped_ptr<net::URLRequestJob> job_; + mutable std::unique_ptr<net::URLRequestJob> job_; }; static void SetUpTestCase() { @@ -280,7 +284,7 @@ EXPECT_EQ(GURL(), manifest_url); EXPECT_EQ(0, handler_->found_group_id_); - scoped_ptr<AppCacheURLRequestJob> fallback_job( + std::unique_ptr<AppCacheURLRequestJob> fallback_job( handler_->MaybeLoadFallbackForRedirect( request_.get(), request_->context()->network_delegate(), GURL("http://blah/redirect"))); @@ -333,7 +337,7 @@ EXPECT_EQ(GURL("http://blah/manifest/"), manifest_url); EXPECT_EQ(2, handler_->found_group_id_); - scoped_ptr<AppCacheURLRequestJob> fallback_job( + std::unique_ptr<AppCacheURLRequestJob> fallback_job( handler_->MaybeLoadFallbackForResponse( request_.get(), request_->context()->network_delegate())); EXPECT_FALSE(fallback_job); @@ -374,7 +378,7 @@ } void SimulateResponseCode(int response_code) { - job_factory_->SetJob(make_scoped_ptr(new MockURLRequestJob( + job_factory_->SetJob(base::WrapUnique(new MockURLRequestJob( request_.get(), request_->context()->network_delegate(), response_code))); request_->Start(); @@ -384,7 +388,7 @@ } void SimulateResponseInfo(const net::HttpResponseInfo& info) { - job_factory_->SetJob(make_scoped_ptr(new MockURLRequestJob( + job_factory_->SetJob(base::WrapUnique(new MockURLRequestJob( request_.get(), request_->context()->network_delegate(), info))); request_->Start(); } @@ -531,7 +535,7 @@ EXPECT_TRUE(job_.get()); EXPECT_TRUE(job_->is_delivering_error_response()); - scoped_ptr<AppCacheURLRequestJob> fallback_job( + std::unique_ptr<AppCacheURLRequestJob> fallback_job( handler_->MaybeLoadFallbackForRedirect( request_.get(), request_->context()->network_delegate(), GURL("http://blah/redirect"))); @@ -566,7 +570,7 @@ EXPECT_FALSE(job_->is_waiting()); EXPECT_TRUE(job_->is_delivering_error_response()); - scoped_ptr<AppCacheURLRequestJob> fallback_job( + std::unique_ptr<AppCacheURLRequestJob> fallback_job( handler_->MaybeLoadFallbackForRedirect( request_.get(), request_->context()->network_delegate(), GURL("http://blah/redirect"))); @@ -597,7 +601,7 @@ EXPECT_TRUE(job_.get()); EXPECT_TRUE(job_->is_delivering_appcache_response()); - scoped_ptr<AppCacheURLRequestJob> fallback_job( + std::unique_ptr<AppCacheURLRequestJob> fallback_job( handler_->MaybeLoadFallbackForRedirect( request_.get(), request_->context()->network_delegate(), GURL("http://blah/redirect"))); @@ -635,7 +639,7 @@ EXPECT_TRUE(job_.get()); EXPECT_TRUE(job_->is_delivering_appcache_response()); - scoped_ptr<AppCacheURLRequestJob> fallback_job( + std::unique_ptr<AppCacheURLRequestJob> fallback_job( handler_->MaybeLoadFallbackForResponse( request_.get(), request_->context()->network_delegate())); EXPECT_FALSE(fallback_job); @@ -663,7 +667,7 @@ request_.get(), request_->context()->network_delegate())); EXPECT_FALSE(job_.get()); - scoped_ptr<AppCacheURLRequestJob> fallback_job( + std::unique_ptr<AppCacheURLRequestJob> fallback_job( handler_->MaybeLoadFallbackForRedirect( request_.get(), request_->context()->network_delegate(), GURL("http://blah/redirect"))); @@ -698,7 +702,7 @@ request_.get(), request_->context()->network_delegate())); EXPECT_FALSE(job_.get()); - scoped_ptr<AppCacheURLRequestJob> fallback_job( + std::unique_ptr<AppCacheURLRequestJob> fallback_job( handler_->MaybeLoadFallbackForRedirect( request_.get(), request_->context()->network_delegate(), GURL("http://blah/redirect"))); @@ -936,25 +940,25 @@ // Data members -------------------------------------------------- - scoped_ptr<base::WaitableEvent> test_finished_event_; + std::unique_ptr<base::WaitableEvent> test_finished_event_; std::stack<base::Closure> task_stack_; - scoped_ptr<MockAppCacheService> mock_service_; - scoped_ptr<AppCacheBackendImpl> backend_impl_; - scoped_ptr<MockFrontend> mock_frontend_; - scoped_ptr<MockAppCachePolicy> mock_policy_; + std::unique_ptr<MockAppCacheService> mock_service_; + std::unique_ptr<AppCacheBackendImpl> backend_impl_; + std::unique_ptr<MockFrontend> mock_frontend_; + std::unique_ptr<MockAppCachePolicy> mock_policy_; AppCacheHost* host_; net::URLRequestContext empty_context_; - scoped_ptr<MockURLRequestJobFactory> job_factory_; + std::unique_ptr<MockURLRequestJobFactory> job_factory_; MockURLRequestDelegate delegate_; - scoped_ptr<net::URLRequest> request_; - scoped_ptr<AppCacheRequestHandler> handler_; - scoped_ptr<AppCacheURLRequestJob> job_; + std::unique_ptr<net::URLRequest> request_; + std::unique_ptr<AppCacheRequestHandler> handler_; + std::unique_ptr<AppCacheURLRequestJob> job_; - static scoped_ptr<base::Thread> io_thread_; + static std::unique_ptr<base::Thread> io_thread_; }; // static -scoped_ptr<base::Thread> AppCacheRequestHandlerTest::io_thread_; +std::unique_ptr<base::Thread> AppCacheRequestHandlerTest::io_thread_; TEST_F(AppCacheRequestHandlerTest, MainResource_Miss) { RunTestOnIOThread(&AppCacheRequestHandlerTest::MainResource_Miss);
diff --git a/content/browser/appcache/appcache_response.cc b/content/browser/appcache/appcache_response.cc index b5df22d..d4b0b96 100644 --- a/content/browser/appcache/appcache_response.cc +++ b/content/browser/appcache/appcache_response.cc
@@ -41,7 +41,7 @@ private: ~WrappedPickleIOBuffer() override {} - scoped_ptr<const base::Pickle> pickle_; + std::unique_ptr<const base::Pickle> pickle_; }; } // anon namespace @@ -268,7 +268,7 @@ } else if (info_buffer_.get()) { // Deserialize the http info structure, ensuring we got headers. base::Pickle pickle(buffer_->data(), result); - scoped_ptr<net::HttpResponseInfo> info(new net::HttpResponseInfo); + std::unique_ptr<net::HttpResponseInfo> info(new net::HttpResponseInfo); bool response_truncated = false; if (!info->InitFromPickle(pickle, &response_truncated) || !info->headers.get()) {
diff --git a/content/browser/appcache/appcache_response.h b/content/browser/appcache/appcache_response.h index 0b709b9..ffb6441 100644 --- a/content/browser/appcache/appcache_response.h +++ b/content/browser/appcache/appcache_response.h
@@ -7,9 +7,10 @@ #include <stdint.h> +#include <memory> + #include "base/compiler_specific.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "content/common/appcache_interfaces.h" #include "content/common/content_export.h" @@ -52,7 +53,7 @@ const GURL manifest_url_; const int64_t response_id_; - const scoped_ptr<net::HttpResponseInfo> http_response_info_; + const std::unique_ptr<net::HttpResponseInfo> http_response_info_; const int64_t response_data_size_; AppCacheStorage* storage_; }; @@ -61,7 +62,7 @@ // refcounting semantics used with IOBuffer with these structures too. struct CONTENT_EXPORT HttpResponseInfoIOBuffer : public base::RefCountedThreadSafe<HttpResponseInfoIOBuffer> { - scoped_ptr<net::HttpResponseInfo> http_info; + std::unique_ptr<net::HttpResponseInfo> http_info; int response_data_size; HttpResponseInfoIOBuffer();
diff --git a/content/browser/appcache/appcache_response_unittest.cc b/content/browser/appcache/appcache_response_unittest.cc index 54f3a6e..c6588cd 100644 --- a/content/browser/appcache/appcache_response_unittest.cc +++ b/content/browser/appcache/appcache_response_unittest.cc
@@ -757,12 +757,12 @@ // Data members - scoped_ptr<base::WaitableEvent> test_finished_event_; - scoped_ptr<MockStorageDelegate> storage_delegate_; - scoped_ptr<MockAppCacheService> service_; + std::unique_ptr<base::WaitableEvent> test_finished_event_; + std::unique_ptr<MockStorageDelegate> storage_delegate_; + std::unique_ptr<MockAppCacheService> service_; std::stack<std::pair<base::Closure, bool> > task_stack_; - scoped_ptr<AppCacheResponseReader> reader_; + std::unique_ptr<AppCacheResponseReader> reader_; scoped_refptr<HttpResponseInfoIOBuffer> read_info_buffer_; scoped_refptr<IOBuffer> read_buffer_; int expected_read_result_; @@ -771,8 +771,8 @@ bool read_callback_was_called_; int64_t written_response_id_; - scoped_ptr<AppCacheResponseWriter> writer_; - scoped_ptr<AppCacheResponseMetadataWriter> metadata_writer_; + std::unique_ptr<AppCacheResponseWriter> writer_; + std::unique_ptr<AppCacheResponseMetadataWriter> metadata_writer_; scoped_refptr<HttpResponseInfoIOBuffer> write_info_buffer_; scoped_refptr<IOBuffer> write_buffer_; int expected_write_result_; @@ -780,11 +780,11 @@ int writer_deletion_count_down_; bool write_callback_was_called_; - static scoped_ptr<base::Thread> io_thread_; + static std::unique_ptr<base::Thread> io_thread_; }; // static -scoped_ptr<base::Thread> AppCacheResponseTest::io_thread_; +std::unique_ptr<base::Thread> AppCacheResponseTest::io_thread_; TEST_F(AppCacheResponseTest, ReadNonExistentResponse) { RunTestOnIOThread(&AppCacheResponseTest::ReadNonExistentResponse);
diff --git a/content/browser/appcache/appcache_service_impl.cc b/content/browser/appcache/appcache_service_impl.cc index 537ca8e8..eb05b702 100644 --- a/content/browser/appcache/appcache_service_impl.cc +++ b/content/browser/appcache/appcache_service_impl.cc
@@ -294,7 +294,7 @@ // Internals used to perform the checks. const int kIOBufferSize; scoped_refptr<AppCache> cache_; - scoped_ptr<AppCacheResponseReader> response_reader_; + std::unique_ptr<AppCacheResponseReader> response_reader_; scoped_refptr<HttpResponseInfoIOBuffer> info_buffer_; scoped_refptr<net::IOBuffer> data_buffer_; int64_t expected_total_size_; @@ -389,7 +389,7 @@ // AppCacheStorageReference ------ AppCacheStorageReference::AppCacheStorageReference( - scoped_ptr<AppCacheStorage> storage) + std::unique_ptr<AppCacheStorage> storage) : storage_(std::move(storage)) {} AppCacheStorageReference::~AppCacheStorageReference() {}
diff --git a/content/browser/appcache/appcache_service_impl.h b/content/browser/appcache/appcache_service_impl.h index acc660f7..fbebf97 100644 --- a/content/browser/appcache/appcache_service_impl.h +++ b/content/browser/appcache/appcache_service_impl.h
@@ -8,12 +8,12 @@ #include <stdint.h> #include <map> +#include <memory> #include <set> #include "base/gtest_prod_util.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/observer_list.h" #include "base/time/time.h" #include "base/timer/timer.h" @@ -56,10 +56,10 @@ private: friend class AppCacheServiceImpl; friend class base::RefCounted<AppCacheStorageReference>; - AppCacheStorageReference(scoped_ptr<AppCacheStorage> storage); + AppCacheStorageReference(std::unique_ptr<AppCacheStorage> storage); ~AppCacheStorageReference(); - scoped_ptr<AppCacheStorage> storage_; + std::unique_ptr<AppCacheStorage> storage_; }; // Class that manages the application cache service. Sends notifications @@ -203,7 +203,7 @@ AppCachePolicy* appcache_policy_; AppCacheQuotaClient* quota_client_; AppCacheExecutableHandlerFactory* handler_factory_; - scoped_ptr<AppCacheStorage> storage_; + std::unique_ptr<AppCacheStorage> storage_; scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy_; scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy_; PendingAsyncHelpers pending_helpers_;
diff --git a/content/browser/appcache/appcache_service_unittest.cc b/content/browser/appcache/appcache_service_unittest.cc index 5c29d50..6a0fed2 100644 --- a/content/browser/appcache/appcache_service_unittest.cc +++ b/content/browser/appcache/appcache_service_unittest.cc
@@ -83,7 +83,7 @@ weak_factory_.GetWeakPtr(), result)); } - scoped_ptr<net::HttpResponseInfo> info_; + std::unique_ptr<net::HttpResponseInfo> info_; int info_size_; const char* data_; int data_size_; @@ -128,7 +128,7 @@ } void SetupMockGroup() { - scoped_ptr<net::HttpResponseInfo> info(MakeMockResponseInfo()); + std::unique_ptr<net::HttpResponseInfo> info(MakeMockResponseInfo()); const int kMockInfoSize = GetResponseInfoSize(info.get()); // Create a mock group, cache, and entry and stuff them into mock storage. @@ -183,7 +183,7 @@ const GURL kOrigin; const GURL kManifestUrl; - scoped_ptr<AppCacheServiceImpl> service_; + std::unique_ptr<AppCacheServiceImpl> service_; int delete_result_; int delete_completion_count_; net::CompletionCallback deletion_callback_; @@ -337,7 +337,7 @@ const base::TimeDelta kOneHour(base::TimeDelta::FromHours(1)); // Do things get initialized as expected? - scoped_ptr<AppCacheServiceImpl> service(new AppCacheServiceImpl(NULL)); + std::unique_ptr<AppCacheServiceImpl> service(new AppCacheServiceImpl(NULL)); EXPECT_TRUE(service->last_reinit_time_.is_null()); EXPECT_FALSE(service->reinit_timer_.IsRunning()); EXPECT_EQ(kNoDelay, service->next_reinit_delay_);
diff --git a/content/browser/appcache/appcache_storage.h b/content/browser/appcache/appcache_storage.h index 42a77cd..42638b8f 100644 --- a/content/browser/appcache/appcache_storage.h +++ b/content/browser/appcache/appcache_storage.h
@@ -8,13 +8,13 @@ #include <stdint.h> #include <map> +#include <memory> #include <vector> #include "base/compiler_specific.h" #include "base/gtest_prod_util.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/appcache/appcache_working_set.h" #include "content/common/content_export.h" #include "net/base/completion_callback.h" @@ -276,7 +276,7 @@ GURL manifest_url_; int64_t group_id_; int64_t response_id_; - scoped_ptr<AppCacheResponseReader> reader_; + std::unique_ptr<AppCacheResponseReader> reader_; DelegateReferenceVector delegates_; scoped_refptr<HttpResponseInfoIOBuffer> info_buffer_; };
diff --git a/content/browser/appcache/appcache_storage_impl.cc b/content/browser/appcache/appcache_storage_impl.cc index ceb52271..a83180b 100644 --- a/content/browser/appcache/appcache_storage_impl.cc +++ b/content/browser/appcache/appcache_storage_impl.cc
@@ -82,7 +82,7 @@ AppCacheDatabase* database, scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy, bool force_keep_session_state) { - scoped_ptr<AppCacheDatabase> database_to_delete(database); + std::unique_ptr<AppCacheDatabase> database_to_delete(database); // If saving session state, only delete the database. if (force_keep_session_state)
diff --git a/content/browser/appcache/appcache_storage_impl.h b/content/browser/appcache/appcache_storage_impl.h index 664ba31f..1135409 100644 --- a/content/browser/appcache/appcache_storage_impl.h +++ b/content/browser/appcache/appcache_storage_impl.h
@@ -180,7 +180,7 @@ // disk cache and cannot continue. bool is_disabled_; - scoped_ptr<AppCacheDiskCache> disk_cache_; + std::unique_ptr<AppCacheDiskCache> disk_cache_; base::OneShotTimer lazy_commit_timer_; // Used to short-circuit certain operations without having to schedule
diff --git a/content/browser/appcache/appcache_storage_impl_unittest.cc b/content/browser/appcache/appcache_storage_impl_unittest.cc index 9e4c2c4..c47f3c4 100644 --- a/content/browser/appcache/appcache_storage_impl_unittest.cc +++ b/content/browser/appcache/appcache_storage_impl_unittest.cc
@@ -5,6 +5,8 @@ #include "content/browser/appcache/appcache_storage_impl.h" #include <stdint.h> + +#include <memory> #include <stack> #include <utility> @@ -15,7 +17,7 @@ #include "base/files/scoped_temp_dir.h" #include "base/location.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" +#include "base/memory/ptr_util.h" #include "base/single_thread_task_runner.h" #include "base/synchronization/waitable_event.h" #include "base/thread_task_runner_handle.h" @@ -133,7 +135,7 @@ : public net::URLRequestJobFactory::ProtocolHandler { public: MockHttpServerJobFactory( - scoped_ptr<net::URLRequestInterceptor> appcache_start_interceptor) + std::unique_ptr<net::URLRequestInterceptor> appcache_start_interceptor) : appcache_start_interceptor_(std::move(appcache_start_interceptor)) {} net::URLRequestJob* MaybeCreateJob( @@ -147,7 +149,7 @@ return MockHttpServer::CreateJob(request, network_delegate); } private: - scoped_ptr<net::URLRequestInterceptor> appcache_start_interceptor_; + std::unique_ptr<net::URLRequestInterceptor> appcache_start_interceptor_; }; class IOThread : public base::Thread { @@ -163,11 +165,11 @@ } void Init() override { - scoped_ptr<net::URLRequestJobFactoryImpl> factory( + std::unique_ptr<net::URLRequestJobFactoryImpl> factory( new net::URLRequestJobFactoryImpl()); factory->SetProtocolHandler( - "http", make_scoped_ptr(new MockHttpServerJobFactory( - make_scoped_ptr(new AppCacheInterceptor())))); + "http", base::WrapUnique(new MockHttpServerJobFactory( + base::WrapUnique(new AppCacheInterceptor())))); job_factory_ = std::move(factory); request_context_.reset(new net::TestURLRequestContext()); request_context_->set_job_factory(job_factory_.get()); @@ -179,12 +181,12 @@ } private: - scoped_ptr<net::URLRequestJobFactory> job_factory_; - scoped_ptr<net::URLRequestContext> request_context_; + std::unique_ptr<net::URLRequestJobFactory> job_factory_; + std::unique_ptr<net::URLRequestContext> request_context_; }; -scoped_ptr<IOThread> io_thread; -scoped_ptr<base::Thread> db_thread; +std::unique_ptr<IOThread> io_thread; +std::unique_ptr<base::Thread> db_thread; } // namespace @@ -1879,10 +1881,10 @@ // Data members -------------------------------------------------- - scoped_ptr<base::WaitableEvent> test_finished_event_; + std::unique_ptr<base::WaitableEvent> test_finished_event_; std::stack<base::Closure> task_stack_; - scoped_ptr<AppCacheServiceImpl> service_; - scoped_ptr<MockStorageDelegate> delegate_; + std::unique_ptr<AppCacheServiceImpl> service_; + std::unique_ptr<MockStorageDelegate> delegate_; scoped_refptr<MockQuotaManagerProxy> mock_quota_manager_proxy_; scoped_refptr<AppCacheGroup> group_; scoped_refptr<AppCache> cache_; @@ -1890,11 +1892,11 @@ // Specifically for the Reinitalize test. base::ScopedTempDir temp_directory_; - scoped_ptr<MockServiceObserver> observer_; + std::unique_ptr<MockServiceObserver> observer_; MockAppCacheFrontend frontend_; - scoped_ptr<AppCacheBackendImpl> backend_; + std::unique_ptr<AppCacheBackendImpl> backend_; net::TestDelegate request_delegate_; - scoped_ptr<net::URLRequest> request_; + std::unique_ptr<net::URLRequest> request_; };
diff --git a/content/browser/appcache/appcache_update_job.h b/content/browser/appcache/appcache_update_job.h index 4fa1588..57840bf1 100644 --- a/content/browser/appcache/appcache_update_job.h +++ b/content/browser/appcache/appcache_update_job.h
@@ -158,13 +158,13 @@ FetchType fetch_type_; int retry_503_attempts_; scoped_refptr<net::IOBuffer> buffer_; - scoped_ptr<net::URLRequest> request_; + std::unique_ptr<net::URLRequest> request_; AppCacheEntry existing_entry_; scoped_refptr<net::HttpResponseHeaders> existing_response_headers_; std::string manifest_data_; ResultType result_; int redirect_response_code_; - scoped_ptr<AppCacheResponseWriter> response_writer_; + std::unique_ptr<AppCacheResponseWriter> response_writer_; }; // class URLFetcher AppCacheResponseWriter* CreateResponseWriter(); @@ -317,11 +317,11 @@ // Temporary storage of manifest response data for parsing and comparison. std::string manifest_data_; - scoped_ptr<net::HttpResponseInfo> manifest_response_info_; - scoped_ptr<AppCacheResponseWriter> manifest_response_writer_; + std::unique_ptr<net::HttpResponseInfo> manifest_response_info_; + std::unique_ptr<AppCacheResponseWriter> manifest_response_writer_; scoped_refptr<net::IOBuffer> read_manifest_buffer_; std::string loaded_manifest_data_; - scoped_ptr<AppCacheResponseReader> manifest_response_reader_; + std::unique_ptr<AppCacheResponseReader> manifest_response_reader_; bool manifest_has_valid_mime_type_; // New master entries added to the cache by this job, used to cleanup
diff --git a/content/browser/appcache/appcache_update_job_unittest.cc b/content/browser/appcache/appcache_update_job_unittest.cc index 9820bc27..18ba66f 100644 --- a/content/browser/appcache/appcache_update_job_unittest.cc +++ b/content/browser/appcache/appcache_update_job_unittest.cc
@@ -6,12 +6,14 @@ #include <stddef.h> #include <stdint.h> + #include <utility> #include "base/bind.h" #include "base/bind_helpers.h" #include "base/location.h" #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/single_thread_task_runner.h" #include "base/stl_util.h" #include "base/synchronization/waitable_event.h" @@ -578,12 +580,12 @@ } void Init() override { - scoped_ptr<net::URLRequestJobFactoryImpl> factory( + std::unique_ptr<net::URLRequestJobFactoryImpl> factory( new net::URLRequestJobFactoryImpl()); factory->SetProtocolHandler("http", - make_scoped_ptr(new MockHttpServerJobFactory)); + base::WrapUnique(new MockHttpServerJobFactory)); factory->SetProtocolHandler("https", - make_scoped_ptr(new MockHttpServerJobFactory)); + base::WrapUnique(new MockHttpServerJobFactory)); job_factory_ = std::move(factory); request_context_.reset(new net::TestURLRequestContext()); request_context_->set_job_factory(job_factory_.get()); @@ -595,8 +597,8 @@ } private: - scoped_ptr<net::URLRequestJobFactory> job_factory_; - scoped_ptr<net::URLRequestContext> request_context_; + std::unique_ptr<net::URLRequestJobFactory> job_factory_; + std::unique_ptr<net::URLRequestContext> request_context_; }; class AppCacheUpdateJobTest : public testing::Test, @@ -805,7 +807,7 @@ net::URLRequestJobFactoryImpl* new_factory( new net::URLRequestJobFactoryImpl); new_factory->SetProtocolHandler("http", - make_scoped_ptr(new RedirectFactory)); + base::WrapUnique(new RedirectFactory)); io_thread_->SetNewJobFactory(new_factory); MakeService(); @@ -1691,7 +1693,7 @@ net::URLRequestJobFactoryImpl* new_factory( new net::URLRequestJobFactoryImpl); new_factory->SetProtocolHandler( - "http", make_scoped_ptr(new RetryRequestTestJobFactory)); + "http", base::WrapUnique(new RetryRequestTestJobFactory)); io_thread_->SetNewJobFactory(new_factory); MakeService(); @@ -1725,7 +1727,7 @@ net::URLRequestJobFactoryImpl* new_factory( new net::URLRequestJobFactoryImpl); new_factory->SetProtocolHandler( - "http", make_scoped_ptr(new RetryRequestTestJobFactory)); + "http", base::WrapUnique(new RetryRequestTestJobFactory)); io_thread_->SetNewJobFactory(new_factory); MakeService(); @@ -1760,7 +1762,7 @@ net::URLRequestJobFactoryImpl* new_factory( new net::URLRequestJobFactoryImpl); new_factory->SetProtocolHandler( - "http", make_scoped_ptr(new RetryRequestTestJobFactory)); + "http", base::WrapUnique(new RetryRequestTestJobFactory)); io_thread_->SetNewJobFactory(new_factory); MakeService(); @@ -1794,7 +1796,7 @@ net::URLRequestJobFactoryImpl* new_factory( new net::URLRequestJobFactoryImpl); new_factory->SetProtocolHandler( - "http", make_scoped_ptr(new RetryRequestTestJobFactory)); + "http", base::WrapUnique(new RetryRequestTestJobFactory)); io_thread_->SetNewJobFactory(new_factory); MakeService(); @@ -1828,7 +1830,7 @@ net::URLRequestJobFactoryImpl* new_factory( new net::URLRequestJobFactoryImpl); new_factory->SetProtocolHandler( - "http", make_scoped_ptr(new RetryRequestTestJobFactory)); + "http", base::WrapUnique(new RetryRequestTestJobFactory)); io_thread_->SetNewJobFactory(new_factory); MakeService(); @@ -2694,7 +2696,7 @@ net::URLRequestJobFactoryImpl* new_factory( new net::URLRequestJobFactoryImpl); new_factory->SetProtocolHandler( - "http", make_scoped_ptr(new IfModifiedSinceJobFactory)); + "http", base::WrapUnique(new IfModifiedSinceJobFactory)); io_thread_->SetNewJobFactory(new_factory); MakeService(); @@ -2766,7 +2768,7 @@ net::URLRequestJobFactoryImpl* new_factory( new net::URLRequestJobFactoryImpl); new_factory->SetProtocolHandler( - "http", make_scoped_ptr(new IfModifiedSinceJobFactory)); + "http", base::WrapUnique(new IfModifiedSinceJobFactory)); io_thread_->SetNewJobFactory(new_factory); MakeService(); @@ -2830,7 +2832,7 @@ net::URLRequestJobFactoryImpl* new_factory( new net::URLRequestJobFactoryImpl); new_factory->SetProtocolHandler( - "http", make_scoped_ptr(new IfModifiedSinceJobFactory)); + "http", base::WrapUnique(new IfModifiedSinceJobFactory)); io_thread_->SetNewJobFactory(new_factory); MakeService(); @@ -2894,7 +2896,7 @@ net::URLRequestJobFactoryImpl* new_factory( new net::URLRequestJobFactoryImpl); new_factory->SetProtocolHandler( - "http", make_scoped_ptr(new IfModifiedSinceJobFactory)); + "http", base::WrapUnique(new IfModifiedSinceJobFactory)); io_thread_->SetNewJobFactory(new_factory); MakeService(); @@ -2933,7 +2935,7 @@ net::URLRequestJobFactoryImpl* new_factory( new net::URLRequestJobFactoryImpl); new_factory->SetProtocolHandler( - "http", make_scoped_ptr(new IfModifiedSinceJobFactory)); + "http", base::WrapUnique(new IfModifiedSinceJobFactory)); io_thread_->SetNewJobFactory(new_factory); MakeService(); @@ -3422,14 +3424,14 @@ MANIFEST_WITH_INTERCEPT }; - scoped_ptr<IOThread> io_thread_; + std::unique_ptr<IOThread> io_thread_; - scoped_ptr<MockAppCacheService> service_; + std::unique_ptr<MockAppCacheService> service_; scoped_refptr<AppCacheGroup> group_; scoped_refptr<AppCache> protect_newest_cache_; - scoped_ptr<base::WaitableEvent> event_; + std::unique_ptr<base::WaitableEvent> event_; - scoped_ptr<AppCacheResponseWriter> response_writer_; + std::unique_ptr<AppCacheResponseWriter> response_writer_; // Hosts used by an async test that need to live until update job finishes. // Otherwise, test can put host on the stack instead of here.
diff --git a/content/browser/appcache/appcache_url_request_job.h b/content/browser/appcache/appcache_url_request_job.h index 5b872376..23d0f3b 100644 --- a/content/browser/appcache/appcache_url_request_job.h +++ b/content/browser/appcache/appcache_url_request_job.h
@@ -181,10 +181,10 @@ bool cache_entry_not_found_; scoped_refptr<AppCacheResponseInfo> info_; scoped_refptr<net::GrowableIOBuffer> handler_source_buffer_; - scoped_ptr<AppCacheResponseReader> handler_source_reader_; + std::unique_ptr<AppCacheResponseReader> handler_source_reader_; net::HttpByteRange range_requested_; - scoped_ptr<net::HttpResponseInfo> range_response_info_; - scoped_ptr<AppCacheResponseReader> reader_; + std::unique_ptr<net::HttpResponseInfo> range_response_info_; + std::unique_ptr<AppCacheResponseReader> reader_; scoped_refptr<AppCache> cache_; scoped_refptr<AppCacheGroup> group_; const OnPrepareToRestartCallback on_prepare_to_restart_callback_;
diff --git a/content/browser/appcache/appcache_url_request_job_unittest.cc b/content/browser/appcache/appcache_url_request_job_unittest.cc index aa228c87..2ac7536 100644 --- a/content/browser/appcache/appcache_url_request_job_unittest.cc +++ b/content/browser/appcache/appcache_url_request_job_unittest.cc
@@ -2,9 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/browser/appcache/appcache_url_request_job.h" + #include <stdint.h> #include <string.h> +#include <memory> #include <stack> #include <utility> @@ -15,7 +18,6 @@ #include "base/location.h" #include "base/logging.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/pickle.h" #include "base/single_thread_task_runner.h" @@ -23,7 +25,6 @@ #include "base/thread_task_runner_handle.h" #include "base/threading/thread.h" #include "content/browser/appcache/appcache_response.h" -#include "content/browser/appcache/appcache_url_request_job.h" #include "content/browser/appcache/mock_appcache_service.h" #include "net/base/io_buffer.h" #include "net/base/net_errors.h" @@ -70,7 +71,9 @@ ~MockURLRequestJobFactory() override { DCHECK(!job_); } - void SetJob(scoped_ptr<net::URLRequestJob> job) { job_ = std::move(job); } + void SetJob(std::unique_ptr<net::URLRequestJob> job) { + job_ = std::move(job); + } bool has_job() const { return job_.get() != nullptr; } @@ -115,7 +118,7 @@ private: // This is mutable because MaybeCreateJobWithProtocolHandler is const. - mutable scoped_ptr<net::URLRequestJob> job_; + mutable std::unique_ptr<net::URLRequestJob> job_; }; } // namespace @@ -455,7 +458,7 @@ // Create an instance and see that it looks as expected. - scoped_ptr<AppCacheURLRequestJob> job( + std::unique_ptr<AppCacheURLRequestJob> job( new AppCacheURLRequestJob(request_.get(), nullptr, storage, nullptr, false, base::Bind(&ExpectNotRestarted))); EXPECT_TRUE(job->is_waiting()); @@ -474,13 +477,13 @@ // DeliveryOrders ----------------------------------------------------- void DeliveryOrders() { AppCacheStorage* storage = service_->storage(); - scoped_ptr<net::URLRequest> request(empty_context_->CreateRequest( + std::unique_ptr<net::URLRequest> request(empty_context_->CreateRequest( GURL("http://blah/"), net::DEFAULT_PRIORITY, nullptr)); // Create an instance, give it a delivery order and see that // it looks as expected. - scoped_ptr<AppCacheURLRequestJob> job( + std::unique_ptr<AppCacheURLRequestJob> job( new AppCacheURLRequestJob(request.get(), nullptr, storage, nullptr, false, base::Bind(&ExpectNotRestarted))); job->DeliverErrorResponse(); @@ -530,7 +533,7 @@ // Set up to create an AppCacheURLRequestJob with orders to deliver // a network response. - scoped_ptr<AppCacheURLRequestJob> mock_job(new AppCacheURLRequestJob( + std::unique_ptr<AppCacheURLRequestJob> mock_job(new AppCacheURLRequestJob( request_.get(), nullptr, storage, nullptr, false, base::Bind(&SetIfCalled, &restart_callback_invoked_))); mock_job->DeliverNetworkResponse(); @@ -568,7 +571,7 @@ // Setup to create an AppCacheURLRequestJob with orders to deliver // a network response. - scoped_ptr<AppCacheURLRequestJob> mock_job( + std::unique_ptr<AppCacheURLRequestJob> mock_job( new AppCacheURLRequestJob(request_.get(), nullptr, storage, nullptr, false, base::Bind(&ExpectNotRestarted))); mock_job->DeliverErrorResponse(); @@ -620,7 +623,7 @@ // Setup to create an AppCacheURLRequestJob with orders to deliver // a network response. - scoped_ptr<AppCacheURLRequestJob> job( + std::unique_ptr<AppCacheURLRequestJob> job( new AppCacheURLRequestJob(request_.get(), NULL, storage, NULL, false, base::Bind(&ExpectNotRestarted))); @@ -741,7 +744,7 @@ request_->SetExtraRequestHeaders(extra_headers); // Create job with orders to deliver an appcached entry. - scoped_ptr<AppCacheURLRequestJob> job( + std::unique_ptr<AppCacheURLRequestJob> job( new AppCacheURLRequestJob(request_.get(), NULL, storage, NULL, false, base::Bind(&ExpectNotRestarted))); job->DeliverAppCachedResponse( @@ -832,19 +835,19 @@ // Data members -------------------------------------------------------- - scoped_ptr<base::WaitableEvent> test_finished_event_; - scoped_ptr<MockStorageDelegate> storage_delegate_; - scoped_ptr<MockAppCacheService> service_; + std::unique_ptr<base::WaitableEvent> test_finished_event_; + std::unique_ptr<MockStorageDelegate> storage_delegate_; + std::unique_ptr<MockAppCacheService> service_; std::stack<std::pair<base::Closure, bool> > task_stack_; - scoped_ptr<AppCacheResponseReader> reader_; + std::unique_ptr<AppCacheResponseReader> reader_; scoped_refptr<HttpResponseInfoIOBuffer> read_info_buffer_; scoped_refptr<IOBuffer> read_buffer_; int expected_read_result_; int reader_deletion_count_down_; int64_t written_response_id_; - scoped_ptr<AppCacheResponseWriter> writer_; + std::unique_ptr<AppCacheResponseWriter> writer_; scoped_refptr<HttpResponseInfoIOBuffer> write_info_buffer_; scoped_refptr<IOBuffer> write_buffer_; int expected_write_result_; @@ -852,16 +855,16 @@ bool restart_callback_invoked_; - scoped_ptr<MockURLRequestJobFactory> job_factory_; - scoped_ptr<net::URLRequestContext> empty_context_; - scoped_ptr<net::URLRequest> request_; - scoped_ptr<MockURLRequestDelegate> url_request_delegate_; + std::unique_ptr<MockURLRequestJobFactory> job_factory_; + std::unique_ptr<net::URLRequestContext> empty_context_; + std::unique_ptr<net::URLRequest> request_; + std::unique_ptr<MockURLRequestDelegate> url_request_delegate_; - static scoped_ptr<base::Thread> io_thread_; + static std::unique_ptr<base::Thread> io_thread_; }; // static -scoped_ptr<base::Thread> AppCacheURLRequestJobTest::io_thread_; +std::unique_ptr<base::Thread> AppCacheURLRequestJobTest::io_thread_; TEST_F(AppCacheURLRequestJobTest, Basic) { RunTestOnIOThread(&AppCacheURLRequestJobTest::Basic);
diff --git a/content/browser/appcache/mock_appcache_storage.h b/content/browser/appcache/mock_appcache_storage.h index 22d0e8e..6a27ad3b 100644 --- a/content/browser/appcache/mock_appcache_storage.h +++ b/content/browser/appcache/mock_appcache_storage.h
@@ -9,13 +9,13 @@ #include <deque> #include <map> +#include <memory> #include <vector> #include "base/callback.h" #include "base/containers/hash_tables.h" #include "base/gtest_prod_util.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "content/browser/appcache/appcache.h" #include "content/browser/appcache/appcache_disk_cache.h" @@ -201,7 +201,7 @@ StoredGroupMap stored_groups_; StoredEvictionTimesMap stored_eviction_times_; DoomedResponseIds doomed_response_ids_; - scoped_ptr<AppCacheDiskCache> disk_cache_; + std::unique_ptr<AppCacheDiskCache> disk_cache_; std::deque<base::Closure> pending_tasks_; bool simulate_make_group_obsolete_failure_; @@ -217,7 +217,7 @@ GURL simulated_found_manifest_url_; bool simulated_found_network_namespace_; scoped_refptr<AppCacheInfoCollection> simulated_appcache_info_; - scoped_ptr<AppCacheResponseReader> simulated_reader_; + std::unique_ptr<AppCacheResponseReader> simulated_reader_; base::WeakPtrFactory<MockAppCacheStorage> weak_factory_;
diff --git a/content/browser/background_sync/background_sync_browsertest.cc b/content/browser/background_sync/background_sync_browsertest.cc index 4113137..e12f59e6 100644 --- a/content/browser/background_sync/background_sync_browsertest.cc +++ b/content/browser/background_sync/background_sync_browsertest.cc
@@ -72,7 +72,7 @@ const std::string& tag, const base::Callback<void(bool)>& callback, BackgroundSyncStatus error_type, - scoped_ptr<ScopedVector<BackgroundSyncRegistration>> registrations) { + std::unique_ptr<ScopedVector<BackgroundSyncRegistration>> registrations) { ASSERT_EQ(BACKGROUND_SYNC_STATUS_OK, error_type); // Find the right registration in the list and check its status. for (const BackgroundSyncRegistration* registration : *registrations) { @@ -207,7 +207,7 @@ net::EmbeddedTestServer* https_server() { return https_server_.get(); } private: - scoped_ptr<net::EmbeddedTestServer> https_server_; + std::unique_ptr<net::EmbeddedTestServer> https_server_; Shell* shell_ = nullptr; DISALLOW_COPY_AND_ASSIGN(BackgroundSyncBrowserTest);
diff --git a/content/browser/background_sync/background_sync_context_impl.cc b/content/browser/background_sync/background_sync_context_impl.cc index bd92edb..19e6c60 100644 --- a/content/browser/background_sync/background_sync_context_impl.cc +++ b/content/browser/background_sync/background_sync_context_impl.cc
@@ -69,7 +69,7 @@ } void BackgroundSyncContextImpl::set_background_sync_manager_for_testing( - scoped_ptr<BackgroundSyncManager> manager) { + std::unique_ptr<BackgroundSyncManager> manager) { DCHECK_CURRENTLY_ON(BrowserThread::IO); background_sync_manager_ = std::move(manager);
diff --git a/content/browser/background_sync/background_sync_context_impl.h b/content/browser/background_sync/background_sync_context_impl.h index 1eebe700..f845b304 100644 --- a/content/browser/background_sync/background_sync_context_impl.h +++ b/content/browser/background_sync/background_sync_context_impl.h
@@ -5,11 +5,11 @@ #ifndef CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_CONTEXT_IMPL_H_ #define CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_CONTEXT_IMPL_H_ +#include <memory> #include <set> #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "content/common/background_sync_service.mojom.h" #include "content/common/content_export.h" #include "content/public/browser/background_sync_context.h" @@ -51,7 +51,7 @@ ~BackgroundSyncContextImpl() override; void set_background_sync_manager_for_testing( - scoped_ptr<BackgroundSyncManager> manager); + std::unique_ptr<BackgroundSyncManager> manager); private: friend class BackgroundSyncServiceImplTest; @@ -65,7 +65,7 @@ void ShutdownOnIO(); // Only accessed on the IO thread. - scoped_ptr<BackgroundSyncManager> background_sync_manager_; + std::unique_ptr<BackgroundSyncManager> background_sync_manager_; // The services are owned by this. They're either deleted // during ShutdownOnIO or when the channel is closed via
diff --git a/content/browser/background_sync/background_sync_manager.cc b/content/browser/background_sync/background_sync_manager.cc index 343dd05a..097b9b8 100644 --- a/content/browser/background_sync/background_sync_manager.cc +++ b/content/browser/background_sync/background_sync_manager.cc
@@ -9,6 +9,7 @@ #include "base/barrier_closure.h" #include "base/bind.h" #include "base/location.h" +#include "base/memory/ptr_util.h" #include "base/single_thread_task_runner.h" #include "base/thread_task_runner_handle.h" #include "base/time/default_clock.h" @@ -46,7 +47,7 @@ base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(callback, status, - base::Passed(scoped_ptr<BackgroundSyncRegistration>()))); + base::Passed(std::unique_ptr<BackgroundSyncRegistration>()))); } // Returns nullptr if the browser context cannot be accessed for any reason. @@ -126,9 +127,9 @@ } } -scoped_ptr<BackgroundSyncParameters> GetControllerParameters( +std::unique_ptr<BackgroundSyncParameters> GetControllerParameters( const scoped_refptr<ServiceWorkerContextWrapper>& sw_context_wrapper, - scoped_ptr<BackgroundSyncParameters> parameters) { + std::unique_ptr<BackgroundSyncParameters> parameters) { DCHECK_CURRENTLY_ON(BrowserThread::UI); BackgroundSyncController* background_sync_controller = @@ -173,14 +174,14 @@ } // static -scoped_ptr<BackgroundSyncManager> BackgroundSyncManager::Create( +std::unique_ptr<BackgroundSyncManager> BackgroundSyncManager::Create( const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context) { DCHECK_CURRENTLY_ON(BrowserThread::IO); BackgroundSyncManager* sync_manager = new BackgroundSyncManager(service_worker_context); sync_manager->Init(); - return make_scoped_ptr(sync_manager); + return base::WrapUnique(sync_manager); } BackgroundSyncManager::~BackgroundSyncManager() { @@ -216,8 +217,9 @@ FROM_HERE, base::Bind( callback, BACKGROUND_SYNC_STATUS_STORAGE_ERROR, - base::Passed(scoped_ptr<ScopedVector<BackgroundSyncRegistration>>( - new ScopedVector<BackgroundSyncRegistration>())))); + base::Passed( + std::unique_ptr<ScopedVector<BackgroundSyncRegistration>>( + new ScopedVector<BackgroundSyncRegistration>())))); return; } @@ -300,7 +302,7 @@ return; } - scoped_ptr<BackgroundSyncParameters> parameters_copy( + std::unique_ptr<BackgroundSyncParameters> parameters_copy( new BackgroundSyncParameters(*parameters_)); BrowserThread::PostTaskAndReplyWithResult( @@ -313,7 +315,7 @@ void BackgroundSyncManager::InitDidGetControllerParameters( const base::Closure& callback, - scoped_ptr<BackgroundSyncParameters> updated_parameters) { + std::unique_ptr<BackgroundSyncParameters> updated_parameters) { DCHECK_CURRENTLY_ON(BrowserThread::IO); parameters_ = std::move(updated_parameters); @@ -509,7 +511,7 @@ base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(callback, BACKGROUND_SYNC_STATUS_OK, - base::Passed(make_scoped_ptr(new BackgroundSyncRegistration( + base::Passed(base::WrapUnique(new BackgroundSyncRegistration( *existing_registration))))); return; } @@ -662,9 +664,9 @@ "failure."; BackgroundSyncMetrics::CountRegisterFailure( BACKGROUND_SYNC_STATUS_STORAGE_ERROR); - DisableAndClearManager( - base::Bind(callback, BACKGROUND_SYNC_STATUS_STORAGE_ERROR, - base::Passed(scoped_ptr<BackgroundSyncRegistration>()))); + DisableAndClearManager(base::Bind( + callback, BACKGROUND_SYNC_STATUS_STORAGE_ERROR, + base::Passed(std::unique_ptr<BackgroundSyncRegistration>()))); return; } @@ -681,7 +683,7 @@ base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(callback, BACKGROUND_SYNC_STATUS_OK, - base::Passed(make_scoped_ptr( + base::Passed(base::WrapUnique( new BackgroundSyncRegistration(new_registration))))); } @@ -782,7 +784,7 @@ const StatusAndRegistrationsCallback& callback) { DCHECK_CURRENTLY_ON(BrowserThread::IO); - scoped_ptr<ScopedVector<BackgroundSyncRegistration>> out_registrations( + std::unique_ptr<ScopedVector<BackgroundSyncRegistration>> out_registrations( new ScopedVector<BackgroundSyncRegistration>()); if (disabled_) { @@ -1185,7 +1187,7 @@ void BackgroundSyncManager::CompleteStatusAndRegistrationCallback( StatusAndRegistrationCallback callback, BackgroundSyncStatus status, - scoped_ptr<BackgroundSyncRegistration> registration) { + std::unique_ptr<BackgroundSyncRegistration> registration) { DCHECK_CURRENTLY_ON(BrowserThread::IO); callback.Run(status, std::move(registration)); @@ -1195,7 +1197,7 @@ void BackgroundSyncManager::CompleteStatusAndRegistrationsCallback( StatusAndRegistrationsCallback callback, BackgroundSyncStatus status, - scoped_ptr<ScopedVector<BackgroundSyncRegistration>> registrations) { + std::unique_ptr<ScopedVector<BackgroundSyncRegistration>> registrations) { DCHECK_CURRENTLY_ON(BrowserThread::IO); callback.Run(status, std::move(registrations));
diff --git a/content/browser/background_sync/background_sync_manager.h b/content/browser/background_sync/background_sync_manager.h index e80ee0a..d16a7a8 100644 --- a/content/browser/background_sync/background_sync_manager.h +++ b/content/browser/background_sync/background_sync_manager.h
@@ -9,6 +9,7 @@ #include <stdint.h> #include <map> +#include <memory> #include <string> #include <utility> #include <vector> @@ -16,7 +17,6 @@ #include "base/callback_forward.h" #include "base/cancelable_callback.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_vector.h" #include "base/memory/weak_ptr.h" #include "base/time/clock.h" @@ -58,12 +58,12 @@ using StatusCallback = base::Callback<void(BackgroundSyncStatus)>; using StatusAndRegistrationCallback = base::Callback<void(BackgroundSyncStatus, - scoped_ptr<BackgroundSyncRegistration>)>; + std::unique_ptr<BackgroundSyncRegistration>)>; using StatusAndRegistrationsCallback = base::Callback<void( BackgroundSyncStatus, - scoped_ptr<ScopedVector<BackgroundSyncRegistration>>)>; + std::unique_ptr<ScopedVector<BackgroundSyncRegistration>>)>; - static scoped_ptr<BackgroundSyncManager> Create( + static std::unique_ptr<BackgroundSyncManager> Create( const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context); ~BackgroundSyncManager() override; @@ -97,7 +97,7 @@ return network_observer_.get(); } - void set_clock(scoped_ptr<base::Clock> clock) { + void set_clock(std::unique_ptr<base::Clock> clock) { DCHECK_CURRENTLY_ON(BrowserThread::IO); clock_ = std::move(clock); } @@ -186,7 +186,7 @@ void InitImpl(const base::Closure& callback); void InitDidGetControllerParameters( const base::Closure& callback, - scoped_ptr<BackgroundSyncParameters> parameters); + std::unique_ptr<BackgroundSyncParameters> parameters); void InitDidGetDataFromBackend( const base::Closure& callback, const std::vector<std::pair<int64_t, std::string>>& user_data, @@ -285,11 +285,11 @@ void CompleteStatusAndRegistrationCallback( StatusAndRegistrationCallback callback, BackgroundSyncStatus status, - scoped_ptr<BackgroundSyncRegistration> registration); + std::unique_ptr<BackgroundSyncRegistration> registration); void CompleteStatusAndRegistrationsCallback( StatusAndRegistrationsCallback callback, BackgroundSyncStatus status, - scoped_ptr<ScopedVector<BackgroundSyncRegistration>> registrations); + std::unique_ptr<ScopedVector<BackgroundSyncRegistration>> registrations); base::Closure MakeEmptyCompletion(); base::Closure MakeClosureCompletion(const base::Closure& callback); StatusAndRegistrationCallback MakeStatusAndRegistrationCompletion( @@ -303,7 +303,7 @@ CacheStorageScheduler op_scheduler_; scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; - scoped_ptr<BackgroundSyncParameters> parameters_; + std::unique_ptr<BackgroundSyncParameters> parameters_; // True if the manager is disabled and registrations should fail. bool disabled_; @@ -313,9 +313,9 @@ base::CancelableCallback<void()> delayed_sync_task_; - scoped_ptr<BackgroundSyncNetworkObserver> network_observer_; + std::unique_ptr<BackgroundSyncNetworkObserver> network_observer_; - scoped_ptr<base::Clock> clock_; + std::unique_ptr<base::Clock> clock_; base::WeakPtrFactory<BackgroundSyncManager> weak_ptr_factory_;
diff --git a/content/browser/background_sync/background_sync_manager_unittest.cc b/content/browser/background_sync/background_sync_manager_unittest.cc index dbe81cd..2ef0f0b 100644 --- a/content/browser/background_sync/background_sync_manager_unittest.cc +++ b/content/browser/background_sync/background_sync_manager_unittest.cc
@@ -5,13 +5,15 @@ #include "content/browser/background_sync/background_sync_manager.h" #include <stdint.h> + +#include <memory> #include <utility> #include "base/files/scoped_temp_dir.h" #include "base/location.h" #include "base/logging.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" +#include "base/memory/ptr_util.h" #include "base/metrics/field_trial.h" #include "base/run_loop.h" #include "base/single_thread_task_runner.h" @@ -123,7 +125,7 @@ // extra SW stuff. helper_.reset(new EmbeddedWorkerTestHelper(base::FilePath())); - scoped_ptr<MockPermissionManager> mock_permission_manager( + std::unique_ptr<MockPermissionManager> mock_permission_manager( new testing::NiceMock<MockPermissionManager>()); ON_CALL(*mock_permission_manager, GetPermissionStatus(PermissionType::BACKGROUND_SYNC, _, _)) @@ -198,7 +200,7 @@ void StatusAndRegistrationCallback( bool* was_called, BackgroundSyncStatus status, - scoped_ptr<BackgroundSyncRegistration> registration) { + std::unique_ptr<BackgroundSyncRegistration> registration) { *was_called = true; callback_status_ = status; callback_registration_ = std::move(registration); @@ -207,7 +209,7 @@ void StatusAndRegistrationsCallback( bool* was_called, BackgroundSyncStatus status, - scoped_ptr<ScopedVector<BackgroundSyncRegistration>> registrations) { + std::unique_ptr<ScopedVector<BackgroundSyncRegistration>> registrations) { *was_called = true; callback_status_ = status; callback_registrations_ = std::move(registrations); @@ -225,7 +227,7 @@ background_sync_manager_.reset(test_background_sync_manager_); test_clock_ = new base::SimpleTestClock(); - background_sync_manager_->set_clock(make_scoped_ptr(test_clock_)); + background_sync_manager_->set_clock(base::WrapUnique(test_clock_)); // Many tests do not expect the sync event to fire immediately after // register (and cleanup up the sync registrations). Tests can control when @@ -407,10 +409,10 @@ } TestBrowserThreadBundle browser_thread_bundle_; - scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; - scoped_ptr<EmbeddedWorkerTestHelper> helper_; - scoped_ptr<BackgroundSyncManager> background_sync_manager_; - scoped_ptr<StoragePartitionImpl> storage_partition_impl_; + std::unique_ptr<net::NetworkChangeNotifier> network_change_notifier_; + std::unique_ptr<EmbeddedWorkerTestHelper> helper_; + std::unique_ptr<BackgroundSyncManager> background_sync_manager_; + std::unique_ptr<StoragePartitionImpl> storage_partition_impl_; TestBackgroundSyncManager* test_background_sync_manager_ = nullptr; base::SimpleTestClock* test_clock_ = nullptr; @@ -424,8 +426,9 @@ // Callback values. BackgroundSyncStatus callback_status_ = BACKGROUND_SYNC_STATUS_OK; - scoped_ptr<BackgroundSyncRegistration> callback_registration_; - scoped_ptr<ScopedVector<BackgroundSyncRegistration>> callback_registrations_; + std::unique_ptr<BackgroundSyncRegistration> callback_registration_; + std::unique_ptr<ScopedVector<BackgroundSyncRegistration>> + callback_registrations_; ServiceWorkerStatusCode callback_sw_status_code_ = SERVICE_WORKER_OK; int sync_events_called_ = 0; ServiceWorkerVersion::StatusCallback sync_fired_callback_;
diff --git a/content/browser/background_sync/background_sync_network_observer_unittest.cc b/content/browser/background_sync/background_sync_network_observer_unittest.cc index eb97bed..1b9b2ff9 100644 --- a/content/browser/background_sync/background_sync_network_observer_unittest.cc +++ b/content/browser/background_sync/background_sync_network_observer_unittest.cc
@@ -30,8 +30,8 @@ TestBrowserThreadBundle browser_thread_bundle_; - scoped_ptr<net::NetworkChangeNotifier> network_change_notifier; - scoped_ptr<BackgroundSyncNetworkObserver> network_observer_; + std::unique_ptr<net::NetworkChangeNotifier> network_change_notifier; + std::unique_ptr<BackgroundSyncNetworkObserver> network_observer_; int network_changed_count_; };
diff --git a/content/browser/background_sync/background_sync_registration.h b/content/browser/background_sync/background_sync_registration.h index 924540f..684370d 100644 --- a/content/browser/background_sync/background_sync_registration.h +++ b/content/browser/background_sync/background_sync_registration.h
@@ -8,10 +8,10 @@ #include <stdint.h> #include <list> +#include <memory> #include "base/callback.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/time/time.h" #include "content/browser/background_sync/background_sync.pb.h" #include "content/browser/background_sync/background_sync_registration_options.h" @@ -68,9 +68,9 @@ template <> struct CONTENT_EXPORT - TypeConverter<scoped_ptr<content::BackgroundSyncRegistration>, + TypeConverter<std::unique_ptr<content::BackgroundSyncRegistration>, content::mojom::SyncRegistrationPtr> { - static scoped_ptr<content::BackgroundSyncRegistration> Convert( + static std::unique_ptr<content::BackgroundSyncRegistration> Convert( const content::mojom::SyncRegistrationPtr& input); };
diff --git a/content/browser/background_sync/background_sync_service_impl.cc b/content/browser/background_sync/background_sync_service_impl.cc index a5b51bd..6394a642 100644 --- a/content/browser/background_sync/background_sync_service_impl.cc +++ b/content/browser/background_sync/background_sync_service_impl.cc
@@ -127,7 +127,7 @@ void BackgroundSyncServiceImpl::OnRegisterResult( const RegisterCallback& callback, BackgroundSyncStatus status, - scoped_ptr<BackgroundSyncRegistration> result) { + std::unique_ptr<BackgroundSyncRegistration> result) { DCHECK_CURRENTLY_ON(BrowserThread::IO); if (status != BACKGROUND_SYNC_STATUS_OK) { @@ -146,7 +146,8 @@ void BackgroundSyncServiceImpl::OnGetRegistrationsResult( const GetRegistrationsCallback& callback, BackgroundSyncStatus status, - scoped_ptr<ScopedVector<BackgroundSyncRegistration>> result_registrations) { + std::unique_ptr<ScopedVector<BackgroundSyncRegistration>> + result_registrations) { DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK(result_registrations);
diff --git a/content/browser/background_sync/background_sync_service_impl.h b/content/browser/background_sync/background_sync_service_impl.h index 1851b90..c058b26 100644 --- a/content/browser/background_sync/background_sync_service_impl.h +++ b/content/browser/background_sync/background_sync_service_impl.h
@@ -40,11 +40,11 @@ void OnRegisterResult(const RegisterCallback& callback, BackgroundSyncStatus status, - scoped_ptr<BackgroundSyncRegistration> result); + std::unique_ptr<BackgroundSyncRegistration> result); void OnGetRegistrationsResult( const GetRegistrationsCallback& callback, BackgroundSyncStatus status, - scoped_ptr<ScopedVector<BackgroundSyncRegistration>> result); + std::unique_ptr<ScopedVector<BackgroundSyncRegistration>> result); // Called when an error is detected on binding_. void OnConnectionError();
diff --git a/content/browser/background_sync/background_sync_service_impl_unittest.cc b/content/browser/background_sync/background_sync_service_impl_unittest.cc index 8f413508..6cc0253 100644 --- a/content/browser/background_sync/background_sync_service_impl_unittest.cc +++ b/content/browser/background_sync/background_sync_service_impl_unittest.cc
@@ -5,11 +5,12 @@ #include "content/browser/background_sync/background_sync_service_impl.h" #include <stdint.h> + +#include <memory> #include <utility> #include "base/bind.h" #include "base/bind_helpers.h" -#include "base/memory/scoped_ptr.h" #include "base/run_loop.h" #include "content/browser/background_sync/background_sync_context_impl.h" #include "content/browser/background_sync/background_sync_network_observer.h" @@ -118,7 +119,7 @@ void CreateTestHelper() { embedded_worker_helper_.reset( new EmbeddedWorkerTestHelper(base::FilePath())); - scoped_ptr<MockPermissionManager> mock_permission_manager( + std::unique_ptr<MockPermissionManager> mock_permission_manager( new testing::NiceMock<MockPermissionManager>()); ON_CALL(*mock_permission_manager, GetPermissionStatus(PermissionType::BACKGROUND_SYNC, _, _)) @@ -203,10 +204,10 @@ base::RunLoop().RunUntilIdle(); } - scoped_ptr<TestBrowserThreadBundle> thread_bundle_; - scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; - scoped_ptr<EmbeddedWorkerTestHelper> embedded_worker_helper_; - scoped_ptr<StoragePartitionImpl> storage_partition_impl_; + std::unique_ptr<TestBrowserThreadBundle> thread_bundle_; + std::unique_ptr<net::NetworkChangeNotifier> network_change_notifier_; + std::unique_ptr<EmbeddedWorkerTestHelper> embedded_worker_helper_; + std::unique_ptr<StoragePartitionImpl> storage_partition_impl_; scoped_refptr<BackgroundSyncContextImpl> background_sync_context_; int64_t sw_registration_id_; scoped_refptr<ServiceWorkerRegistration> sw_registration_;
diff --git a/content/browser/battery_status/battery_monitor_impl_browsertest.cc b/content/browser/battery_status/battery_monitor_impl_browsertest.cc index 8e4b6bc..f84da6fd5 100644 --- a/content/browser/battery_status/battery_monitor_impl_browsertest.cc +++ b/content/browser/battery_status/battery_monitor_impl_browsertest.cc
@@ -75,7 +75,7 @@ // We keep a raw pointer to the FakeBatteryManager, which we expect to // remain valid for the lifetime of the BatteryStatusService. - scoped_ptr<FakeBatteryManager> battery_manager(new FakeBatteryManager( + std::unique_ptr<FakeBatteryManager> battery_manager(new FakeBatteryManager( battery_service_->GetUpdateCallbackForTesting())); battery_manager_ = battery_manager.get(); @@ -84,7 +84,7 @@ void TearDown() override { battery_service_->SetBatteryManagerForTesting( - scoped_ptr<device::BatteryStatusManager>()); + std::unique_ptr<device::BatteryStatusManager>()); battery_manager_ = NULL; }
diff --git a/content/browser/battery_status/battery_monitor_integration_browsertest.cc b/content/browser/battery_status/battery_monitor_integration_browsertest.cc index 1aee2958..0fa65608 100644 --- a/content/browser/battery_status/battery_monitor_integration_browsertest.cc +++ b/content/browser/battery_status/battery_monitor_integration_browsertest.cc
@@ -82,7 +82,7 @@ } } - scoped_ptr<BatteryUpdateSubscription> subscription_; + std::unique_ptr<BatteryUpdateSubscription> subscription_; mojo::StrongBinding<BatteryMonitor> binding_; BatteryStatusCallback callback_; };
diff --git a/content/browser/blob_storage/blob_async_builder_host_unittest.cc b/content/browser/blob_storage/blob_async_builder_host_unittest.cc index d40cc7c..31cdc667 100644 --- a/content/browser/blob_storage/blob_async_builder_host_unittest.cc +++ b/content/browser/blob_storage/blob_async_builder_host_unittest.cc
@@ -86,9 +86,10 @@ } void RequestMemoryCallback( - scoped_ptr<std::vector<storage::BlobItemBytesRequest>> requests, - scoped_ptr<std::vector<base::SharedMemoryHandle>> shared_memory_handles, - scoped_ptr<std::vector<base::File>> files) { + std::unique_ptr<std::vector<storage::BlobItemBytesRequest>> requests, + std::unique_ptr<std::vector<base::SharedMemoryHandle>> + shared_memory_handles, + std::unique_ptr<std::vector<base::File>> files) { requests_ = std::move(*requests); memory_handles_ = std::move(*shared_memory_handles); request_called_ = true; @@ -129,7 +130,7 @@ std::vector<base::SharedMemoryHandle> memory_handles_; std::set<std::string> completed_blob_uuid_set_; - scoped_ptr<BlobDataHandle> completed_blob_handle_; + std::unique_ptr<BlobDataHandle> completed_blob_handle_; }; // The 'shortcut' method is when the data is included in the initial IPCs and @@ -153,10 +154,11 @@ EXPECT_FALSE(request_called_); EXPECT_EQ(0u, host_.blob_building_count()); - scoped_ptr<BlobDataHandle> handle = context_.GetBlobDataFromUUID(kBlobUUID); + std::unique_ptr<BlobDataHandle> handle = + context_.GetBlobDataFromUUID(kBlobUUID); EXPECT_FALSE(handle->IsBeingBuilt()); EXPECT_FALSE(handle->IsBroken()); - scoped_ptr<BlobDataSnapshot> data = handle->CreateSnapshot(); + std::unique_ptr<BlobDataSnapshot> data = handle->CreateSnapshot(); EXPECT_EQ(expected, *data); data.reset(); handle.reset(); @@ -257,11 +259,11 @@ host_.OnMemoryResponses(kBlobUUID, responses, &context_)); EXPECT_FALSE(request_called_); EXPECT_EQ(0u, host_.blob_building_count()); - scoped_ptr<BlobDataHandle> blob_handle = + std::unique_ptr<BlobDataHandle> blob_handle = context_.GetBlobDataFromUUID(kBlobUUID); EXPECT_FALSE(blob_handle->IsBeingBuilt()); EXPECT_FALSE(blob_handle->IsBroken()); - scoped_ptr<BlobDataSnapshot> blob_data = blob_handle->CreateSnapshot(); + std::unique_ptr<BlobDataSnapshot> blob_data = blob_handle->CreateSnapshot(); EXPECT_EQ(expected, *blob_data); }; @@ -285,7 +287,7 @@ &context_); // Check that we're broken, and then remove the blob. - scoped_ptr<BlobDataHandle> blob_handle = + std::unique_ptr<BlobDataHandle> blob_handle = context_.GetBlobDataFromUUID(kBlobUUID); EXPECT_FALSE(blob_handle->IsBeingBuilt()); EXPECT_TRUE(blob_handle->IsBroken()); @@ -316,7 +318,7 @@ blob_handle = context_.GetBlobDataFromUUID(kBlobUUID); EXPECT_FALSE(blob_handle->IsBeingBuilt()); EXPECT_FALSE(blob_handle->IsBroken()); - scoped_ptr<BlobDataSnapshot> blob_data = blob_handle->CreateSnapshot(); + std::unique_ptr<BlobDataSnapshot> blob_data = blob_handle->CreateSnapshot(); EXPECT_EQ(expected, *blob_data); }; @@ -346,11 +348,11 @@ base::Unretained(this)))); EXPECT_TRUE(request_called_); - scoped_ptr<BlobDataHandle> blob_handle1 = + std::unique_ptr<BlobDataHandle> blob_handle1 = context_.GetBlobDataFromUUID(kBlob1); - scoped_ptr<BlobDataHandle> blob_handle2 = + std::unique_ptr<BlobDataHandle> blob_handle2 = context_.GetBlobDataFromUUID(kBlob2); - scoped_ptr<BlobDataHandle> blob_handle3 = + std::unique_ptr<BlobDataHandle> blob_handle3 = context_.GetBlobDataFromUUID(kBlob2); EXPECT_TRUE(blob_handle1->IsBeingBuilt() && blob_handle2->IsBeingBuilt() && blob_handle3->IsBeingBuilt());
diff --git a/content/browser/blob_storage/blob_dispatcher_host.cc b/content/browser/blob_storage/blob_dispatcher_host.cc index 8b3741b1..d3c2e20 100644 --- a/content/browser/blob_storage/blob_dispatcher_host.cc +++ b/content/browser/blob_storage/blob_dispatcher_host.cc
@@ -269,9 +269,9 @@ void BlobDispatcherHost::SendMemoryRequest( const std::string& uuid, - scoped_ptr<std::vector<storage::BlobItemBytesRequest>> requests, - scoped_ptr<std::vector<base::SharedMemoryHandle>> memory_handles, - scoped_ptr<std::vector<base::File>> files) { + std::unique_ptr<std::vector<storage::BlobItemBytesRequest>> requests, + std::unique_ptr<std::vector<base::SharedMemoryHandle>> memory_handles, + std::unique_ptr<std::vector<base::File>> files) { DCHECK_CURRENTLY_ON(BrowserThread::IO); std::vector<IPC::PlatformFileForTransit> file_handles; // TODO(dmurph): Support file-backed blob transportation.
diff --git a/content/browser/blob_storage/blob_dispatcher_host.h b/content/browser/blob_storage/blob_dispatcher_host.h index bf1a03c..b004aa2 100644 --- a/content/browser/blob_storage/blob_dispatcher_host.h +++ b/content/browser/blob_storage/blob_dispatcher_host.h
@@ -118,9 +118,9 @@ void SendMemoryRequest( const std::string& uuid, - scoped_ptr<std::vector<storage::BlobItemBytesRequest>> requests, - scoped_ptr<std::vector<base::SharedMemoryHandle>> memory_handles, - scoped_ptr<std::vector<base::File>> files); + std::unique_ptr<std::vector<storage::BlobItemBytesRequest>> requests, + std::unique_ptr<std::vector<base::SharedMemoryHandle>> memory_handles, + std::unique_ptr<std::vector<base::File>> files); // Send the appropriate IPC response to the renderer for the given result. void SendIPCResponse(const std::string& uuid,
diff --git a/content/browser/blob_storage/blob_dispatcher_host_unittest.cc b/content/browser/blob_storage/blob_dispatcher_host_unittest.cc index 43cdf8a..a537252 100644 --- a/content/browser/blob_storage/blob_dispatcher_host_unittest.cc +++ b/content/browser/blob_storage/blob_dispatcher_host_unittest.cc
@@ -4,10 +4,10 @@ #include "content/browser/blob_storage/blob_dispatcher_host.h" +#include <memory> #include <vector> #include "base/command_line.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/shared_memory.h" #include "base/run_loop.h" #include "base/tuple.h" @@ -164,7 +164,8 @@ void ExpectHandleEqualsData(BlobDataHandle* handle, const std::vector<DataElement>& data) { - scoped_ptr<storage::BlobDataSnapshot> snapshot = handle->CreateSnapshot(); + std::unique_ptr<storage::BlobDataSnapshot> snapshot = + handle->CreateSnapshot(); EXPECT_FALSE(handle->IsBeingBuilt()); for (size_t i = 0; i < data.size(); i++) { const DataElement& expected = data[i]; @@ -276,7 +277,7 @@ const std::string kId = "uuid1"; AsyncShortcutBlobTransfer(kId); EXPECT_TRUE(context_->registry().HasEntry(kId)); - scoped_ptr<BlobDataHandle> handle = context_->GetBlobDataFromUUID(kId); + std::unique_ptr<BlobDataHandle> handle = context_->GetBlobDataFromUUID(kId); EXPECT_TRUE(handle); DataElement expected; @@ -289,7 +290,7 @@ const std::string kId = "uuid1"; AsyncBlobTransfer(kId); EXPECT_TRUE(context_->registry().HasEntry(kId)); - scoped_ptr<BlobDataHandle> handle = context_->GetBlobDataFromUUID(kId); + std::unique_ptr<BlobDataHandle> handle = context_->GetBlobDataFromUUID(kId); EXPECT_TRUE(handle); DataElement expected; @@ -349,7 +350,7 @@ std::set<std::string>()); // Grab the handle. - scoped_ptr<BlobDataHandle> blob_data_handle = + std::unique_ptr<BlobDataHandle> blob_data_handle = context_->GetBlobDataFromUUID(kId); bool built = false; IPCBlobCreationCancelCode error_code = IPCBlobCreationCancelCode::UNKNOWN; @@ -421,7 +422,7 @@ base::RunLoop().RunUntilIdle(); EXPECT_TRUE(built) << "Error code: " << static_cast<int>(error_code); EXPECT_TRUE(context_->registry().HasEntry(kId)); - scoped_ptr<BlobDataHandle> handle = context_->GetBlobDataFromUUID(kId); + std::unique_ptr<BlobDataHandle> handle = context_->GetBlobDataFromUUID(kId); EXPECT_TRUE(handle); DataElement expected; @@ -459,7 +460,7 @@ EXPECT_TRUE(host_->IsInUseInHost(kId)); EXPECT_FALSE(IsBeingBuiltInHost(kId)); // Check that's it's broken. - scoped_ptr<BlobDataHandle> handle = context_->GetBlobDataFromUUID(kId); + std::unique_ptr<BlobDataHandle> handle = context_->GetBlobDataFromUUID(kId); EXPECT_TRUE(handle->IsBroken()); handle.reset(); base::RunLoop().RunUntilIdle(); @@ -490,14 +491,14 @@ // Build up a basic blob. const std::string kId("id"); AsyncShortcutBlobTransfer(kId); - scoped_ptr<BlobDataHandle> handle = context_->GetBlobDataFromUUID(kId); + std::unique_ptr<BlobDataHandle> handle = context_->GetBlobDataFromUUID(kId); EXPECT_TRUE(handle); // Kill the host. host_ = nullptr; base::RunLoop().RunUntilIdle(); // Should still be there due to the handle. - scoped_ptr<BlobDataHandle> another_handle = + std::unique_ptr<BlobDataHandle> another_handle = context_->GetBlobDataFromUUID(kId); EXPECT_TRUE(another_handle); @@ -519,7 +520,7 @@ std::set<std::string>()); // Grab the handle. - scoped_ptr<BlobDataHandle> blob_data_handle = + std::unique_ptr<BlobDataHandle> blob_data_handle = context_->GetBlobDataFromUUID(kId); EXPECT_TRUE(blob_data_handle); EXPECT_TRUE(blob_data_handle->IsBeingBuilt()); @@ -556,7 +557,7 @@ std::set<std::string>()); // Grab the handle. - scoped_ptr<BlobDataHandle> blob_data_handle = + std::unique_ptr<BlobDataHandle> blob_data_handle = context_->GetBlobDataFromUUID(kId); EXPECT_TRUE(blob_data_handle); EXPECT_TRUE(blob_data_handle->IsBeingBuilt()); @@ -584,7 +585,7 @@ std::set<std::string>()); // Grab the handle. - scoped_ptr<BlobDataHandle> blob_data_handle = + std::unique_ptr<BlobDataHandle> blob_data_handle = context_->GetBlobDataFromUUID(kId); EXPECT_TRUE(blob_data_handle); EXPECT_TRUE(blob_data_handle->IsBeingBuilt()); @@ -636,7 +637,7 @@ host_->OnRegisterBlobUUID(kId, std::string(kContentType), std::string(kContentDisposition), std::set<std::string>()); - scoped_ptr<BlobDataHandle> blob_data_handle = + std::unique_ptr<BlobDataHandle> blob_data_handle = context_->GetBlobDataFromUUID(kId); host_->OnDecrementBlobRefCount(kId); EXPECT_TRUE(context_->registry().HasEntry(kId)); @@ -695,7 +696,7 @@ sink_.ClearMessages(); EXPECT_TRUE(context_->registry().HasEntry(kId)); // Grab the handle before decrementing. - scoped_ptr<BlobDataHandle> blob_data_handle = + std::unique_ptr<BlobDataHandle> blob_data_handle = context_->GetBlobDataFromUUID(kId); host_->OnDecrementBlobRefCount(kId); EXPECT_TRUE(context_->registry().HasEntry(kId)); @@ -729,7 +730,7 @@ std::set<std::string>()); EXPECT_FALSE(host_->shutdown_for_bad_message_); - scoped_ptr<BlobDataHandle> blob_data_handle = + std::unique_ptr<BlobDataHandle> blob_data_handle = context_->GetBlobDataFromUUID(kId); EXPECT_TRUE(blob_data_handle->IsBeingBuilt()); bool built = true; @@ -782,7 +783,7 @@ std::string(kContentDisposition), std::set<std::string>()); - scoped_ptr<BlobDataHandle> blob_data_handle = + std::unique_ptr<BlobDataHandle> blob_data_handle = context_->GetBlobDataFromUUID(kId); EXPECT_TRUE(blob_data_handle->IsBeingBuilt()); bool built = true; @@ -797,7 +798,7 @@ EXPECT_EQ(IPCBlobCreationCancelCode::SOURCE_DIED_IN_TRANSIT, error_code); // Should still be there due to the handle. - scoped_ptr<BlobDataHandle> another_handle = + std::unique_ptr<BlobDataHandle> another_handle = context_->GetBlobDataFromUUID(kId); EXPECT_TRUE(another_handle); @@ -1044,7 +1045,7 @@ sink_.ClearMessages(); // Finally check that our data is correct in the child elements. - scoped_ptr<BlobDataHandle> handle = + std::unique_ptr<BlobDataHandle> handle = context_->GetBlobDataFromUUID(kDifferentHostReferencingId); ExpectHandleEqualsData(handle.get(), elements); } @@ -1152,14 +1153,15 @@ // Grab handles & add listeners. bool built = true; IPCBlobCreationCancelCode error_code = IPCBlobCreationCancelCode::UNKNOWN; - scoped_ptr<BlobDataHandle> blob_handle = context_->GetBlobDataFromUUID(kId); + std::unique_ptr<BlobDataHandle> blob_handle = + context_->GetBlobDataFromUUID(kId); blob_handle->RunOnConstructionComplete( base::Bind(&ConstructionCompletePopulator, &built, &error_code)); bool same_host_built = true; IPCBlobCreationCancelCode same_host_error_code = IPCBlobCreationCancelCode::UNKNOWN; - scoped_ptr<BlobDataHandle> same_host_blob_handle = + std::unique_ptr<BlobDataHandle> same_host_blob_handle = context_->GetBlobDataFromUUID(kSameHostReferencingId); same_host_blob_handle->RunOnConstructionComplete(base::Bind( &ConstructionCompletePopulator, &same_host_built, &same_host_error_code)); @@ -1167,7 +1169,7 @@ bool other_host_built = true; IPCBlobCreationCancelCode other_host_error_code = IPCBlobCreationCancelCode::UNKNOWN; - scoped_ptr<BlobDataHandle> other_host_blob_handle = + std::unique_ptr<BlobDataHandle> other_host_blob_handle = context_->GetBlobDataFromUUID(kDifferentHostReferencingId); other_host_blob_handle->RunOnConstructionComplete( base::Bind(&ConstructionCompletePopulator, &other_host_built,
diff --git a/content/browser/bluetooth/bluetooth_allowed_devices_map.h b/content/browser/bluetooth/bluetooth_allowed_devices_map.h index 32823593..2f585f8 100644 --- a/content/browser/bluetooth/bluetooth_allowed_devices_map.h +++ b/content/browser/bluetooth/bluetooth_allowed_devices_map.h
@@ -6,10 +6,10 @@ #define CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_ALLOWED_DEVICES_MAP_ #include <map> +#include <memory> #include <set> #include <vector> -#include "base/memory/scoped_ptr.h" #include "content/common/content_export.h" #include "url/origin.h"
diff --git a/content/browser/bluetooth/bluetooth_dispatcher_host.cc b/content/browser/bluetooth/bluetooth_dispatcher_host.cc index f8444cae..0180613 100644 --- a/content/browser/bluetooth/bluetooth_dispatcher_host.cc +++ b/content/browser/bluetooth/bluetooth_dispatcher_host.cc
@@ -208,7 +208,7 @@ } void StopDiscoverySession( - scoped_ptr<device::BluetoothDiscoverySession> discovery_session) { + std::unique_ptr<device::BluetoothDiscoverySession> discovery_session) { // Nothing goes wrong if the discovery session fails to stop, and we don't // need to wait for it before letting the user's script proceed, so we ignore // the results here. @@ -385,12 +385,12 @@ } } - scoped_ptr<device::BluetoothDiscoveryFilter> ComputeScanFilter() const { + std::unique_ptr<device::BluetoothDiscoveryFilter> ComputeScanFilter() const { std::set<BluetoothUUID> services; for (const BluetoothScanFilter& filter : filters) { services.insert(filter.services.begin(), filter.services.end()); } - scoped_ptr<device::BluetoothDiscoveryFilter> discovery_filter( + std::unique_ptr<device::BluetoothDiscoveryFilter> discovery_filter( new device::BluetoothDiscoveryFilter( device::BluetoothDiscoveryFilter::TRANSPORT_DUAL)); for (const BluetoothUUID& service : services) { @@ -405,8 +405,8 @@ const url::Origin origin; const std::vector<BluetoothScanFilter> filters; const std::vector<BluetoothUUID> optional_services; - scoped_ptr<BluetoothChooser> chooser; - scoped_ptr<device::BluetoothDiscoverySession> discovery_session; + std::unique_ptr<BluetoothChooser> chooser; + std::unique_ptr<device::BluetoothDiscoverySession> discovery_session; }; BluetoothDispatcherHost::CacheQueryResult::CacheQueryResult() {} @@ -476,7 +476,7 @@ void BluetoothDispatcherHost::ConnectedDevicesMap::InsertOrReplace( int frame_routing_id, const std::string& device_id, - scoped_ptr<device::BluetoothGattConnection> connection) { + std::unique_ptr<device::BluetoothGattConnection> connection) { auto connection_iter = device_id_to_connection_map_.find(device_id); if (connection_iter == device_id_to_connection_map_.end()) { IncrementBluetoothConnectedDeviceCount(frame_routing_id); @@ -1310,7 +1310,7 @@ void BluetoothDispatcherHost::OnDiscoverySessionStarted( int chooser_id, - scoped_ptr<device::BluetoothDiscoverySession> discovery_session) { + std::unique_ptr<device::BluetoothDiscoverySession> discovery_session) { DCHECK_CURRENTLY_ON(BrowserThread::UI); VLOG(1) << "Started discovery session for " << chooser_id; if (RequestDeviceSession* session = @@ -1472,7 +1472,7 @@ int frame_routing_id, const std::string& device_id, base::TimeTicks start_time, - scoped_ptr<device::BluetoothGattConnection> connection) { + std::unique_ptr<device::BluetoothGattConnection> connection) { DCHECK_CURRENTLY_ON(BrowserThread::UI); RecordConnectGATTTimeSuccess(base::TimeTicks::Now() - start_time); RecordConnectGATTOutcome(UMAConnectGATTOutcome::SUCCESS); @@ -1539,7 +1539,7 @@ void BluetoothDispatcherHost::OnStartNotifySessionSuccess( int thread_id, int request_id, - scoped_ptr<device::BluetoothGattNotifySession> notify_session) { + std::unique_ptr<device::BluetoothGattNotifySession> notify_session) { RecordStartNotificationsOutcome(UMAGATTOperationOutcome::SUCCESS); // Copy Characteristic Instance ID before passing scoped pointer because
diff --git a/content/browser/bluetooth/bluetooth_dispatcher_host.h b/content/browser/bluetooth/bluetooth_dispatcher_host.h index e3a4d61..d65f99d 100644 --- a/content/browser/bluetooth/bluetooth_dispatcher_host.h +++ b/content/browser/bluetooth/bluetooth_dispatcher_host.h
@@ -98,13 +98,14 @@ void InsertOrReplace( int frame_routing_id, const std::string& device_id, - scoped_ptr<device::BluetoothGattConnection> connection); + std::unique_ptr<device::BluetoothGattConnection> connection); void Remove(int frame_routing_id, const std::string& device_id); void IncrementBluetoothConnectedDeviceCount(int frame_routing_id); void DecrementBluetoothConnectedDeviceCount(int frame_routing_id); int render_process_id_; - std::unordered_map<std::string, scoped_ptr<device::BluetoothGattConnection>> + std::unordered_map<std::string, + std::unique_ptr<device::BluetoothGattConnection>> device_id_to_connection_map_; // Keeps track of which frame is connected to which device so that // we can clean up the WebContents in our destructor. @@ -207,7 +208,7 @@ // Callbacks for BluetoothAdapter::StartDiscoverySession. void OnDiscoverySessionStarted( int chooser_id, - scoped_ptr<device::BluetoothDiscoverySession> discovery_session); + std::unique_ptr<device::BluetoothDiscoverySession> discovery_session); void OnDiscoverySessionStartedError(int chooser_id); // BluetoothChooser::EventHandler: @@ -229,7 +230,7 @@ int frame_routing_id, const std::string& device_id, base::TimeTicks start_time, - scoped_ptr<device::BluetoothGattConnection> connection); + std::unique_ptr<device::BluetoothGattConnection> connection); void OnCreateGATTConnectionError( int thread_id, int request_id, @@ -257,7 +258,7 @@ void OnStartNotifySessionSuccess( int thread_id, int request_id, - scoped_ptr<device::BluetoothGattNotifySession> notify_session); + std::unique_ptr<device::BluetoothGattNotifySession> notify_session); void OnStartNotifySessionFailed( int thread_id, int request_id, @@ -320,7 +321,7 @@ // Map that matches characteristic_instance_id to notify session. // TODO(ortuno): Also key by thread_id once support for web workers, // is added: http://crbug.com/537372 - std::map<std::string, scoped_ptr<device::BluetoothGattNotifySession>> + std::map<std::string, std::unique_ptr<device::BluetoothGattNotifySession>> characteristic_id_to_notify_session_; // Map of characteristic_instance_id to a set of thread ids. @@ -342,7 +343,7 @@ base::Timer discovery_session_timer_; // Retains BluetoothGattConnection objects to keep connections open. - scoped_ptr<ConnectedDevicesMap> connected_devices_map_; + std::unique_ptr<ConnectedDevicesMap> connected_devices_map_; // Map of device_address's to primary-services requests that need responses // when that device's service discovery completes.
diff --git a/content/browser/bootstrap_sandbox_manager_mac.h b/content/browser/bootstrap_sandbox_manager_mac.h index edddde8b7..33bdad36 100644 --- a/content/browser/bootstrap_sandbox_manager_mac.h +++ b/content/browser/bootstrap_sandbox_manager_mac.h
@@ -5,8 +5,9 @@ #ifndef CONTENT_BROWSER_BOOTSTRAP_SANDBOX_MANAGER_MAC_H_ #define CONTENT_BROWSER_BOOTSTRAP_SANDBOX_MANAGER_MAC_H_ +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/singleton.h" #include "content/public/browser/browser_child_process_observer.h" #include "content/public/browser/render_process_host_observer.h" @@ -60,7 +61,7 @@ void AddBaselinePolicy(sandbox::BootstrapSandboxPolicy* policy); - scoped_ptr<sandbox::BootstrapSandbox> sandbox_; + std::unique_ptr<sandbox::BootstrapSandbox> sandbox_; DISALLOW_COPY_AND_ASSIGN(BootstrapSandboxManager); };
diff --git a/content/browser/browser_child_process_host_impl.h b/content/browser/browser_child_process_host_impl.h index 4b852e2..3a798c2 100644 --- a/content/browser/browser_child_process_host_impl.h +++ b/content/browser/browser_child_process_host_impl.h
@@ -8,9 +8,9 @@ #include <stdint.h> #include <list> +#include <memory> #include "base/compiler_specific.h" -#include "base/memory/scoped_ptr.h" #include "base/process/process.h" #include "base/synchronization/waitable_event_watcher.h" #include "build/build_config.h" @@ -118,9 +118,9 @@ ChildProcessData data_; BrowserChildProcessHostDelegate* delegate_; - scoped_ptr<ChildProcessHost> child_process_host_; + std::unique_ptr<ChildProcessHost> child_process_host_; - scoped_ptr<ChildProcessLauncher> child_process_; + std::unique_ptr<ChildProcessLauncher> child_process_; PowerMonitorMessageBroadcaster power_monitor_message_broadcaster_;
diff --git a/content/browser/browser_context.cc b/content/browser/browser_context.cc index 4b8396e..4e43792d 100644 --- a/content/browser/browser_context.cc +++ b/content/browser/browser_context.cc
@@ -123,9 +123,9 @@ // static void BrowserContext::GarbageCollectStoragePartitions( - BrowserContext* browser_context, - scoped_ptr<base::hash_set<base::FilePath> > active_paths, - const base::Closure& done) { + BrowserContext* browser_context, + std::unique_ptr<base::hash_set<base::FilePath>> active_paths, + const base::Closure& done) { GetStoragePartitionMap(browser_context) ->GarbageCollect(std::move(active_paths), done); }
diff --git a/content/browser/browser_main.cc b/content/browser/browser_main.cc index 459bde0..772010c 100644 --- a/content/browser/browser_main.cc +++ b/content/browser/browser_main.cc
@@ -4,7 +4,8 @@ #include "content/browser/browser_main.h" -#include "base/memory/scoped_ptr.h" +#include <memory> + #include "base/trace_event/trace_event.h" #include "content/common/content_constants_internal.h" #include "content/public/browser/browser_main_runner.h" @@ -36,7 +37,7 @@ base::trace_event::TraceLog::GetInstance()->SetProcessSortIndex( kTraceEventBrowserProcessSortIndex); - scoped_ptr<BrowserMainRunner> main_runner(BrowserMainRunner::Create()); + std::unique_ptr<BrowserMainRunner> main_runner(BrowserMainRunner::Create()); int exit_code = main_runner->Initialize(parameters); if (exit_code >= 0)
diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc index 175e9d6..2d968cdd 100644 --- a/content/browser/browser_main_loop.cc +++ b/content/browser/browser_main_loop.cc
@@ -5,6 +5,7 @@ #include "content/browser/browser_main_loop.h" #include <stddef.h> + #include <utility> #include "base/bind.h" @@ -14,6 +15,7 @@ #include "base/logging.h" #include "base/macros.h" #include "base/memory/memory_pressure_monitor.h" +#include "base/memory/ptr_util.h" #include "base/metrics/field_trial.h" #include "base/metrics/histogram.h" #include "base/pending_task.h" @@ -196,7 +198,7 @@ TRACE_EVENT0("startup", "SetupSandbox"); base::FilePath sandbox_binary; - scoped_ptr<sandbox::SetuidSandboxHost> setuid_sandbox_host( + std::unique_ptr<sandbox::SetuidSandboxHost> setuid_sandbox_host( sandbox::SetuidSandboxHost::Create()); const bool want_setuid_sandbox = @@ -298,45 +300,47 @@ MSVC_DISABLE_OPTIMIZE() MSVC_PUSH_DISABLE_WARNING(4748) -NOINLINE void ResetThread_DB(scoped_ptr<BrowserProcessSubThread> thread) { +NOINLINE void ResetThread_DB(std::unique_ptr<BrowserProcessSubThread> thread) { volatile int inhibit_comdat = __LINE__; ALLOW_UNUSED_LOCAL(inhibit_comdat); thread.reset(); } -NOINLINE void ResetThread_FILE(scoped_ptr<BrowserProcessSubThread> thread) { +NOINLINE void ResetThread_FILE( + std::unique_ptr<BrowserProcessSubThread> thread) { volatile int inhibit_comdat = __LINE__; ALLOW_UNUSED_LOCAL(inhibit_comdat); thread.reset(); } NOINLINE void ResetThread_FILE_USER_BLOCKING( - scoped_ptr<BrowserProcessSubThread> thread) { + std::unique_ptr<BrowserProcessSubThread> thread) { volatile int inhibit_comdat = __LINE__; ALLOW_UNUSED_LOCAL(inhibit_comdat); thread.reset(); } NOINLINE void ResetThread_PROCESS_LAUNCHER( - scoped_ptr<BrowserProcessSubThread> thread) { + std::unique_ptr<BrowserProcessSubThread> thread) { volatile int inhibit_comdat = __LINE__; ALLOW_UNUSED_LOCAL(inhibit_comdat); thread.reset(); } -NOINLINE void ResetThread_CACHE(scoped_ptr<BrowserProcessSubThread> thread) { +NOINLINE void ResetThread_CACHE( + std::unique_ptr<BrowserProcessSubThread> thread) { volatile int inhibit_comdat = __LINE__; ALLOW_UNUSED_LOCAL(inhibit_comdat); thread.reset(); } -NOINLINE void ResetThread_IO(scoped_ptr<BrowserProcessSubThread> thread) { +NOINLINE void ResetThread_IO(std::unique_ptr<BrowserProcessSubThread> thread) { volatile int inhibit_comdat = __LINE__; ALLOW_UNUSED_LOCAL(inhibit_comdat); thread.reset(); } -NOINLINE void ResetThread_IndexedDb(scoped_ptr<base::Thread> thread) { +NOINLINE void ResetThread_IndexedDb(std::unique_ptr<base::Thread> thread) { volatile int inhibit_comdat = __LINE__; ALLOW_UNUSED_LOCAL(inhibit_comdat); thread.reset(); @@ -385,7 +389,7 @@ void WillProcessTask(const base::PendingTask& pending_task) override {} void DidProcessTask(const base::PendingTask& pending_task) override { - scoped_ptr<base::ProcessMetrics> process_metrics( + std::unique_ptr<base::ProcessMetrics> process_metrics( base::ProcessMetrics::CreateCurrentProcessMetrics()); size_t private_bytes; process_metrics->GetMemoryBytes(&private_bytes, NULL); @@ -546,8 +550,8 @@ } { TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:PowerMonitor"); - scoped_ptr<base::PowerMonitorSource> power_monitor_source( - new base::PowerMonitorDeviceSource()); + std::unique_ptr<base::PowerMonitorSource> power_monitor_source( + new base::PowerMonitorDeviceSource()); power_monitor_.reset( new base::PowerMonitor(std::move(power_monitor_source))); } @@ -758,13 +762,12 @@ // First time through, we really want to create all the tasks if (!startup_task_runner_.get()) { #if defined(OS_ANDROID) - startup_task_runner_ = make_scoped_ptr( + startup_task_runner_ = base::WrapUnique( new StartupTaskRunner(base::Bind(&BrowserStartupComplete), base::ThreadTaskRunnerHandle::Get())); #else - startup_task_runner_ = make_scoped_ptr( - new StartupTaskRunner(base::Callback<void(int)>(), - base::ThreadTaskRunnerHandle::Get())); + startup_task_runner_ = base::WrapUnique(new StartupTaskRunner( + base::Callback<void(int)>(), base::ThreadTaskRunnerHandle::Get())); #endif StartupTask pre_create_threads = base::Bind(&BrowserMainLoop::PreCreateThreads, base::Unretained(this)); @@ -819,7 +822,7 @@ for (size_t thread_id = BrowserThread::UI + 1; thread_id < BrowserThread::ID_COUNT; ++thread_id) { - scoped_ptr<BrowserProcessSubThread>* thread_to_start = NULL; + std::unique_ptr<BrowserProcessSubThread>* thread_to_start = NULL; base::Thread::Options options; switch (thread_id) {
diff --git a/content/browser/browser_main_loop.h b/content/browser/browser_main_loop.h index e8a13a0..9f43d547 100644 --- a/content/browser/browser_main_loop.h +++ b/content/browser/browser_main_loop.h
@@ -5,10 +5,11 @@ #ifndef CONTENT_BROWSER_BROWSER_MAIN_LOOP_H_ #define CONTENT_BROWSER_BROWSER_MAIN_LOOP_H_ +#include <memory> + #include "base/files/file_path.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/timer/timer.h" #include "build/build_config.h" #include "content/browser/browser_process_sub_thread.h" @@ -187,30 +188,30 @@ bool is_tracing_startup_for_duration_; // Members initialized in |MainMessageLoopStart()| --------------------------- - scoped_ptr<base::MessageLoop> main_message_loop_; + std::unique_ptr<base::MessageLoop> main_message_loop_; // Members initialized in |PostMainMessageLoopStart()| ----------------------- - scoped_ptr<base::SystemMonitor> system_monitor_; - scoped_ptr<base::PowerMonitor> power_monitor_; - scoped_ptr<base::HighResolutionTimerManager> hi_res_timer_manager_; - scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; + std::unique_ptr<base::SystemMonitor> system_monitor_; + std::unique_ptr<base::PowerMonitor> power_monitor_; + std::unique_ptr<base::HighResolutionTimerManager> hi_res_timer_manager_; + std::unique_ptr<net::NetworkChangeNotifier> network_change_notifier_; // Per-process listener for online state changes. - scoped_ptr<BrowserOnlineStateObserver> online_state_observer_; + std::unique_ptr<BrowserOnlineStateObserver> online_state_observer_; - scoped_ptr<base::trace_event::TraceEventSystemStatsMonitor> + std::unique_ptr<base::trace_event::TraceEventSystemStatsMonitor> system_stats_monitor_; #if defined(OS_WIN) - scoped_ptr<ScreenOrientationDelegate> screen_orientation_delegate_; + std::unique_ptr<ScreenOrientationDelegate> screen_orientation_delegate_; #endif #if defined(OS_ANDROID) // Android implementation of ScreenOrientationDelegate - scoped_ptr<ScreenOrientationDelegate> screen_orientation_delegate_; + std::unique_ptr<ScreenOrientationDelegate> screen_orientation_delegate_; #endif - scoped_ptr<MemoryObserver> memory_observer_; + std::unique_ptr<MemoryObserver> memory_observer_; // Members initialized in |InitStartupTracingForDuration()| ------------------ base::FilePath startup_trace_file_; @@ -221,53 +222,53 @@ // Members initialized in |Init()| ------------------------------------------- // Destroy |parts_| before |main_message_loop_| (required) and before other // classes constructed in content (but after |main_thread_|). - scoped_ptr<BrowserMainParts> parts_; + std::unique_ptr<BrowserMainParts> parts_; // Members initialized in |InitializeMainThread()| --------------------------- // This must get destroyed before other threads that are created in |parts_|. - scoped_ptr<BrowserThreadImpl> main_thread_; + std::unique_ptr<BrowserThreadImpl> main_thread_; // Members initialized in |CreateStartupTasks()| ----------------------------- - scoped_ptr<StartupTaskRunner> startup_task_runner_; + std::unique_ptr<StartupTaskRunner> startup_task_runner_; // Members initialized in |PreCreateThreads()| ------------------------------- // Torn down in ShutdownThreadsAndCleanUp. - scoped_ptr<base::MemoryPressureMonitor> memory_pressure_monitor_; + std::unique_ptr<base::MemoryPressureMonitor> memory_pressure_monitor_; // Members initialized in |CreateThreads()| ---------------------------------- - scoped_ptr<BrowserProcessSubThread> db_thread_; - scoped_ptr<BrowserProcessSubThread> file_user_blocking_thread_; - scoped_ptr<BrowserProcessSubThread> file_thread_; - scoped_ptr<BrowserProcessSubThread> process_launcher_thread_; - scoped_ptr<BrowserProcessSubThread> cache_thread_; - scoped_ptr<BrowserProcessSubThread> io_thread_; + std::unique_ptr<BrowserProcessSubThread> db_thread_; + std::unique_ptr<BrowserProcessSubThread> file_user_blocking_thread_; + std::unique_ptr<BrowserProcessSubThread> file_thread_; + std::unique_ptr<BrowserProcessSubThread> process_launcher_thread_; + std::unique_ptr<BrowserProcessSubThread> cache_thread_; + std::unique_ptr<BrowserProcessSubThread> io_thread_; // Members initialized in |BrowserThreadsStarted()| -------------------------- - scoped_ptr<base::Thread> indexed_db_thread_; - scoped_ptr<MojoShellContext> mojo_shell_context_; - scoped_ptr<IPC::ScopedIPCSupport> mojo_ipc_support_; + std::unique_ptr<base::Thread> indexed_db_thread_; + std::unique_ptr<MojoShellContext> mojo_shell_context_; + std::unique_ptr<IPC::ScopedIPCSupport> mojo_ipc_support_; // |user_input_monitor_| has to outlive |audio_manager_|, so declared first. - scoped_ptr<media::UserInputMonitor> user_input_monitor_; - scoped_ptr<media::AudioManager> audio_manager_; + std::unique_ptr<media::UserInputMonitor> user_input_monitor_; + std::unique_ptr<media::AudioManager> audio_manager_; - scoped_ptr<media::midi::MidiManager> midi_manager_; + std::unique_ptr<media::midi::MidiManager> midi_manager_; #if defined(OS_WIN) - scoped_ptr<media::SystemMessageWindowWin> system_message_window_; + std::unique_ptr<media::SystemMessageWindowWin> system_message_window_; #elif defined(OS_LINUX) && defined(USE_UDEV) - scoped_ptr<media::DeviceMonitorLinux> device_monitor_linux_; + std::unique_ptr<media::DeviceMonitorLinux> device_monitor_linux_; #elif defined(OS_MACOSX) && !defined(OS_IOS) - scoped_ptr<media::DeviceMonitorMac> device_monitor_mac_; + std::unique_ptr<media::DeviceMonitorMac> device_monitor_mac_; #endif #if defined(USE_OZONE) - scoped_ptr<ui::ClientNativePixmapFactory> client_native_pixmap_factory_; + std::unique_ptr<ui::ClientNativePixmapFactory> client_native_pixmap_factory_; #endif - scoped_ptr<ResourceDispatcherHostImpl> resource_dispatcher_host_; - scoped_ptr<MediaStreamManager> media_stream_manager_; - scoped_ptr<SpeechRecognitionManagerImpl> speech_recognition_manager_; - scoped_ptr<TimeZoneMonitor> time_zone_monitor_; + std::unique_ptr<ResourceDispatcherHostImpl> resource_dispatcher_host_; + std::unique_ptr<MediaStreamManager> media_stream_manager_; + std::unique_ptr<SpeechRecognitionManagerImpl> speech_recognition_manager_; + std::unique_ptr<TimeZoneMonitor> time_zone_monitor_; // DO NOT add members here. Add them to the right categories above.
diff --git a/content/browser/browser_main_runner.cc b/content/browser/browser_main_runner.cc index de130940..96a3454 100644 --- a/content/browser/browser_main_runner.cc +++ b/content/browser/browser_main_runner.cc
@@ -172,7 +172,7 @@ // There are two cases: // 1. Startup duration is not reached. // 2. Or startup duration is not specified for --trace-config-file flag. - scoped_ptr<BrowserShutdownProfileDumper> startup_profiler; + std::unique_ptr<BrowserShutdownProfileDumper> startup_profiler; if (main_loop_->is_tracing_startup_for_duration()) { main_loop_->StopStartupTracingTimer(); if (main_loop_->startup_trace_file() != @@ -196,7 +196,7 @@ // which will dump the traces to disc when it gets destroyed. const base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); - scoped_ptr<BrowserShutdownProfileDumper> shutdown_profiler; + std::unique_ptr<BrowserShutdownProfileDumper> shutdown_profiler; if (command_line.HasSwitch(switches::kTraceShutdown)) { shutdown_profiler.reset(new BrowserShutdownProfileDumper( BrowserShutdownProfileDumper::GetShutdownProfileFileName())); @@ -235,10 +235,10 @@ // True if the runner has been shut down. bool is_shutdown_; - scoped_ptr<NotificationServiceImpl> notification_service_; - scoped_ptr<BrowserMainLoop> main_loop_; + std::unique_ptr<NotificationServiceImpl> notification_service_; + std::unique_ptr<BrowserMainLoop> main_loop_; #if defined(OS_WIN) - scoped_ptr<ui::ScopedOleInitializer> ole_initializer_; + std::unique_ptr<ui::ScopedOleInitializer> ole_initializer_; #endif private:
diff --git a/content/browser/browser_plugin/browser_plugin_guest.cc b/content/browser/browser_plugin/browser_plugin_guest.cc index ad4474f..fa72b21 100644 --- a/content/browser/browser_plugin/browser_plugin_guest.cc +++ b/content/browser/browser_plugin/browser_plugin_guest.cc
@@ -556,7 +556,7 @@ if (!browser_plugin_instance_id()) return msg; - scoped_ptr<IPC::Message> new_msg( + std::unique_ptr<IPC::Message> new_msg( new IPC::Message(msg->routing_id(), msg->type(), msg->priority())); new_msg->WriteInt(browser_plugin_instance_id());
diff --git a/content/browser/browser_plugin/browser_plugin_guest.h b/content/browser/browser_plugin/browser_plugin_guest.h index 9158709..8313f0f 100644 --- a/content/browser/browser_plugin/browser_plugin_guest.h +++ b/content/browser/browser_plugin/browser_plugin_guest.h
@@ -386,7 +386,7 @@ // The last tooltip that was set with SetTooltipText(). base::string16 current_tooltip_text_; - scoped_ptr<EmbedderVisibilityObserver> embedder_visibility_observer_; + std::unique_ptr<EmbedderVisibilityObserver> embedder_visibility_observer_; WebContentsImpl* owner_web_contents_; // Indicates whether this guest has been attached to a container. @@ -425,7 +425,7 @@ // Text input type states. // Using scoped_ptr to avoid including the header file: view_messages.h. - scoped_ptr<const TextInputState> last_text_input_state_; + std::unique_ptr<const TextInputState> last_text_input_state_; // The is the routing ID for a swapped out RenderView for the guest // WebContents in the embedder's process.
diff --git a/content/browser/browser_process_sub_thread.h b/content/browser/browser_process_sub_thread.h index aded0cb..65d73ea 100644 --- a/content/browser/browser_process_sub_thread.h +++ b/content/browser/browser_process_sub_thread.h
@@ -5,8 +5,9 @@ #ifndef CONTENT_BROWSER_BROWSER_PROCESS_SUB_THREAD_H_ #define CONTENT_BROWSER_BROWSER_PROCESS_SUB_THREAD_H_ +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "build/build_config.h" #include "content/browser/browser_thread_impl.h" #include "content/common/content_export.h" @@ -49,11 +50,11 @@ void IOThreadPreCleanUp(); #if defined (OS_WIN) - scoped_ptr<base::win::ScopedCOMInitializer> com_initializer_; + std::unique_ptr<base::win::ScopedCOMInitializer> com_initializer_; #endif // Each specialized thread has its own notification service. - scoped_ptr<NotificationService> notification_service_; + std::unique_ptr<NotificationService> notification_service_; DISALLOW_COPY_AND_ASSIGN(BrowserProcessSubThread); };
diff --git a/content/browser/browser_thread_unittest.cc b/content/browser/browser_thread_unittest.cc index 1c622c2..b54e20e4 100644 --- a/content/browser/browser_thread_unittest.cc +++ b/content/browser/browser_thread_unittest.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 <memory> + #include "base/bind.h" #include "base/bind_helpers.h" #include "base/location.h" -#include "base/memory/scoped_ptr.h" #include "base/sequenced_task_runner_helpers.h" #include "base/single_thread_task_runner.h" #include "content/browser/browser_thread_impl.h" @@ -63,8 +64,8 @@ }; private: - scoped_ptr<BrowserThreadImpl> ui_thread_; - scoped_ptr<BrowserThreadImpl> file_thread_; + std::unique_ptr<BrowserThreadImpl> ui_thread_; + std::unique_ptr<BrowserThreadImpl> file_thread_; // It's kind of ugly to make this mutable - solely so we can post the Quit // Task from Release(). This should be fixed. mutable base::MessageLoop loop_;
diff --git a/content/browser/byte_stream.cc b/content/browser/byte_stream.cc index 0a8939e..1c70739 100644 --- a/content/browser/byte_stream.cc +++ b/content/browser/byte_stream.cc
@@ -126,21 +126,19 @@ // static because it may be called after the object it is targeting // has been destroyed. It may not access |*target| // if |*object_lifetime_flag| is false. - static void TransferData( - scoped_refptr<LifetimeFlag> object_lifetime_flag, - ByteStreamReaderImpl* target, - scoped_ptr<ContentVector> transfer_buffer, - size_t transfer_buffer_bytes, - bool source_complete, - int status); + static void TransferData(scoped_refptr<LifetimeFlag> object_lifetime_flag, + ByteStreamReaderImpl* target, + std::unique_ptr<ContentVector> transfer_buffer, + size_t transfer_buffer_bytes, + bool source_complete, + int status); private: // Called from TransferData once object existence has been validated. - void TransferDataInternal( - scoped_ptr<ContentVector> transfer_buffer, - size_t transfer_buffer_bytes, - bool source_complete, - int status); + void TransferDataInternal(std::unique_ptr<ContentVector> transfer_buffer, + size_t transfer_buffer_bytes, + bool source_complete, + int status); void MaybeUpdateInput(); @@ -289,7 +287,7 @@ // Valid contexts in which to call. DCHECK(complete || 0 != input_contents_size_); - scoped_ptr<ContentVector> transfer_buffer; + std::unique_ptr<ContentVector> transfer_buffer; size_t buffer_size = 0; if (0 != input_contents_size_) { transfer_buffer.reset(new ContentVector); @@ -377,7 +375,7 @@ void ByteStreamReaderImpl::TransferData( scoped_refptr<LifetimeFlag> object_lifetime_flag, ByteStreamReaderImpl* target, - scoped_ptr<ContentVector> transfer_buffer, + std::unique_ptr<ContentVector> transfer_buffer, size_t buffer_size, bool source_complete, int status) { @@ -389,7 +387,7 @@ } void ByteStreamReaderImpl::TransferDataInternal( - scoped_ptr<ContentVector> transfer_buffer, + std::unique_ptr<ContentVector> transfer_buffer, size_t buffer_size, bool source_complete, int status) { @@ -448,8 +446,8 @@ scoped_refptr<base::SequencedTaskRunner> input_task_runner, scoped_refptr<base::SequencedTaskRunner> output_task_runner, size_t buffer_size, - scoped_ptr<ByteStreamWriter>* input, - scoped_ptr<ByteStreamReader>* output) { + std::unique_ptr<ByteStreamWriter>* input, + std::unique_ptr<ByteStreamReader>* output) { scoped_refptr<LifetimeFlag> input_flag(new LifetimeFlag()); scoped_refptr<LifetimeFlag> output_flag(new LifetimeFlag());
diff --git a/content/browser/byte_stream.h b/content/browser/byte_stream.h index 8590645..1a86c723 100644 --- a/content/browser/byte_stream.h +++ b/content/browser/byte_stream.h
@@ -7,9 +7,10 @@ #include <stddef.h> +#include <memory> + #include "base/callback.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "content/common/content_export.h" #include "net/base/io_buffer.h" @@ -62,8 +63,8 @@ // // void OriginatingClass::Initialize() { // // Create a stream for sending bytes from IO->FILE threads. -// scoped_ptr<ByteStreamWriter> writer; -// scoped_ptr<ByteStreamReader> reader; +// std::unique_ptr<ByteStreamWriter> writer; +// std::unique_ptr<ByteStreamReader> reader; // CreateByteStream( // BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), // BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), @@ -82,7 +83,7 @@ // // thread. // void OriginatingClass::SpaceAvailable() { // while (<data available>) { -// scoped_ptr<net::IOBuffer> buffer; +// std::unique_ptr<net::IOBuffer> buffer; // size_t buffer_length; // // Create IOBuffer, fill in with data, and set buffer_length. // if (!writer->Write(buffer, buffer_length)) { @@ -197,8 +198,8 @@ scoped_refptr<base::SequencedTaskRunner> input_task_runner, scoped_refptr<base::SequencedTaskRunner> output_task_runner, size_t buffer_size, - scoped_ptr<ByteStreamWriter>* input, - scoped_ptr<ByteStreamReader>* output); + std::unique_ptr<ByteStreamWriter>* input, + std::unique_ptr<ByteStreamReader>* output); } // namespace content
diff --git a/content/browser/byte_stream_unittest.cc b/content/browser/byte_stream_unittest.cc index 4c348b7..6b6db42 100644 --- a/content/browser/byte_stream_unittest.cc +++ b/content/browser/byte_stream_unittest.cc
@@ -103,8 +103,8 @@ // Confirm that filling and emptying the stream works properly, and that // we get full triggers when we expect. TEST_F(ByteStreamTest, ByteStream_PushBack) { - scoped_ptr<ByteStreamWriter> byte_stream_input; - scoped_ptr<ByteStreamReader> byte_stream_output; + std::unique_ptr<ByteStreamWriter> byte_stream_input; + std::unique_ptr<ByteStreamReader> byte_stream_output; CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(), 3 * 1024, &byte_stream_input, &byte_stream_output); @@ -157,8 +157,8 @@ // Confirm that Flush() method makes the writer to send written contents to // the reader. TEST_F(ByteStreamTest, ByteStream_Flush) { - scoped_ptr<ByteStreamWriter> byte_stream_input; - scoped_ptr<ByteStreamReader> byte_stream_output; + std::unique_ptr<ByteStreamWriter> byte_stream_input; + std::unique_ptr<ByteStreamReader> byte_stream_output; CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(), 1024, &byte_stream_input, &byte_stream_output); @@ -196,8 +196,8 @@ // that we're getting pushback even when data's split across the two // objects TEST_F(ByteStreamTest, ByteStream_PushBackSplit) { - scoped_ptr<ByteStreamWriter> byte_stream_input; - scoped_ptr<ByteStreamReader> byte_stream_output; + std::unique_ptr<ByteStreamWriter> byte_stream_input; + std::unique_ptr<ByteStreamReader> byte_stream_output; CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(), 9 * 1024, &byte_stream_input, &byte_stream_output); @@ -245,8 +245,8 @@ // Confirm that a Close() notification transmits in-order // with data on the stream. TEST_F(ByteStreamTest, ByteStream_CompleteTransmits) { - scoped_ptr<ByteStreamWriter> byte_stream_input; - scoped_ptr<ByteStreamReader> byte_stream_output; + std::unique_ptr<ByteStreamWriter> byte_stream_input; + std::unique_ptr<ByteStreamReader> byte_stream_output; scoped_refptr<net::IOBuffer> output_io_buffer; size_t output_length; @@ -311,8 +311,8 @@ scoped_refptr<base::TestSimpleTaskRunner> task_runner( new base::TestSimpleTaskRunner()); - scoped_ptr<ByteStreamWriter> byte_stream_input; - scoped_ptr<ByteStreamReader> byte_stream_output; + std::unique_ptr<ByteStreamWriter> byte_stream_input; + std::unique_ptr<ByteStreamReader> byte_stream_output; CreateByteStream(message_loop_.task_runner(), task_runner, 10000, &byte_stream_input, &byte_stream_output); @@ -362,8 +362,8 @@ scoped_refptr<base::TestSimpleTaskRunner> task_runner( new base::TestSimpleTaskRunner()); - scoped_ptr<ByteStreamWriter> byte_stream_input; - scoped_ptr<ByteStreamReader> byte_stream_output; + std::unique_ptr<ByteStreamWriter> byte_stream_input; + std::unique_ptr<ByteStreamReader> byte_stream_output; CreateByteStream(task_runner, message_loop_.task_runner(), 10000, &byte_stream_input, &byte_stream_output); @@ -423,8 +423,8 @@ scoped_refptr<base::TestSimpleTaskRunner> task_runner( new base::TestSimpleTaskRunner()); - scoped_ptr<ByteStreamWriter> byte_stream_input; - scoped_ptr<ByteStreamReader> byte_stream_output; + std::unique_ptr<ByteStreamWriter> byte_stream_input; + std::unique_ptr<ByteStreamReader> byte_stream_output; CreateByteStream(message_loop_.task_runner(), task_runner, 10000, &byte_stream_input, &byte_stream_output); @@ -469,8 +469,8 @@ scoped_refptr<base::TestSimpleTaskRunner> task_runner( new base::TestSimpleTaskRunner()); - scoped_ptr<ByteStreamWriter> byte_stream_input; - scoped_ptr<ByteStreamReader> byte_stream_output; + std::unique_ptr<ByteStreamWriter> byte_stream_input; + std::unique_ptr<ByteStreamReader> byte_stream_output; CreateByteStream(task_runner, message_loop_.task_runner(), 10000, &byte_stream_input, &byte_stream_output); @@ -520,8 +520,8 @@ scoped_refptr<base::TestSimpleTaskRunner> task_runner( new base::TestSimpleTaskRunner()); - scoped_ptr<ByteStreamWriter> byte_stream_input; - scoped_ptr<ByteStreamReader> byte_stream_output; + std::unique_ptr<ByteStreamWriter> byte_stream_input; + std::unique_ptr<ByteStreamReader> byte_stream_output; CreateByteStream(message_loop_.task_runner(), task_runner, 10000, &byte_stream_input, &byte_stream_output); @@ -539,8 +539,8 @@ } TEST_F(ByteStreamTest, ByteStream_CloseWithoutAnyWrite) { - scoped_ptr<ByteStreamWriter> byte_stream_input; - scoped_ptr<ByteStreamReader> byte_stream_output; + std::unique_ptr<ByteStreamWriter> byte_stream_input; + std::unique_ptr<ByteStreamReader> byte_stream_output; CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(), 3 * 1024, &byte_stream_input, &byte_stream_output); @@ -554,8 +554,8 @@ } TEST_F(ByteStreamTest, ByteStream_FlushWithoutAnyWrite) { - scoped_ptr<ByteStreamWriter> byte_stream_input; - scoped_ptr<ByteStreamReader> byte_stream_output; + std::unique_ptr<ByteStreamWriter> byte_stream_input; + std::unique_ptr<ByteStreamReader> byte_stream_output; CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(), 3 * 1024, &byte_stream_input, &byte_stream_output); @@ -575,8 +575,8 @@ } TEST_F(ByteStreamTest, ByteStream_WriteOverflow) { - scoped_ptr<ByteStreamWriter> byte_stream_input; - scoped_ptr<ByteStreamReader> byte_stream_output; + std::unique_ptr<ByteStreamWriter> byte_stream_input; + std::unique_ptr<ByteStreamReader> byte_stream_output; CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(), std::numeric_limits<size_t>::max(), &byte_stream_input, &byte_stream_output);
diff --git a/content/browser/cache_storage/cache_storage.cc b/content/browser/cache_storage/cache_storage.cc index c5a7b1ef..fa3251f 100644 --- a/content/browser/cache_storage/cache_storage.cc +++ b/content/browser/cache_storage/cache_storage.cc
@@ -5,6 +5,7 @@ #include "content/browser/cache_storage/cache_storage.h" #include <stddef.h> + #include <set> #include <string> #include <utility> @@ -14,6 +15,7 @@ #include "base/files/memory_mapped_file.h" #include "base/guid.h" #include "base/location.h" +#include "base/memory/ptr_util.h" #include "base/memory/ref_counted.h" #include "base/metrics/histogram_macros.h" #include "base/numerics/safe_conversions.h" @@ -54,7 +56,7 @@ closure.Run(); } -void SizeRetrievedFromAllCaches(scoped_ptr<int64_t> accumulator, +void SizeRetrievedFromAllCaches(std::unique_ptr<int64_t> accumulator, const CacheStorage::SizeCallback& callback) { base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(callback, *accumulator)); @@ -69,8 +71,8 @@ ~CacheMatchResponse() = default; CacheStorageError error; - scoped_ptr<ServiceWorkerResponse> service_worker_response; - scoped_ptr<storage::BlobDataHandle> blob_data_handle; + std::unique_ptr<ServiceWorkerResponse> service_worker_response; + std::unique_ptr<storage::BlobDataHandle> blob_data_handle; }; // Handles the loading and clean up of CacheStorageCache objects. @@ -78,7 +80,7 @@ public: typedef base::Callback<void(scoped_refptr<CacheStorageCache>)> CacheCallback; typedef base::Callback<void(bool)> BoolCallback; - typedef base::Callback<void(scoped_ptr<std::vector<std::string>>)> + typedef base::Callback<void(std::unique_ptr<std::vector<std::string>>)> StringVectorCallback; CacheLoader( @@ -116,7 +118,7 @@ const BoolCallback& callback) = 0; // Loads the cache names from disk if applicable. - virtual void LoadIndex(scoped_ptr<std::vector<std::string>> cache_names, + virtual void LoadIndex(std::unique_ptr<std::vector<std::string>> cache_names, const StringVectorCallback& callback) = 0; protected: @@ -174,7 +176,7 @@ callback.Run(false); } - void LoadIndex(scoped_ptr<std::vector<std::string>> cache_names, + void LoadIndex(std::unique_ptr<std::vector<std::string>> cache_names, const StringVectorCallback& callback) override { callback.Run(std::move(cache_names)); } @@ -323,7 +325,7 @@ return base::ReplaceFile(tmp_path, index_path, NULL); } - void LoadIndex(scoped_ptr<std::vector<std::string>> names, + void LoadIndex(std::unique_ptr<std::vector<std::string>> names, const StringVectorCallback& callback) override { DCHECK_CURRENTLY_ON(BrowserThread::IO); @@ -341,12 +343,13 @@ callback)); } - void LoadIndexDidReadFile(scoped_ptr<std::vector<std::string>> names, + void LoadIndexDidReadFile(std::unique_ptr<std::vector<std::string>> names, const StringVectorCallback& callback, const std::string& serialized) { DCHECK_CURRENTLY_ON(BrowserThread::IO); - scoped_ptr<std::set<std::string>> cache_dirs(new std::set<std::string>); + std::unique_ptr<std::set<std::string>> cache_dirs( + new std::set<std::string>); CacheStorageIndex index; if (index.ParseFromString(serialized)) { @@ -373,7 +376,7 @@ // |cache_dirs|. Runs on cache_task_runner_ static void DeleteUnreferencedCachesInPool( const base::FilePath& cache_base_dir, - scoped_ptr<std::set<std::string>> cache_dirs) { + std::unique_ptr<std::set<std::string>> cache_dirs) { base::FileEnumerator file_enum(cache_base_dir, false /* recursive */, base::FileEnumerator::DIRECTORIES); std::vector<base::FilePath> dirs_to_delete; @@ -561,7 +564,7 @@ void CacheStorage::MatchCache( const std::string& cache_name, - scoped_ptr<ServiceWorkerFetchRequest> request, + std::unique_ptr<ServiceWorkerFetchRequest> request, const CacheStorageCache::ResponseCallback& callback) { DCHECK_CURRENTLY_ON(BrowserThread::IO); @@ -581,7 +584,7 @@ } void CacheStorage::MatchAllCaches( - scoped_ptr<ServiceWorkerFetchRequest> request, + std::unique_ptr<ServiceWorkerFetchRequest> request, const CacheStorageCache::ResponseCallback& callback) { DCHECK_CURRENTLY_ON(BrowserThread::IO); @@ -660,7 +663,7 @@ // 3. Once each load is complete, update the map variables. // 4. Call the list of waiting callbacks. - scoped_ptr<std::vector<std::string>> indexed_cache_names( + std::unique_ptr<std::vector<std::string>> indexed_cache_names( new std::vector<std::string>()); cache_loader_->LoadIndex(std::move(indexed_cache_names), @@ -669,7 +672,7 @@ } void CacheStorage::LazyInitDidLoadIndex( - scoped_ptr<std::vector<std::string>> indexed_cache_names) { + std::unique_ptr<std::vector<std::string>> indexed_cache_names) { DCHECK_CURRENTLY_ON(BrowserThread::IO); for (size_t i = 0u, max = indexed_cache_names->size(); i < max; ++i) { @@ -805,14 +808,14 @@ void CacheStorage::MatchCacheImpl( const std::string& cache_name, - scoped_ptr<ServiceWorkerFetchRequest> request, + std::unique_ptr<ServiceWorkerFetchRequest> request, const CacheStorageCache::ResponseCallback& callback) { scoped_refptr<CacheStorageCache> cache = GetLoadedCache(cache_name); if (!cache.get()) { callback.Run(CACHE_STORAGE_ERROR_CACHE_NAME_NOT_FOUND, - scoped_ptr<ServiceWorkerResponse>(), - scoped_ptr<storage::BlobDataHandle>()); + std::unique_ptr<ServiceWorkerResponse>(), + std::unique_ptr<storage::BlobDataHandle>()); return; } @@ -827,13 +830,13 @@ scoped_refptr<CacheStorageCache> cache, const CacheStorageCache::ResponseCallback& callback, CacheStorageError error, - scoped_ptr<ServiceWorkerResponse> response, - scoped_ptr<storage::BlobDataHandle> handle) { + std::unique_ptr<ServiceWorkerResponse> response, + std::unique_ptr<storage::BlobDataHandle> handle) { callback.Run(error, std::move(response), std::move(handle)); } void CacheStorage::MatchAllCachesImpl( - scoped_ptr<ServiceWorkerFetchRequest> request, + std::unique_ptr<ServiceWorkerFetchRequest> request, const CacheStorageCache::ResponseCallback& callback) { std::vector<CacheMatchResponse>* match_responses = new std::vector<CacheMatchResponse>(ordered_cache_names_.size()); @@ -842,14 +845,14 @@ ordered_cache_names_.size(), base::Bind(&CacheStorage::MatchAllCachesDidMatchAll, weak_factory_.GetWeakPtr(), - base::Passed(make_scoped_ptr(match_responses)), callback)); + base::Passed(base::WrapUnique(match_responses)), callback)); for (size_t i = 0, max = ordered_cache_names_.size(); i < max; ++i) { scoped_refptr<CacheStorageCache> cache = GetLoadedCache(ordered_cache_names_[i]); DCHECK(cache.get()); - cache->Match(make_scoped_ptr(new ServiceWorkerFetchRequest(*request)), + cache->Match(base::WrapUnique(new ServiceWorkerFetchRequest(*request)), base::Bind(&CacheStorage::MatchAllCachesDidMatch, weak_factory_.GetWeakPtr(), cache, &match_responses->at(i), barrier_closure)); @@ -861,8 +864,8 @@ CacheMatchResponse* out_match_response, const base::Closure& barrier_closure, CacheStorageError error, - scoped_ptr<ServiceWorkerResponse> service_worker_response, - scoped_ptr<storage::BlobDataHandle> handle) { + std::unique_ptr<ServiceWorkerResponse> service_worker_response, + std::unique_ptr<storage::BlobDataHandle> handle) { out_match_response->error = error; out_match_response->service_worker_response = std::move(service_worker_response); @@ -871,7 +874,7 @@ } void CacheStorage::MatchAllCachesDidMatchAll( - scoped_ptr<std::vector<CacheMatchResponse>> match_responses, + std::unique_ptr<std::vector<CacheMatchResponse>> match_responses, const CacheStorageCache::ResponseCallback& callback) { for (CacheMatchResponse& match_response : *match_responses) { if (match_response.error == CACHE_STORAGE_ERROR_NOT_FOUND) @@ -882,8 +885,8 @@ return; } callback.Run(CACHE_STORAGE_ERROR_NOT_FOUND, - scoped_ptr<ServiceWorkerResponse>(), - scoped_ptr<storage::BlobDataHandle>()); + std::unique_ptr<ServiceWorkerResponse>(), + std::unique_ptr<storage::BlobDataHandle>()); } scoped_refptr<CacheStorageCache> CacheStorage::GetLoadedCache( @@ -940,7 +943,7 @@ DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK(initialized_); - scoped_ptr<int64_t> accumulator(new int64_t(0)); + std::unique_ptr<int64_t> accumulator(new int64_t(0)); int64_t* accumulator_ptr = accumulator.get(); base::Closure barrier_closure = base::BarrierClosure( @@ -959,7 +962,7 @@ DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK(initialized_); - scoped_ptr<int64_t> accumulator(new int64_t(0)); + std::unique_ptr<int64_t> accumulator(new int64_t(0)); int64_t* accumulator_ptr = accumulator.get(); base::Closure barrier_closure = base::BarrierClosure( @@ -1018,8 +1021,8 @@ void CacheStorage::PendingResponseCallback( const CacheStorageCache::ResponseCallback& callback, CacheStorageError error, - scoped_ptr<ServiceWorkerResponse> response, - scoped_ptr<storage::BlobDataHandle> blob_data_handle) { + std::unique_ptr<ServiceWorkerResponse> response, + std::unique_ptr<storage::BlobDataHandle> blob_data_handle) { base::WeakPtr<CacheStorage> cache_storage = weak_factory_.GetWeakPtr(); callback.Run(error, std::move(response), std::move(blob_data_handle));
diff --git a/content/browser/cache_storage/cache_storage.h b/content/browser/cache_storage/cache_storage.h index e81dd2f..b8d1e47 100644 --- a/content/browser/cache_storage/cache_storage.h +++ b/content/browser/cache_storage/cache_storage.h
@@ -82,14 +82,14 @@ // Calls match on the cache with the given |cache_name|. void MatchCache(const std::string& cache_name, - scoped_ptr<ServiceWorkerFetchRequest> request, + std::unique_ptr<ServiceWorkerFetchRequest> request, const CacheStorageCache::ResponseCallback& callback); // Calls match on all of the caches in parallel, calling |callback| with the // response from the first cache (in order of cache creation) to have the // entry. If no response is found then |callback| is called with // CACHE_STORAGE_ERROR_NOT_FOUND. - void MatchAllCaches(scoped_ptr<ServiceWorkerFetchRequest> request, + void MatchAllCaches(std::unique_ptr<ServiceWorkerFetchRequest> request, const CacheStorageCache::ResponseCallback& callback); // Sums the sizes of each cache and closes them. Runs |callback| with the @@ -129,7 +129,7 @@ void LazyInit(); void LazyInitImpl(); void LazyInitDidLoadIndex( - scoped_ptr<std::vector<std::string>> indexed_cache_names); + std::unique_ptr<std::vector<std::string>> indexed_cache_names); // The Open and CreateCache callbacks are below. void OpenCacheImpl(const std::string& cache_name, @@ -166,26 +166,26 @@ // The MatchCache callbacks are below. void MatchCacheImpl(const std::string& cache_name, - scoped_ptr<ServiceWorkerFetchRequest> request, + std::unique_ptr<ServiceWorkerFetchRequest> request, const CacheStorageCache::ResponseCallback& callback); void MatchCacheDidMatch(scoped_refptr<CacheStorageCache> cache, const CacheStorageCache::ResponseCallback& callback, CacheStorageError error, - scoped_ptr<ServiceWorkerResponse> response, - scoped_ptr<storage::BlobDataHandle> handle); + std::unique_ptr<ServiceWorkerResponse> response, + std::unique_ptr<storage::BlobDataHandle> handle); // The MatchAllCaches callbacks are below. - void MatchAllCachesImpl(scoped_ptr<ServiceWorkerFetchRequest> request, + void MatchAllCachesImpl(std::unique_ptr<ServiceWorkerFetchRequest> request, const CacheStorageCache::ResponseCallback& callback); void MatchAllCachesDidMatch( scoped_refptr<CacheStorageCache> cache, CacheMatchResponse* out_match_response, const base::Closure& barrier_closure, CacheStorageError error, - scoped_ptr<ServiceWorkerResponse> service_worker_response, - scoped_ptr<storage::BlobDataHandle> handle); + std::unique_ptr<ServiceWorkerResponse> service_worker_response, + std::unique_ptr<storage::BlobDataHandle> handle); void MatchAllCachesDidMatchAll( - scoped_ptr<std::vector<CacheMatchResponse>> match_responses, + std::unique_ptr<std::vector<CacheMatchResponse>> match_responses, const CacheStorageCache::ResponseCallback& callback); void GetSizeThenCloseAllCachesImpl(const SizeCallback& callback); @@ -205,8 +205,8 @@ void PendingResponseCallback( const CacheStorageCache::ResponseCallback& callback, CacheStorageError error, - scoped_ptr<ServiceWorkerResponse> response, - scoped_ptr<storage::BlobDataHandle> blob_data_handle); + std::unique_ptr<ServiceWorkerResponse> response, + std::unique_ptr<storage::BlobDataHandle> blob_data_handle); void PendingSizeCallback(const SizeCallback& callback, int64_t size); @@ -215,7 +215,7 @@ bool initializing_; // The pending operation scheduler. - scoped_ptr<CacheStorageScheduler> scheduler_; + std::unique_ptr<CacheStorageScheduler> scheduler_; // The map of cache names to CacheStorageCache objects. CacheMap cache_map_; @@ -233,7 +233,7 @@ bool memory_only_; // Performs backend specific operations (memory vs disk). - scoped_ptr<CacheLoader> cache_loader_; + std::unique_ptr<CacheLoader> cache_loader_; // Holds ref pointers to recently opened caches so that they can be reused // without having the open the cache again.
diff --git a/content/browser/cache_storage/cache_storage_blob_to_disk_cache.cc b/content/browser/cache_storage/cache_storage_blob_to_disk_cache.cc index bc58008..a61cc7c 100644 --- a/content/browser/cache_storage/cache_storage_blob_to_disk_cache.cc +++ b/content/browser/cache_storage/cache_storage_blob_to_disk_cache.cc
@@ -33,7 +33,7 @@ disk_cache::ScopedEntryPtr entry, int disk_cache_body_index, net::URLRequestContextGetter* request_context_getter, - scoped_ptr<storage::BlobDataHandle> blob_data_handle, + std::unique_ptr<storage::BlobDataHandle> blob_data_handle, const EntryAndBoolCallback& callback) { DCHECK(entry); DCHECK_LE(0, disk_cache_body_index);
diff --git a/content/browser/cache_storage/cache_storage_blob_to_disk_cache.h b/content/browser/cache_storage/cache_storage_blob_to_disk_cache.h index 3f73f25..6317d107 100644 --- a/content/browser/cache_storage/cache_storage_blob_to_disk_cache.h +++ b/content/browser/cache_storage/cache_storage_blob_to_disk_cache.h
@@ -5,10 +5,11 @@ #ifndef CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_BLOB_TO_DISK_CACHE_H_ #define CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_BLOB_TO_DISK_CACHE_H_ +#include <memory> + #include "base/callback.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "content/common/content_export.h" #include "net/disk_cache/disk_cache.h" @@ -43,11 +44,12 @@ // Writes the body of |blob_data_handle| to |entry| with index // |disk_cache_body_index|. |entry| is passed to the callback once complete. // Only call this once per instantiation of CacheStorageBlobToDiskCache. - void StreamBlobToCache(disk_cache::ScopedEntryPtr entry, - int disk_cache_body_index, - net::URLRequestContextGetter* request_context_getter, - scoped_ptr<storage::BlobDataHandle> blob_data_handle, - const EntryAndBoolCallback& callback); + void StreamBlobToCache( + disk_cache::ScopedEntryPtr entry, + int disk_cache_body_index, + net::URLRequestContextGetter* request_context_getter, + std::unique_ptr<storage::BlobDataHandle> blob_data_handle, + const EntryAndBoolCallback& callback); // net::URLRequest::Delegate overrides for reading blobs. void OnResponseStarted(net::URLRequest* request) override; @@ -84,7 +86,7 @@ net::URLRequestContextGetter* request_context_getter_; int disk_cache_body_index_; - scoped_ptr<net::URLRequest> blob_request_; + std::unique_ptr<net::URLRequest> blob_request_; EntryAndBoolCallback callback_; scoped_refptr<net::IOBufferWithSize> buffer_;
diff --git a/content/browser/cache_storage/cache_storage_blob_to_disk_cache_unittest.cc b/content/browser/cache_storage/cache_storage_blob_to_disk_cache_unittest.cc index 5734e0d..656a4bc1 100644 --- a/content/browser/cache_storage/cache_storage_blob_to_disk_cache_unittest.cc +++ b/content/browser/cache_storage/cache_storage_blob_to_disk_cache_unittest.cc
@@ -9,6 +9,7 @@ #include "base/files/file_path.h" #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/run_loop.h" #include "base/test/null_task_runner.h" #include "base/thread_task_runner_handle.h" @@ -56,11 +57,11 @@ // Returns a BlobProtocolHandler that uses |blob_storage_context|. Caller owns // the memory. -scoped_ptr<storage::BlobProtocolHandler> CreateMockBlobProtocolHandler( +std::unique_ptr<storage::BlobProtocolHandler> CreateMockBlobProtocolHandler( storage::BlobStorageContext* blob_storage_context) { // The FileSystemContext and thread task runner are not actually used but a // task runner is needed to avoid a DCHECK in BlobURLRequestJob ctor. - return make_scoped_ptr(new storage::BlobProtocolHandler( + return base::WrapUnique(new storage::BlobProtocolHandler( blob_storage_context, nullptr, base::ThreadTaskRunnerHandle::Get().get())); } @@ -128,7 +129,7 @@ } void InitBlob() { - scoped_ptr<storage::BlobDataBuilder> blob_data( + std::unique_ptr<storage::BlobDataBuilder> blob_data( new storage::BlobDataBuilder("blob-id:myblob")); blob_data->AppendData(data_); @@ -146,7 +147,7 @@ EXPECT_EQ(net::OK, rv); EXPECT_TRUE(cache_backend_); - scoped_ptr<disk_cache::Entry*> entry(new disk_cache::Entry*()); + std::unique_ptr<disk_cache::Entry*> entry(new disk_cache::Entry*()); disk_cache::Entry** entry_ptr = entry.get(); rv = cache_backend_->CreateEntry(kEntryKey, entry_ptr, base::Bind(&DoNothingCompletion)); @@ -167,7 +168,7 @@ } bool Stream() { - scoped_ptr<storage::BlobDataHandle> new_data_handle( + std::unique_ptr<storage::BlobDataHandle> new_data_handle( blob_storage_context_->GetBlobDataFromUUID(blob_handle_->uuid())); cache_storage_blob_to_disk_cache_->StreamBlobToCache( @@ -187,15 +188,16 @@ callback_called_ = true; } - scoped_ptr<TestBrowserContext> browser_context_; + std::unique_ptr<TestBrowserContext> browser_context_; TestBrowserThreadBundle browser_thread_bundle_; - scoped_ptr<net::URLRequestJobFactoryImpl> url_request_job_factory_; + std::unique_ptr<net::URLRequestJobFactoryImpl> url_request_job_factory_; storage::BlobStorageContext* blob_storage_context_; scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; - scoped_ptr<storage::BlobDataHandle> blob_handle_; - scoped_ptr<disk_cache::Backend> cache_backend_; + std::unique_ptr<storage::BlobDataHandle> blob_handle_; + std::unique_ptr<disk_cache::Backend> cache_backend_; disk_cache::ScopedEntryPtr disk_cache_entry_; - scoped_ptr<TestCacheStorageBlobToDiskCache> cache_storage_blob_to_disk_cache_; + std::unique_ptr<TestCacheStorageBlobToDiskCache> + cache_storage_blob_to_disk_cache_; std::string data_; bool callback_success_;
diff --git a/content/browser/cache_storage/cache_storage_cache.cc b/content/browser/cache_storage/cache_storage_cache.cc index fe60581..a7aade35 100644 --- a/content/browser/cache_storage/cache_storage_cache.cc +++ b/content/browser/cache_storage/cache_storage_cache.cc
@@ -55,7 +55,7 @@ DISALLOW_COPY_AND_ASSIGN(CacheStorageCacheDataHandle); }; -typedef base::Callback<void(scoped_ptr<CacheMetadata>)> MetadataCallback; +typedef base::Callback<void(std::unique_ptr<CacheMetadata>)> MetadataCallback; enum EntryIndex { INDEX_HEADERS = 0, INDEX_RESPONSE_BODY }; @@ -170,14 +170,14 @@ scoped_refptr<net::IOBufferWithSize> buffer, int rv) { if (rv != buffer->size()) { - callback.Run(scoped_ptr<CacheMetadata>()); + callback.Run(std::unique_ptr<CacheMetadata>()); return; } - scoped_ptr<CacheMetadata> metadata(new CacheMetadata()); + std::unique_ptr<CacheMetadata> metadata(new CacheMetadata()); if (!metadata->ParseFromArray(buffer->data(), buffer->size())) { - callback.Run(scoped_ptr<CacheMetadata>()); + callback.Run(std::unique_ptr<CacheMetadata>()); return; } @@ -202,7 +202,7 @@ Entries entries; // Used for enumerating cache entries. - scoped_ptr<disk_cache::Backend::Iterator> backend_iterator; + std::unique_ptr<disk_cache::Backend::Iterator> backend_iterator; disk_cache::Entry* enumerated_entry; private: @@ -211,7 +211,7 @@ // The state needed to pass between CacheStorageCache::MatchAll callbacks. struct CacheStorageCache::MatchAllContext { - MatchAllContext(scoped_ptr<ServiceWorkerFetchRequest> request, + MatchAllContext(std::unique_ptr<ServiceWorkerFetchRequest> request, const CacheStorageCacheQueryParams& match_params, const ResponsesCallback& callback) : request(std::move(request)), @@ -221,7 +221,7 @@ out_blob_data_handles(new BlobDataHandles) {} ~MatchAllContext() {} - scoped_ptr<ServiceWorkerFetchRequest> request; + std::unique_ptr<ServiceWorkerFetchRequest> request; CacheStorageCacheQueryParams options; @@ -229,11 +229,11 @@ ResponsesCallback original_callback; // The outputs of the MatchAll function. - scoped_ptr<Responses> out_responses; - scoped_ptr<BlobDataHandles> out_blob_data_handles; + std::unique_ptr<Responses> out_responses; + std::unique_ptr<BlobDataHandles> out_blob_data_handles; // The context holding open entries. - scoped_ptr<OpenAllEntriesContext> entries_context; + std::unique_ptr<OpenAllEntriesContext> entries_context; private: DISALLOW_COPY_AND_ASSIGN(MatchAllContext); @@ -249,10 +249,10 @@ RequestsCallback original_callback; // The output of the Keys function. - scoped_ptr<Requests> out_keys; + std::unique_ptr<Requests> out_keys; // The context holding open entries. - scoped_ptr<OpenAllEntriesContext> entries_context; + std::unique_ptr<OpenAllEntriesContext> entries_context; private: DISALLOW_COPY_AND_ASSIGN(KeysContext); @@ -260,9 +260,9 @@ // The state needed to pass between CacheStorageCache::Put callbacks. struct CacheStorageCache::PutContext { - PutContext(scoped_ptr<ServiceWorkerFetchRequest> request, - scoped_ptr<ServiceWorkerResponse> response, - scoped_ptr<storage::BlobDataHandle> blob_data_handle, + PutContext(std::unique_ptr<ServiceWorkerFetchRequest> request, + std::unique_ptr<ServiceWorkerResponse> response, + std::unique_ptr<storage::BlobDataHandle> blob_data_handle, const CacheStorageCache::ErrorCallback& callback) : request(std::move(request)), response(std::move(response)), @@ -270,9 +270,9 @@ callback(callback) {} // Input parameters to the Put function. - scoped_ptr<ServiceWorkerFetchRequest> request; - scoped_ptr<ServiceWorkerResponse> response; - scoped_ptr<storage::BlobDataHandle> blob_data_handle; + std::unique_ptr<ServiceWorkerFetchRequest> request; + std::unique_ptr<ServiceWorkerResponse> response; + std::unique_ptr<storage::BlobDataHandle> blob_data_handle; CacheStorageCache::ErrorCallback callback; disk_cache::ScopedEntryPtr cache_entry; int64_t available_bytes = 0; @@ -314,12 +314,13 @@ return weak_ptr_factory_.GetWeakPtr(); } -void CacheStorageCache::Match(scoped_ptr<ServiceWorkerFetchRequest> request, - const ResponseCallback& callback) { +void CacheStorageCache::Match( + std::unique_ptr<ServiceWorkerFetchRequest> request, + const ResponseCallback& callback) { if (!LazyInitialize()) { callback.Run(CACHE_STORAGE_ERROR_STORAGE, - scoped_ptr<ServiceWorkerResponse>(), - scoped_ptr<storage::BlobDataHandle>()); + std::unique_ptr<ServiceWorkerResponse>(), + std::unique_ptr<storage::BlobDataHandle>()); return; } @@ -332,12 +333,12 @@ } void CacheStorageCache::MatchAll( - scoped_ptr<ServiceWorkerFetchRequest> request, + std::unique_ptr<ServiceWorkerFetchRequest> request, const CacheStorageCacheQueryParams& match_params, const ResponsesCallback& callback) { if (!LazyInitialize()) { - callback.Run(CACHE_STORAGE_ERROR_STORAGE, scoped_ptr<Responses>(), - scoped_ptr<BlobDataHandles>()); + callback.Run(CACHE_STORAGE_ERROR_STORAGE, std::unique_ptr<Responses>(), + std::unique_ptr<BlobDataHandles>()); return; } @@ -345,7 +346,7 @@ base::Bind(&CacheStorageCache::PendingResponsesCallback, weak_ptr_factory_.GetWeakPtr(), callback); - scoped_ptr<MatchAllContext> context( + std::unique_ptr<MatchAllContext> context( new MatchAllContext(std::move(request), match_params, pending_callback)); scheduler_->ScheduleOperation(base::Bind(&CacheStorageCache::MatchAllImpl, weak_ptr_factory_.GetWeakPtr(), @@ -360,7 +361,7 @@ return; } - scoped_ptr<ErrorCallback> callback_copy(new ErrorCallback(callback)); + std::unique_ptr<ErrorCallback> callback_copy(new ErrorCallback(callback)); ErrorCallback* callback_ptr = callback_copy.get(); base::Closure barrier_closure = base::BarrierClosure( operations.size(), @@ -404,7 +405,7 @@ } void CacheStorageCache::BatchDidAllOperations( - scoped_ptr<ErrorCallback> callback) { + std::unique_ptr<ErrorCallback> callback) { if (callback->is_null()) return; callback->Run(CACHE_STORAGE_OK); @@ -412,7 +413,7 @@ void CacheStorageCache::Keys(const RequestsCallback& callback) { if (!LazyInitialize()) { - callback.Run(CACHE_STORAGE_ERROR_STORAGE, scoped_ptr<Requests>()); + callback.Run(CACHE_STORAGE_ERROR_STORAGE, std::unique_ptr<Requests>()); return; } @@ -517,7 +518,8 @@ } void CacheStorageCache::OpenAllEntries(const OpenAllEntriesCallback& callback) { - scoped_ptr<OpenAllEntriesContext> entries_context(new OpenAllEntriesContext); + std::unique_ptr<OpenAllEntriesContext> entries_context( + new OpenAllEntriesContext); entries_context->backend_iterator = backend_->CreateIterator(); disk_cache::Backend::Iterator& iterator = *entries_context->backend_iterator; disk_cache::Entry** enumerated_entry = &entries_context->enumerated_entry; @@ -533,7 +535,7 @@ } void CacheStorageCache::DidOpenNextEntry( - scoped_ptr<OpenAllEntriesContext> entries_context, + std::unique_ptr<OpenAllEntriesContext> entries_context, const OpenAllEntriesCallback& callback, int rv) { if (rv == net::ERR_FAILED) { @@ -570,17 +572,19 @@ open_entry_callback.Run(rv); } -void CacheStorageCache::MatchImpl(scoped_ptr<ServiceWorkerFetchRequest> request, - const ResponseCallback& callback) { +void CacheStorageCache::MatchImpl( + std::unique_ptr<ServiceWorkerFetchRequest> request, + const ResponseCallback& callback) { DCHECK_NE(BACKEND_UNINITIALIZED, backend_state_); if (backend_state_ != BACKEND_OPEN) { callback.Run(CACHE_STORAGE_ERROR_STORAGE, - scoped_ptr<ServiceWorkerResponse>(), - scoped_ptr<storage::BlobDataHandle>()); + std::unique_ptr<ServiceWorkerResponse>(), + std::unique_ptr<storage::BlobDataHandle>()); return; } - scoped_ptr<disk_cache::Entry*> scoped_entry_ptr(new disk_cache::Entry*()); + std::unique_ptr<disk_cache::Entry*> scoped_entry_ptr( + new disk_cache::Entry*()); disk_cache::Entry** entry_ptr = scoped_entry_ptr.get(); ServiceWorkerFetchRequest* request_ptr = request.get(); @@ -596,14 +600,14 @@ } void CacheStorageCache::MatchDidOpenEntry( - scoped_ptr<ServiceWorkerFetchRequest> request, + std::unique_ptr<ServiceWorkerFetchRequest> request, const ResponseCallback& callback, - scoped_ptr<disk_cache::Entry*> entry_ptr, + std::unique_ptr<disk_cache::Entry*> entry_ptr, int rv) { if (rv != net::OK) { callback.Run(CACHE_STORAGE_ERROR_NOT_FOUND, - scoped_ptr<ServiceWorkerResponse>(), - scoped_ptr<storage::BlobDataHandle>()); + std::unique_ptr<ServiceWorkerResponse>(), + std::unique_ptr<storage::BlobDataHandle>()); return; } disk_cache::ScopedEntryPtr entry(*entry_ptr); @@ -617,18 +621,18 @@ } void CacheStorageCache::MatchDidReadMetadata( - scoped_ptr<ServiceWorkerFetchRequest> request, + std::unique_ptr<ServiceWorkerFetchRequest> request, const ResponseCallback& callback, disk_cache::ScopedEntryPtr entry, - scoped_ptr<CacheMetadata> metadata) { + std::unique_ptr<CacheMetadata> metadata) { if (!metadata) { callback.Run(CACHE_STORAGE_ERROR_STORAGE, - scoped_ptr<ServiceWorkerResponse>(), - scoped_ptr<storage::BlobDataHandle>()); + std::unique_ptr<ServiceWorkerResponse>(), + std::unique_ptr<storage::BlobDataHandle>()); return; } - scoped_ptr<ServiceWorkerResponse> response(new ServiceWorkerResponse); + std::unique_ptr<ServiceWorkerResponse> response(new ServiceWorkerResponse); PopulateResponseMetadata(*metadata, response.get()); ServiceWorkerHeaderMap cached_request_headers; @@ -642,36 +646,36 @@ if (!VaryMatches(request->headers, cached_request_headers, response->headers)) { callback.Run(CACHE_STORAGE_ERROR_NOT_FOUND, - scoped_ptr<ServiceWorkerResponse>(), - scoped_ptr<storage::BlobDataHandle>()); + std::unique_ptr<ServiceWorkerResponse>(), + std::unique_ptr<storage::BlobDataHandle>()); return; } if (entry->GetDataSize(INDEX_RESPONSE_BODY) == 0) { callback.Run(CACHE_STORAGE_OK, std::move(response), - scoped_ptr<storage::BlobDataHandle>()); + std::unique_ptr<storage::BlobDataHandle>()); return; } if (!blob_storage_context_) { callback.Run(CACHE_STORAGE_ERROR_STORAGE, - scoped_ptr<ServiceWorkerResponse>(), - scoped_ptr<storage::BlobDataHandle>()); + std::unique_ptr<ServiceWorkerResponse>(), + std::unique_ptr<storage::BlobDataHandle>()); return; } - scoped_ptr<storage::BlobDataHandle> blob_data_handle = + std::unique_ptr<storage::BlobDataHandle> blob_data_handle = PopulateResponseBody(std::move(entry), response.get()); callback.Run(CACHE_STORAGE_OK, std::move(response), std::move(blob_data_handle)); } -void CacheStorageCache::MatchAllImpl(scoped_ptr<MatchAllContext> context) { +void CacheStorageCache::MatchAllImpl(std::unique_ptr<MatchAllContext> context) { DCHECK_NE(BACKEND_UNINITIALIZED, backend_state_); if (backend_state_ != BACKEND_OPEN) { context->original_callback.Run(CACHE_STORAGE_ERROR_STORAGE, - scoped_ptr<Responses>(), - scoped_ptr<BlobDataHandles>()); + std::unique_ptr<Responses>(), + std::unique_ptr<BlobDataHandles>()); return; } @@ -681,12 +685,12 @@ } void CacheStorageCache::MatchAllDidOpenAllEntries( - scoped_ptr<MatchAllContext> context, - scoped_ptr<OpenAllEntriesContext> entries_context, + std::unique_ptr<MatchAllContext> context, + std::unique_ptr<OpenAllEntriesContext> entries_context, CacheStorageError error) { if (error != CACHE_STORAGE_OK) { - context->original_callback.Run(error, scoped_ptr<Responses>(), - scoped_ptr<BlobDataHandles>()); + context->original_callback.Run(error, std::unique_ptr<Responses>(), + std::unique_ptr<BlobDataHandles>()); return; } @@ -696,7 +700,7 @@ } void CacheStorageCache::MatchAllProcessNextEntry( - scoped_ptr<MatchAllContext> context, + std::unique_ptr<MatchAllContext> context, const Entries::iterator& iter) { if (iter == context->entries_context->entries.end()) { // All done. Return all of the responses. @@ -723,9 +727,9 @@ } void CacheStorageCache::MatchAllDidReadMetadata( - scoped_ptr<MatchAllContext> context, + std::unique_ptr<MatchAllContext> context, const Entries::iterator& iter, - scoped_ptr<CacheMetadata> metadata) { + std::unique_ptr<CacheMetadata> metadata) { // Move ownership of the entry from the context. disk_cache::ScopedEntryPtr entry(*iter); *iter = nullptr; @@ -747,12 +751,12 @@ if (!blob_storage_context_) { context->original_callback.Run(CACHE_STORAGE_ERROR_STORAGE, - scoped_ptr<Responses>(), - scoped_ptr<BlobDataHandles>()); + std::unique_ptr<Responses>(), + std::unique_ptr<BlobDataHandles>()); return; } - scoped_ptr<storage::BlobDataHandle> blob_data_handle = + std::unique_ptr<storage::BlobDataHandle> blob_data_handle = PopulateResponseBody(std::move(entry), &response); context->out_responses->push_back(response); @@ -765,10 +769,11 @@ DCHECK(BACKEND_OPEN == backend_state_ || initializing_); DCHECK_EQ(CACHE_STORAGE_CACHE_OPERATION_TYPE_PUT, operation.operation_type); - scoped_ptr<ServiceWorkerFetchRequest> request(new ServiceWorkerFetchRequest( - operation.request.url, operation.request.method, - operation.request.headers, operation.request.referrer, - operation.request.is_reload)); + std::unique_ptr<ServiceWorkerFetchRequest> request( + new ServiceWorkerFetchRequest( + operation.request.url, operation.request.method, + operation.request.headers, operation.request.referrer, + operation.request.is_reload)); // We don't support streaming for cache. DCHECK(operation.response.stream_url.is_empty()); @@ -776,7 +781,7 @@ DCHECK(!(operation.response.response_type == blink::WebServiceWorkerResponseTypeOpaqueRedirect && operation.response.blob_size)); - scoped_ptr<ServiceWorkerResponse> response(new ServiceWorkerResponse( + std::unique_ptr<ServiceWorkerResponse> response(new ServiceWorkerResponse( operation.response.url, operation.response.status_code, operation.response.status_text, operation.response.response_type, operation.response.headers, operation.response.blob_uuid, @@ -785,7 +790,7 @@ false /* is_in_cache_storage */, std::string() /* cache_storage_cache_name */)); - scoped_ptr<storage::BlobDataHandle> blob_data_handle; + std::unique_ptr<storage::BlobDataHandle> blob_data_handle; if (!response->blob_uuid.empty()) { if (!blob_storage_context_) { @@ -804,7 +809,7 @@ base::Bind(&CacheStorageCache::PendingErrorCallback, weak_ptr_factory_.GetWeakPtr(), callback); - scoped_ptr<PutContext> put_context( + std::unique_ptr<PutContext> put_context( new PutContext(std::move(request), std::move(response), std::move(blob_data_handle), pending_callback)); @@ -813,14 +818,14 @@ base::Passed(std::move(put_context)))); } -void CacheStorageCache::PutImpl(scoped_ptr<PutContext> put_context) { +void CacheStorageCache::PutImpl(std::unique_ptr<PutContext> put_context) { DCHECK_NE(BACKEND_UNINITIALIZED, backend_state_); if (backend_state_ != BACKEND_OPEN) { put_context->callback.Run(CACHE_STORAGE_ERROR_STORAGE); return; } - scoped_ptr<ServiceWorkerFetchRequest> request_copy( + std::unique_ptr<ServiceWorkerFetchRequest> request_copy( new ServiceWorkerFetchRequest(*put_context->request)); DeleteImpl(std::move(request_copy), CacheStorageCacheQueryParams(), @@ -829,7 +834,7 @@ base::Passed(std::move(put_context)))); } -void CacheStorageCache::PutDidDelete(scoped_ptr<PutContext> put_context, +void CacheStorageCache::PutDidDelete(std::unique_ptr<PutContext> put_context, CacheStorageError delete_error) { if (backend_state_ != BACKEND_OPEN) { put_context->callback.Run(CACHE_STORAGE_ERROR_STORAGE); @@ -845,7 +850,7 @@ } void CacheStorageCache::PutDidGetUsageAndQuota( - scoped_ptr<PutContext> put_context, + std::unique_ptr<PutContext> put_context, storage::QuotaStatusCode status_code, int64_t usage, int64_t quota) { @@ -861,7 +866,8 @@ put_context->available_bytes = quota - usage; - scoped_ptr<disk_cache::Entry*> scoped_entry_ptr(new disk_cache::Entry*()); + std::unique_ptr<disk_cache::Entry*> scoped_entry_ptr( + new disk_cache::Entry*()); disk_cache::Entry** entry_ptr = scoped_entry_ptr.get(); ServiceWorkerFetchRequest* request_ptr = put_context->request.get(); disk_cache::Backend* backend_ptr = backend_.get(); @@ -879,8 +885,8 @@ } void CacheStorageCache::PutDidCreateEntry( - scoped_ptr<disk_cache::Entry*> entry_ptr, - scoped_ptr<PutContext> put_context, + std::unique_ptr<disk_cache::Entry*> entry_ptr, + std::unique_ptr<PutContext> put_context, int rv) { put_context->cache_entry.reset(*entry_ptr); @@ -920,7 +926,7 @@ header_map->set_value(it->second); } - scoped_ptr<std::string> serialized(new std::string()); + std::unique_ptr<std::string> serialized(new std::string()); if (!metadata.SerializeToString(serialized.get())) { put_context->callback.Run(CACHE_STORAGE_ERROR_STORAGE); return; @@ -950,9 +956,10 @@ write_headers_callback.Run(rv); } -void CacheStorageCache::PutDidWriteHeaders(scoped_ptr<PutContext> put_context, - int expected_bytes, - int rv) { +void CacheStorageCache::PutDidWriteHeaders( + std::unique_ptr<PutContext> put_context, + int expected_bytes, + int rv) { if (rv != expected_bytes) { put_context->cache_entry->Doom(); put_context->callback.Run(CACHE_STORAGE_ERROR_STORAGE); @@ -978,7 +985,7 @@ BlobToDiskCacheIDMap::KeyType blob_to_cache_key = active_blob_to_disk_cache_writers_.Add(blob_to_cache); - scoped_ptr<storage::BlobDataHandle> blob_data_handle = + std::unique_ptr<storage::BlobDataHandle> blob_data_handle = std::move(put_context->blob_data_handle); blob_to_cache->StreamBlobToCache( @@ -990,7 +997,7 @@ } void CacheStorageCache::PutDidWriteBlobToCache( - scoped_ptr<PutContext> put_context, + std::unique_ptr<PutContext> put_context, BlobToDiskCacheIDMap::KeyType blob_to_cache_key, disk_cache::ScopedEntryPtr entry, bool success) { @@ -1037,10 +1044,11 @@ DCHECK_EQ(CACHE_STORAGE_CACHE_OPERATION_TYPE_DELETE, operation.operation_type); - scoped_ptr<ServiceWorkerFetchRequest> request(new ServiceWorkerFetchRequest( - operation.request.url, operation.request.method, - operation.request.headers, operation.request.referrer, - operation.request.is_reload)); + std::unique_ptr<ServiceWorkerFetchRequest> request( + new ServiceWorkerFetchRequest( + operation.request.url, operation.request.method, + operation.request.headers, operation.request.referrer, + operation.request.is_reload)); ErrorCallback pending_callback = base::Bind(&CacheStorageCache::PendingErrorCallback, @@ -1052,7 +1060,7 @@ } void CacheStorageCache::DeleteImpl( - scoped_ptr<ServiceWorkerFetchRequest> request, + std::unique_ptr<ServiceWorkerFetchRequest> request, const CacheStorageCacheQueryParams& match_params, const ErrorCallback& callback) { DCHECK_NE(BACKEND_UNINITIALIZED, backend_state_); @@ -1068,7 +1076,7 @@ return; } - scoped_ptr<disk_cache::Entry*> entry(new disk_cache::Entry*); + std::unique_ptr<disk_cache::Entry*> entry(new disk_cache::Entry*); disk_cache::Entry** entry_ptr = entry.get(); @@ -1086,9 +1094,9 @@ } void CacheStorageCache::DeleteDidOpenAllEntries( - scoped_ptr<ServiceWorkerFetchRequest> request, + std::unique_ptr<ServiceWorkerFetchRequest> request, const ErrorCallback& callback, - scoped_ptr<OpenAllEntriesContext> entries_context, + std::unique_ptr<OpenAllEntriesContext> entries_context, CacheStorageError error) { if (error != CACHE_STORAGE_OK) { callback.Run(error); @@ -1111,9 +1119,9 @@ void CacheStorageCache::DeleteDidOpenEntry( const GURL& origin, - scoped_ptr<ServiceWorkerFetchRequest> request, + std::unique_ptr<ServiceWorkerFetchRequest> request, const CacheStorageCache::ErrorCallback& callback, - scoped_ptr<disk_cache::Entry*> entry_ptr, + std::unique_ptr<disk_cache::Entry*> entry_ptr, int rv) { if (rv != net::OK) { callback.Run(CACHE_STORAGE_ERROR_NOT_FOUND); @@ -1133,7 +1141,7 @@ void CacheStorageCache::KeysImpl(const RequestsCallback& callback) { DCHECK_NE(BACKEND_UNINITIALIZED, backend_state_); if (backend_state_ != BACKEND_OPEN) { - callback.Run(CACHE_STORAGE_ERROR_STORAGE, scoped_ptr<Requests>()); + callback.Run(CACHE_STORAGE_ERROR_STORAGE, std::unique_ptr<Requests>()); return; } @@ -1153,21 +1161,21 @@ void CacheStorageCache::KeysDidOpenAllEntries( const RequestsCallback& callback, - scoped_ptr<OpenAllEntriesContext> entries_context, + std::unique_ptr<OpenAllEntriesContext> entries_context, CacheStorageError error) { if (error != CACHE_STORAGE_OK) { - callback.Run(error, scoped_ptr<Requests>()); + callback.Run(error, std::unique_ptr<Requests>()); return; } - scoped_ptr<KeysContext> keys_context(new KeysContext(callback)); + std::unique_ptr<KeysContext> keys_context(new KeysContext(callback)); keys_context->entries_context.swap(entries_context); Entries::iterator iter = keys_context->entries_context->entries.begin(); KeysProcessNextEntry(std::move(keys_context), iter); } void CacheStorageCache::KeysProcessNextEntry( - scoped_ptr<KeysContext> keys_context, + std::unique_ptr<KeysContext> keys_context, const Entries::iterator& iter) { if (iter == keys_context->entries_context->entries.end()) { // All done. Return all of the keys. @@ -1182,9 +1190,9 @@ } void CacheStorageCache::KeysDidReadMetadata( - scoped_ptr<KeysContext> keys_context, + std::unique_ptr<KeysContext> keys_context, const Entries::iterator& iter, - scoped_ptr<CacheMetadata> metadata) { + std::unique_ptr<CacheMetadata> metadata) { disk_cache::Entry* entry = *iter; if (metadata) { @@ -1235,7 +1243,7 @@ // Use APP_CACHE as opposed to DISK_CACHE to prevent cache eviction. net::CacheType cache_type = memory_only_ ? net::MEMORY_CACHE : net::APP_CACHE; - scoped_ptr<ScopedBackendPtr> backend_ptr(new ScopedBackendPtr()); + std::unique_ptr<ScopedBackendPtr> backend_ptr(new ScopedBackendPtr()); // Temporary pointer so that backend_ptr can be Pass()'d in Bind below. ScopedBackendPtr* backend = backend_ptr.get(); @@ -1258,7 +1266,7 @@ void CacheStorageCache::CreateBackendDidCreate( const CacheStorageCache::ErrorCallback& callback, - scoped_ptr<ScopedBackendPtr> backend_ptr, + std::unique_ptr<ScopedBackendPtr> backend_ptr, int rv) { if (rv != net::OK) { callback.Run(CACHE_STORAGE_ERROR_STORAGE); @@ -1334,8 +1342,8 @@ void CacheStorageCache::PendingResponseCallback( const ResponseCallback& callback, CacheStorageError error, - scoped_ptr<ServiceWorkerResponse> response, - scoped_ptr<storage::BlobDataHandle> blob_data_handle) { + std::unique_ptr<ServiceWorkerResponse> response, + std::unique_ptr<storage::BlobDataHandle> blob_data_handle) { base::WeakPtr<CacheStorageCache> cache = weak_ptr_factory_.GetWeakPtr(); callback.Run(error, std::move(response), std::move(blob_data_handle)); @@ -1346,8 +1354,8 @@ void CacheStorageCache::PendingResponsesCallback( const ResponsesCallback& callback, CacheStorageError error, - scoped_ptr<Responses> responses, - scoped_ptr<BlobDataHandles> blob_data_handles) { + std::unique_ptr<Responses> responses, + std::unique_ptr<BlobDataHandles> blob_data_handles) { base::WeakPtr<CacheStorageCache> cache = weak_ptr_factory_.GetWeakPtr(); callback.Run(error, std::move(responses), std::move(blob_data_handles)); @@ -1358,7 +1366,7 @@ void CacheStorageCache::PendingRequestsCallback( const RequestsCallback& callback, CacheStorageError error, - scoped_ptr<Requests> requests) { + std::unique_ptr<Requests> requests) { base::WeakPtr<CacheStorageCache> cache = weak_ptr_factory_.GetWeakPtr(); callback.Run(error, std::move(requests)); @@ -1395,9 +1403,9 @@ } } -scoped_ptr<storage::BlobDataHandle> CacheStorageCache::PopulateResponseBody( - disk_cache::ScopedEntryPtr entry, - ServiceWorkerResponse* response) { +std::unique_ptr<storage::BlobDataHandle> +CacheStorageCache::PopulateResponseBody(disk_cache::ScopedEntryPtr entry, + ServiceWorkerResponse* response) { DCHECK(blob_storage_context_); // Create a blob with the response body data.
diff --git a/content/browser/cache_storage/cache_storage_cache.h b/content/browser/cache_storage/cache_storage_cache.h index c5b2cb2..9a950801 100644 --- a/content/browser/cache_storage/cache_storage_cache.h +++ b/content/browser/cache_storage/cache_storage_cache.h
@@ -48,16 +48,17 @@ using ErrorCallback = base::Callback<void(CacheStorageError)>; using ResponseCallback = base::Callback<void(CacheStorageError, - scoped_ptr<ServiceWorkerResponse>, - scoped_ptr<storage::BlobDataHandle>)>; + std::unique_ptr<ServiceWorkerResponse>, + std::unique_ptr<storage::BlobDataHandle>)>; using Responses = std::vector<ServiceWorkerResponse>; using BlobDataHandles = std::vector<storage::BlobDataHandle>; - using ResponsesCallback = base::Callback<void(CacheStorageError, - scoped_ptr<Responses>, - scoped_ptr<BlobDataHandles>)>; + using ResponsesCallback = + base::Callback<void(CacheStorageError, + std::unique_ptr<Responses>, + std::unique_ptr<BlobDataHandles>)>; using Requests = std::vector<ServiceWorkerFetchRequest>; using RequestsCallback = - base::Callback<void(CacheStorageError, scoped_ptr<Requests>)>; + base::Callback<void(CacheStorageError, std::unique_ptr<Requests>)>; using SizeCallback = base::Callback<void(int64_t)>; static scoped_refptr<CacheStorageCache> CreateMemoryCache( @@ -75,12 +76,12 @@ base::WeakPtr<storage::BlobStorageContext> blob_context); // Returns ERROR_TYPE_NOT_FOUND if not found. - void Match(scoped_ptr<ServiceWorkerFetchRequest> request, + void Match(std::unique_ptr<ServiceWorkerFetchRequest> request, const ResponseCallback& callback); // Returns CACHE_STORAGE_OK and matched responses in this cache. If there are // no responses, returns CACHE_STORAGE_OK and an empty vector. - void MatchAll(scoped_ptr<ServiceWorkerFetchRequest> request, + void MatchAll(std::unique_ptr<ServiceWorkerFetchRequest> request, const CacheStorageCacheQueryParams& match_params, const ResponsesCallback& callback); @@ -102,7 +103,7 @@ void BatchDidOneOperation(const base::Closure& barrier_closure, ErrorCallback* callback, CacheStorageError error); - void BatchDidAllOperations(scoped_ptr<ErrorCallback> callback); + void BatchDidAllOperations(std::unique_ptr<ErrorCallback> callback); // TODO(jkarlin): Have keys take an optional ServiceWorkerFetchRequest. // Returns CACHE_STORAGE_OK and a vector of requests if there are no errors. @@ -142,11 +143,11 @@ }; using Entries = std::vector<disk_cache::Entry*>; - using ScopedBackendPtr = scoped_ptr<disk_cache::Backend>; + using ScopedBackendPtr = std::unique_ptr<disk_cache::Backend>; using BlobToDiskCacheIDMap = IDMap<CacheStorageBlobToDiskCache, IDMapOwnPointer>; using OpenAllEntriesCallback = - base::Callback<void(scoped_ptr<OpenAllEntriesContext>, + base::Callback<void(std::unique_ptr<OpenAllEntriesContext>, CacheStorageError)>; CacheStorageCache( @@ -165,53 +166,53 @@ // Returns all entries in this cache. void OpenAllEntries(const OpenAllEntriesCallback& callback); - void DidOpenNextEntry(scoped_ptr<OpenAllEntriesContext> entries_context, + void DidOpenNextEntry(std::unique_ptr<OpenAllEntriesContext> entries_context, const OpenAllEntriesCallback& callback, int rv); // Match callbacks - void MatchImpl(scoped_ptr<ServiceWorkerFetchRequest> request, + void MatchImpl(std::unique_ptr<ServiceWorkerFetchRequest> request, const ResponseCallback& callback); - void MatchDidOpenEntry(scoped_ptr<ServiceWorkerFetchRequest> request, + void MatchDidOpenEntry(std::unique_ptr<ServiceWorkerFetchRequest> request, const ResponseCallback& callback, - scoped_ptr<disk_cache::Entry*> entry_ptr, + std::unique_ptr<disk_cache::Entry*> entry_ptr, int rv); - void MatchDidReadMetadata(scoped_ptr<ServiceWorkerFetchRequest> request, + void MatchDidReadMetadata(std::unique_ptr<ServiceWorkerFetchRequest> request, const ResponseCallback& callback, disk_cache::ScopedEntryPtr entry, - scoped_ptr<CacheMetadata> headers); + std::unique_ptr<CacheMetadata> headers); // MatchAll callbacks - void MatchAllImpl(scoped_ptr<MatchAllContext> context); + void MatchAllImpl(std::unique_ptr<MatchAllContext> context); void MatchAllDidOpenAllEntries( - scoped_ptr<MatchAllContext> context, - scoped_ptr<OpenAllEntriesContext> entries_context, + std::unique_ptr<MatchAllContext> context, + std::unique_ptr<OpenAllEntriesContext> entries_context, CacheStorageError error); - void MatchAllProcessNextEntry(scoped_ptr<MatchAllContext> context, + void MatchAllProcessNextEntry(std::unique_ptr<MatchAllContext> context, const Entries::iterator& iter); - void MatchAllDidReadMetadata(scoped_ptr<MatchAllContext> context, + void MatchAllDidReadMetadata(std::unique_ptr<MatchAllContext> context, const Entries::iterator& iter, - scoped_ptr<CacheMetadata> metadata); + std::unique_ptr<CacheMetadata> metadata); // Puts the request and response object in the cache. The response body (if // present) is stored in the cache, but not the request body. Returns OK on // success. void Put(const CacheStorageBatchOperation& operation, const ErrorCallback& callback); - void PutImpl(scoped_ptr<PutContext> put_context); - void PutDidDelete(scoped_ptr<PutContext> put_context, + void PutImpl(std::unique_ptr<PutContext> put_context); + void PutDidDelete(std::unique_ptr<PutContext> put_context, CacheStorageError delete_error); - void PutDidGetUsageAndQuota(scoped_ptr<PutContext> put_context, + void PutDidGetUsageAndQuota(std::unique_ptr<PutContext> put_context, storage::QuotaStatusCode status_code, int64_t usage, int64_t quota); - void PutDidCreateEntry(scoped_ptr<disk_cache::Entry*> entry_ptr, - scoped_ptr<PutContext> put_context, + void PutDidCreateEntry(std::unique_ptr<disk_cache::Entry*> entry_ptr, + std::unique_ptr<PutContext> put_context, int rv); - void PutDidWriteHeaders(scoped_ptr<PutContext> put_context, + void PutDidWriteHeaders(std::unique_ptr<PutContext> put_context, int expected_bytes, int rv); - void PutDidWriteBlobToCache(scoped_ptr<PutContext> put_context, + void PutDidWriteBlobToCache(std::unique_ptr<PutContext> put_context, BlobToDiskCacheIDMap::KeyType blob_to_cache_key, disk_cache::ScopedEntryPtr entry, bool success); @@ -225,30 +226,31 @@ // Returns ERROR_NOT_FOUND if not found. Otherwise deletes and returns OK. void Delete(const CacheStorageBatchOperation& operation, const ErrorCallback& callback); - void DeleteImpl(scoped_ptr<ServiceWorkerFetchRequest> request, + void DeleteImpl(std::unique_ptr<ServiceWorkerFetchRequest> request, const CacheStorageCacheQueryParams& match_params, const ErrorCallback& callback); void DeleteDidOpenAllEntries( - scoped_ptr<ServiceWorkerFetchRequest> request, + std::unique_ptr<ServiceWorkerFetchRequest> request, const ErrorCallback& callback, - scoped_ptr<OpenAllEntriesContext> entries_context, + std::unique_ptr<OpenAllEntriesContext> entries_context, CacheStorageError error); void DeleteDidOpenEntry(const GURL& origin, - scoped_ptr<ServiceWorkerFetchRequest> request, + std::unique_ptr<ServiceWorkerFetchRequest> request, const CacheStorageCache::ErrorCallback& callback, - scoped_ptr<disk_cache::Entry*> entryptr, + std::unique_ptr<disk_cache::Entry*> entryptr, int rv); // Keys callbacks. void KeysImpl(const RequestsCallback& callback); - void KeysDidOpenAllEntries(const RequestsCallback& callback, - scoped_ptr<OpenAllEntriesContext> entries_context, - CacheStorageError error); - void KeysProcessNextEntry(scoped_ptr<KeysContext> keys_context, + void KeysDidOpenAllEntries( + const RequestsCallback& callback, + std::unique_ptr<OpenAllEntriesContext> entries_context, + CacheStorageError error); + void KeysProcessNextEntry(std::unique_ptr<KeysContext> keys_context, const Entries::iterator& iter); - void KeysDidReadMetadata(scoped_ptr<KeysContext> keys_context, + void KeysDidReadMetadata(std::unique_ptr<KeysContext> keys_context, const Entries::iterator& iter, - scoped_ptr<CacheMetadata> metadata); + std::unique_ptr<CacheMetadata> metadata); void CloseImpl(const base::Closure& callback); @@ -261,7 +263,7 @@ // success). The callback will always be called. Virtual for tests. virtual void CreateBackend(const ErrorCallback& callback); void CreateBackendDidCreate(const CacheStorageCache::ErrorCallback& callback, - scoped_ptr<ScopedBackendPtr> backend_ptr, + std::unique_ptr<ScopedBackendPtr> backend_ptr, int rv); void InitBackend(); @@ -274,25 +276,26 @@ void PendingResponseCallback( const ResponseCallback& callback, CacheStorageError error, - scoped_ptr<ServiceWorkerResponse> response, - scoped_ptr<storage::BlobDataHandle> blob_data_handle); - void PendingResponsesCallback(const ResponsesCallback& callback, - CacheStorageError error, - scoped_ptr<Responses> responses, - scoped_ptr<BlobDataHandles> blob_data_handles); + std::unique_ptr<ServiceWorkerResponse> response, + std::unique_ptr<storage::BlobDataHandle> blob_data_handle); + void PendingResponsesCallback( + const ResponsesCallback& callback, + CacheStorageError error, + std::unique_ptr<Responses> responses, + std::unique_ptr<BlobDataHandles> blob_data_handles); void PendingRequestsCallback(const RequestsCallback& callback, CacheStorageError error, - scoped_ptr<Requests> requests); + std::unique_ptr<Requests> requests); void PendingSizeCallback(const SizeCallback& callback, int64_t size); void PopulateResponseMetadata(const CacheMetadata& metadata, ServiceWorkerResponse* response); - scoped_ptr<storage::BlobDataHandle> PopulateResponseBody( + std::unique_ptr<storage::BlobDataHandle> PopulateResponseBody( disk_cache::ScopedEntryPtr entry, ServiceWorkerResponse* response); // Be sure to check |backend_state_| before use. - scoped_ptr<disk_cache::Backend> backend_; + std::unique_ptr<disk_cache::Backend> backend_; GURL origin_; const std::string cache_name_; @@ -301,7 +304,7 @@ scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy_; base::WeakPtr<storage::BlobStorageContext> blob_storage_context_; BackendState backend_state_ = BACKEND_UNINITIALIZED; - scoped_ptr<CacheStorageScheduler> scheduler_; + std::unique_ptr<CacheStorageScheduler> scheduler_; bool initializing_ = false; int64_t cache_size_ = 0;
diff --git a/content/browser/cache_storage/cache_storage_cache_unittest.cc b/content/browser/cache_storage/cache_storage_cache_unittest.cc index dabe086..5417f2a 100644 --- a/content/browser/cache_storage/cache_storage_cache_unittest.cc +++ b/content/browser/cache_storage/cache_storage_cache_unittest.cc
@@ -6,13 +6,15 @@ #include <stddef.h> #include <stdint.h> + +#include <memory> #include <utility> #include "base/files/file_path.h" #include "base/files/scoped_temp_dir.h" #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/run_loop.h" #include "base/strings/string_split.h" #include "base/thread_task_runner_handle.h" @@ -47,18 +49,18 @@ // Returns a BlobProtocolHandler that uses |blob_storage_context|. Caller owns // the memory. -scoped_ptr<storage::BlobProtocolHandler> CreateMockBlobProtocolHandler( +std::unique_ptr<storage::BlobProtocolHandler> CreateMockBlobProtocolHandler( storage::BlobStorageContext* blob_storage_context) { // The FileSystemContext and thread task runner are not actually used but a // task runner is needed to avoid a DCHECK in BlobURLRequestJob ctor. - return make_scoped_ptr(new storage::BlobProtocolHandler( + return base::WrapUnique(new storage::BlobProtocolHandler( blob_storage_context, NULL, base::ThreadTaskRunnerHandle::Get().get())); } // A disk_cache::Backend wrapper that can delay operations. class DelayableBackend : public disk_cache::Backend { public: - DelayableBackend(scoped_ptr<disk_cache::Backend> backend) + DelayableBackend(std::unique_ptr<disk_cache::Backend> backend) : backend_(std::move(backend)), delay_open_(false) {} // disk_cache::Backend overrides @@ -103,7 +105,7 @@ const CompletionCallback& callback) override { return backend_->CalculateSizeOfAllEntries(callback); } - scoped_ptr<Iterator> CreateIterator() override { + std::unique_ptr<Iterator> CreateIterator() override { return backend_->CreateIterator(); } void GetStats(base::StringPairs* stats) override { @@ -130,14 +132,15 @@ callback.Run(rv); } - scoped_ptr<disk_cache::Backend> backend_; + std::unique_ptr<disk_cache::Backend> backend_; bool delay_open_; base::Closure open_entry_callback_; }; void CopyBody(const storage::BlobDataHandle& blob_handle, std::string* output) { *output = std::string(); - scoped_ptr<storage::BlobDataSnapshot> data = blob_handle.CreateSnapshot(); + std::unique_ptr<storage::BlobDataSnapshot> data = + blob_handle.CreateSnapshot(); const auto& items = data->items(); for (const auto& item : items) { switch (item->type()) { @@ -337,7 +340,7 @@ for (int i = 0; i < 100; ++i) expected_blob_data_ += kTestData; - scoped_ptr<storage::BlobDataBuilder> blob_data( + std::unique_ptr<storage::BlobDataBuilder> blob_data( new storage::BlobDataBuilder("blob-id:myblob")); blob_data->AppendData(expected_blob_data_); @@ -368,16 +371,16 @@ std::string() /* cache_storage_cache_name */); } - scoped_ptr<ServiceWorkerFetchRequest> CopyFetchRequest( + std::unique_ptr<ServiceWorkerFetchRequest> CopyFetchRequest( const ServiceWorkerFetchRequest& request) { - return make_scoped_ptr(new ServiceWorkerFetchRequest( + return base::WrapUnique(new ServiceWorkerFetchRequest( request.url, request.method, request.headers, request.referrer, request.is_reload)); } CacheStorageError BatchOperation( const std::vector<CacheStorageBatchOperation>& operations) { - scoped_ptr<base::RunLoop> loop(new base::RunLoop()); + std::unique_ptr<base::RunLoop> loop(new base::RunLoop()); cache_->BatchOperation( operations, @@ -403,7 +406,7 @@ } bool Match(const ServiceWorkerFetchRequest& request) { - scoped_ptr<base::RunLoop> loop(new base::RunLoop()); + std::unique_ptr<base::RunLoop> loop(new base::RunLoop()); cache_->Match( CopyFetchRequest(request), @@ -414,10 +417,11 @@ return callback_error_ == CACHE_STORAGE_OK; } - bool MatchAll(const ServiceWorkerFetchRequest& request, - const CacheStorageCacheQueryParams& match_params, - scoped_ptr<CacheStorageCache::Responses>* responses, - scoped_ptr<CacheStorageCache::BlobDataHandles>* body_handles) { + bool MatchAll( + const ServiceWorkerFetchRequest& request, + const CacheStorageCacheQueryParams& match_params, + std::unique_ptr<CacheStorageCache::Responses>* responses, + std::unique_ptr<CacheStorageCache::BlobDataHandles>* body_handles) { base::RunLoop loop; cache_->MatchAll( CopyFetchRequest(request), match_params, @@ -428,8 +432,9 @@ return callback_error_ == CACHE_STORAGE_OK; } - bool MatchAll(scoped_ptr<CacheStorageCache::Responses>* responses, - scoped_ptr<CacheStorageCache::BlobDataHandles>* body_handles) { + bool MatchAll( + std::unique_ptr<CacheStorageCache::Responses>* responses, + std::unique_ptr<CacheStorageCache::BlobDataHandles>* body_handles) { return MatchAll(ServiceWorkerFetchRequest(), CacheStorageCacheQueryParams(), responses, body_handles); } @@ -448,7 +453,7 @@ } bool Keys() { - scoped_ptr<base::RunLoop> loop(new base::RunLoop()); + std::unique_ptr<base::RunLoop> loop(new base::RunLoop()); cache_->Keys(base::Bind(&CacheStorageCacheTest::RequestsCallback, base::Unretained(this), @@ -459,7 +464,7 @@ } bool Close() { - scoped_ptr<base::RunLoop> loop(new base::RunLoop()); + std::unique_ptr<base::RunLoop> loop(new base::RunLoop()); cache_->Close(base::Bind(&CacheStorageCacheTest::CloseCallback, base::Unretained(this), @@ -490,7 +495,7 @@ void RequestsCallback(base::RunLoop* run_loop, CacheStorageError error, - scoped_ptr<CacheStorageCache::Requests> requests) { + std::unique_ptr<CacheStorageCache::Requests> requests) { callback_error_ = error; callback_strings_.clear(); if (requests) { @@ -520,8 +525,8 @@ void ResponseAndErrorCallback( base::RunLoop* run_loop, CacheStorageError error, - scoped_ptr<ServiceWorkerResponse> response, - scoped_ptr<storage::BlobDataHandle> body_handle) { + std::unique_ptr<ServiceWorkerResponse> response, + std::unique_ptr<storage::BlobDataHandle> body_handle) { callback_error_ = error; callback_response_ = std::move(response); callback_response_data_.reset(); @@ -534,11 +539,11 @@ void ResponsesAndErrorCallback( const base::Closure& quit_closure, - scoped_ptr<CacheStorageCache::Responses>* responses_out, - scoped_ptr<CacheStorageCache::BlobDataHandles>* body_handles_out, + std::unique_ptr<CacheStorageCache::Responses>* responses_out, + std::unique_ptr<CacheStorageCache::BlobDataHandles>* body_handles_out, CacheStorageError error, - scoped_ptr<CacheStorageCache::Responses> responses, - scoped_ptr<CacheStorageCache::BlobDataHandles> body_handles) { + std::unique_ptr<CacheStorageCache::Responses> responses, + std::unique_ptr<CacheStorageCache::BlobDataHandles> body_handles) { callback_error_ = error; responses_out->swap(responses); body_handles_out->swap(body_handles); @@ -594,7 +599,7 @@ base::ScopedTempDir temp_dir_; TestBrowserContext browser_context_; TestBrowserThreadBundle browser_thread_bundle_; - scoped_ptr<net::URLRequestJobFactoryImpl> url_request_job_factory_; + std::unique_ptr<net::URLRequestJobFactoryImpl> url_request_job_factory_; scoped_refptr<MockSpecialStoragePolicy> quota_policy_; scoped_refptr<MockQuotaManager> mock_quota_manager_; scoped_refptr<MockQuotaManagerProxy> quota_manager_proxy_; @@ -608,12 +613,12 @@ ServiceWorkerResponse body_response_with_query_; ServiceWorkerFetchRequest no_body_request_; ServiceWorkerResponse no_body_response_; - scoped_ptr<storage::BlobDataHandle> blob_handle_; + std::unique_ptr<storage::BlobDataHandle> blob_handle_; std::string expected_blob_data_; CacheStorageError callback_error_ = CACHE_STORAGE_OK; - scoped_ptr<ServiceWorkerResponse> callback_response_; - scoped_ptr<storage::BlobDataHandle> callback_response_data_; + std::unique_ptr<ServiceWorkerResponse> callback_response_; + std::unique_ptr<storage::BlobDataHandle> callback_response_data_; std::vector<std::string> callback_strings_; bool callback_closed_ = false; int64_t callback_size_ = 0; @@ -694,7 +699,7 @@ operation.request = body_request_; operation.response = body_response_; - scoped_ptr<base::RunLoop> loop(new base::RunLoop()); + std::unique_ptr<base::RunLoop> loop(new base::RunLoop()); cache_->BatchOperation( std::vector<CacheStorageBatchOperation>(1, operation), base::Bind(&CacheStorageCacheTestP::ErrorTypeCallback, @@ -761,8 +766,8 @@ } TEST_P(CacheStorageCacheTestP, MatchAll_Empty) { - scoped_ptr<CacheStorageCache::Responses> responses; - scoped_ptr<CacheStorageCache::BlobDataHandles> body_handles; + std::unique_ptr<CacheStorageCache::Responses> responses; + std::unique_ptr<CacheStorageCache::BlobDataHandles> body_handles; EXPECT_TRUE(MatchAll(&responses, &body_handles)); EXPECT_TRUE(responses->empty()); EXPECT_TRUE(body_handles->empty()); @@ -771,8 +776,8 @@ TEST_P(CacheStorageCacheTestP, MatchAll_NoBody) { EXPECT_TRUE(Put(no_body_request_, no_body_response_)); - scoped_ptr<CacheStorageCache::Responses> responses; - scoped_ptr<CacheStorageCache::BlobDataHandles> body_handles; + std::unique_ptr<CacheStorageCache::Responses> responses; + std::unique_ptr<CacheStorageCache::BlobDataHandles> body_handles; EXPECT_TRUE(MatchAll(&responses, &body_handles)); ASSERT_EQ(1u, responses->size()); @@ -784,8 +789,8 @@ TEST_P(CacheStorageCacheTestP, MatchAll_Body) { EXPECT_TRUE(Put(body_request_, body_response_)); - scoped_ptr<CacheStorageCache::Responses> responses; - scoped_ptr<CacheStorageCache::BlobDataHandles> body_handles; + std::unique_ptr<CacheStorageCache::Responses> responses; + std::unique_ptr<CacheStorageCache::BlobDataHandles> body_handles; EXPECT_TRUE(MatchAll(&responses, &body_handles)); ASSERT_EQ(1u, responses->size()); @@ -799,8 +804,8 @@ EXPECT_TRUE(Put(no_body_request_, no_body_response_)); EXPECT_TRUE(Put(body_request_, body_response_)); - scoped_ptr<CacheStorageCache::Responses> responses; - scoped_ptr<CacheStorageCache::BlobDataHandles> body_handles; + std::unique_ptr<CacheStorageCache::Responses> responses; + std::unique_ptr<CacheStorageCache::BlobDataHandles> body_handles; EXPECT_TRUE(MatchAll(&responses, &body_handles)); ASSERT_EQ(2u, responses->size()); ASSERT_EQ(1u, body_handles->size()); @@ -839,8 +844,8 @@ EXPECT_TRUE(Put(body_request_with_query_, body_response_with_query_)); EXPECT_TRUE(Put(no_body_request_, no_body_response_)); - scoped_ptr<CacheStorageCache::Responses> responses; - scoped_ptr<CacheStorageCache::BlobDataHandles> body_handles; + std::unique_ptr<CacheStorageCache::Responses> responses; + std::unique_ptr<CacheStorageCache::BlobDataHandles> body_handles; CacheStorageCacheQueryParams match_params; match_params.ignore_search = true; EXPECT_TRUE(MatchAll(body_request_, match_params, &responses, &body_handles)); @@ -1174,7 +1179,7 @@ operation1.request = body_request_; operation1.response = body_response_; - scoped_ptr<base::RunLoop> close_loop1(new base::RunLoop()); + std::unique_ptr<base::RunLoop> close_loop1(new base::RunLoop()); cache_->BatchOperation( std::vector<CacheStorageBatchOperation>(1, operation1), base::Bind(&CacheStorageCacheTest::SequenceCallback, @@ -1189,7 +1194,7 @@ operation2.response = body_response_; delayable_backend->set_delay_open(false); - scoped_ptr<base::RunLoop> close_loop2(new base::RunLoop()); + std::unique_ptr<base::RunLoop> close_loop2(new base::RunLoop()); cache_->BatchOperation( std::vector<CacheStorageBatchOperation>(1, operation2), base::Bind(&CacheStorageCacheTest::SequenceCallback,
diff --git a/content/browser/cache_storage/cache_storage_context_impl.h b/content/browser/cache_storage/cache_storage_context_impl.h index f404fa8..e298828 100644 --- a/content/browser/cache_storage/cache_storage_context_impl.h +++ b/content/browser/cache_storage/cache_storage_context_impl.h
@@ -5,9 +5,10 @@ #ifndef CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_CONTEXT_IMPL_H_ #define CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_CONTEXT_IMPL_H_ +#include <memory> + #include "base/files/file_path.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "content/common/content_export.h" #include "content/public/browser/cache_storage_context.h" #include "content/public/browser/cache_storage_usage_info.h" @@ -81,7 +82,7 @@ bool is_incognito_ = false; // Only accessed on the IO thread. - scoped_ptr<CacheStorageManager> cache_manager_; + std::unique_ptr<CacheStorageManager> cache_manager_; }; } // namespace content
diff --git a/content/browser/cache_storage/cache_storage_dispatcher_host.cc b/content/browser/cache_storage/cache_storage_dispatcher_host.cc index f371be94..a12c93d6 100644 --- a/content/browser/cache_storage/cache_storage_dispatcher_host.cc +++ b/content/browser/cache_storage/cache_storage_dispatcher_host.cc
@@ -190,7 +190,7 @@ bad_message::ReceivedBadMessage(this, bad_message::CSDH_INVALID_ORIGIN); return; } - scoped_ptr<ServiceWorkerFetchRequest> scoped_request( + std::unique_ptr<ServiceWorkerFetchRequest> scoped_request( new ServiceWorkerFetchRequest(request.url, request.method, request.headers, request.referrer, request.is_reload)); @@ -223,7 +223,7 @@ } scoped_refptr<CacheStorageCache> cache = it->second; - scoped_ptr<ServiceWorkerFetchRequest> scoped_request( + std::unique_ptr<ServiceWorkerFetchRequest> scoped_request( new ServiceWorkerFetchRequest(request.url, request.method, request.headers, request.referrer, request.is_reload)); @@ -248,13 +248,13 @@ scoped_refptr<CacheStorageCache> cache = it->second; if (request.url.is_empty()) { cache->MatchAll( - scoped_ptr<ServiceWorkerFetchRequest>(), match_params, + std::unique_ptr<ServiceWorkerFetchRequest>(), match_params, base::Bind(&CacheStorageDispatcherHost::OnCacheMatchAllCallback, this, thread_id, request_id, cache)); return; } - scoped_ptr<ServiceWorkerFetchRequest> scoped_request( + std::unique_ptr<ServiceWorkerFetchRequest> scoped_request( new ServiceWorkerFetchRequest(request.url, request.method, request.headers, request.referrer, request.is_reload)); @@ -384,8 +384,8 @@ int thread_id, int request_id, CacheStorageError error, - scoped_ptr<ServiceWorkerResponse> response, - scoped_ptr<storage::BlobDataHandle> blob_data_handle) { + std::unique_ptr<ServiceWorkerResponse> response, + std::unique_ptr<storage::BlobDataHandle> blob_data_handle) { if (error != CACHE_STORAGE_OK) { Send(new CacheStorageMsg_CacheStorageMatchError( thread_id, request_id, ToWebServiceWorkerCacheError(error))); @@ -404,8 +404,8 @@ int request_id, scoped_refptr<CacheStorageCache> cache, CacheStorageError error, - scoped_ptr<ServiceWorkerResponse> response, - scoped_ptr<storage::BlobDataHandle> blob_data_handle) { + std::unique_ptr<ServiceWorkerResponse> response, + std::unique_ptr<storage::BlobDataHandle> blob_data_handle) { if (error != CACHE_STORAGE_OK) { Send(new CacheStorageMsg_CacheMatchError( thread_id, request_id, ToWebServiceWorkerCacheError(error))); @@ -423,11 +423,11 @@ int request_id, scoped_refptr<CacheStorageCache> cache, CacheStorageError error, - scoped_ptr<ServiceWorkerResponse> response, - scoped_ptr<storage::BlobDataHandle> blob_data_handle) { - scoped_ptr<CacheStorageCache::Responses> responses( + std::unique_ptr<ServiceWorkerResponse> response, + std::unique_ptr<storage::BlobDataHandle> blob_data_handle) { + std::unique_ptr<CacheStorageCache::Responses> responses( new CacheStorageCache::Responses); - scoped_ptr<CacheStorageCache::BlobDataHandles> blob_data_handles( + std::unique_ptr<CacheStorageCache::BlobDataHandles> blob_data_handles( new CacheStorageCache::BlobDataHandles); if (error == CACHE_STORAGE_OK) { DCHECK(response); @@ -444,8 +444,8 @@ int request_id, scoped_refptr<CacheStorageCache> cache, CacheStorageError error, - scoped_ptr<CacheStorageCache::Responses> responses, - scoped_ptr<CacheStorageCache::BlobDataHandles> blob_data_handles) { + std::unique_ptr<CacheStorageCache::Responses> responses, + std::unique_ptr<CacheStorageCache::BlobDataHandles> blob_data_handles) { if (error != CACHE_STORAGE_OK && error != CACHE_STORAGE_ERROR_NOT_FOUND) { Send(new CacheStorageMsg_CacheMatchAllError( thread_id, request_id, ToWebServiceWorkerCacheError(error))); @@ -464,7 +464,7 @@ int request_id, scoped_refptr<CacheStorageCache> cache, CacheStorageError error, - scoped_ptr<CacheStorageCache::Requests> requests) { + std::unique_ptr<CacheStorageCache::Requests> requests) { if (error != CACHE_STORAGE_OK) { Send(new CacheStorageMsg_CacheKeysError( thread_id, request_id, ToWebServiceWorkerCacheError(error)));
diff --git a/content/browser/cache_storage/cache_storage_dispatcher_host.h b/content/browser/cache_storage/cache_storage_dispatcher_host.h index 14cfe30..a62755f 100644 --- a/content/browser/cache_storage/cache_storage_dispatcher_host.h +++ b/content/browser/cache_storage/cache_storage_dispatcher_host.h
@@ -111,8 +111,8 @@ int thread_id, int request_id, CacheStorageError error, - scoped_ptr<ServiceWorkerResponse> response, - scoped_ptr<storage::BlobDataHandle> blob_data_handle); + std::unique_ptr<ServiceWorkerResponse> response, + std::unique_ptr<storage::BlobDataHandle> blob_data_handle); // Cache callbacks. void OnCacheMatchCallback( @@ -120,32 +120,33 @@ int request_id, scoped_refptr<CacheStorageCache> cache, CacheStorageError error, - scoped_ptr<ServiceWorkerResponse> response, - scoped_ptr<storage::BlobDataHandle> blob_data_handle); + std::unique_ptr<ServiceWorkerResponse> response, + std::unique_ptr<storage::BlobDataHandle> blob_data_handle); void OnCacheMatchAllCallbackAdapter( int thread_id, int request_id, scoped_refptr<CacheStorageCache> cache, CacheStorageError error, - scoped_ptr<ServiceWorkerResponse> response, - scoped_ptr<storage::BlobDataHandle> blob_data_handle); + std::unique_ptr<ServiceWorkerResponse> response, + std::unique_ptr<storage::BlobDataHandle> blob_data_handle); void OnCacheMatchAllCallback( int thread_id, int request_id, scoped_refptr<CacheStorageCache> cache, CacheStorageError error, - scoped_ptr<std::vector<ServiceWorkerResponse>> responses, - scoped_ptr<CacheStorageCache::BlobDataHandles> blob_data_handles); + std::unique_ptr<std::vector<ServiceWorkerResponse>> responses, + std::unique_ptr<CacheStorageCache::BlobDataHandles> blob_data_handles); void OnCacheMatchAll(int thread_id, int request_id, int cache_id, const ServiceWorkerFetchRequest& request, const CacheStorageCacheQueryParams& match_params); - void OnCacheKeysCallback(int thread_id, - int request_id, - scoped_refptr<CacheStorageCache> cache, - CacheStorageError error, - scoped_ptr<CacheStorageCache::Requests> requests); + void OnCacheKeysCallback( + int thread_id, + int request_id, + scoped_refptr<CacheStorageCache> cache, + CacheStorageError error, + std::unique_ptr<CacheStorageCache::Requests> requests); void OnCacheBatchCallback(int thread_id, int request_id, scoped_refptr<CacheStorageCache> cache,
diff --git a/content/browser/cache_storage/cache_storage_manager.cc b/content/browser/cache_storage/cache_storage_manager.cc index be2c6d7c..f58fb61 100644 --- a/content/browser/cache_storage/cache_storage_manager.cc +++ b/content/browser/cache_storage/cache_storage_manager.cc
@@ -5,6 +5,7 @@ #include "content/browser/cache_storage/cache_storage_manager.h" #include <stdint.h> + #include <map> #include <string> #include <utility> @@ -14,6 +15,7 @@ #include "base/files/file_enumerator.h" #include "base/files/file_util.h" #include "base/id_map.h" +#include "base/memory/ptr_util.h" #include "base/sha1.h" #include "base/stl_util.h" #include "base/strings/string_number_conversions.h" @@ -101,7 +103,7 @@ void EmptyQuotaStatusCallback(storage::QuotaStatusCode code) {} void AllOriginSizesReported( - scoped_ptr<std::vector<CacheStorageUsageInfo>> usages, + std::unique_ptr<std::vector<CacheStorageUsageInfo>> usages, const CacheStorageContext::GetUsageInfoCallback& callback) { DCHECK_CURRENTLY_ON(BrowserThread::IO); @@ -121,7 +123,7 @@ } // namespace // static -scoped_ptr<CacheStorageManager> CacheStorageManager::Create( +std::unique_ptr<CacheStorageManager> CacheStorageManager::Create( const base::FilePath& path, scoped_refptr<base::SequencedTaskRunner> cache_task_runner, scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy) { @@ -131,14 +133,14 @@ .AppendASCII("CacheStorage"); } - return make_scoped_ptr(new CacheStorageManager( + return base::WrapUnique(new CacheStorageManager( root_path, std::move(cache_task_runner), std::move(quota_manager_proxy))); } // static -scoped_ptr<CacheStorageManager> CacheStorageManager::Create( +std::unique_ptr<CacheStorageManager> CacheStorageManager::Create( CacheStorageManager* old_manager) { - scoped_ptr<CacheStorageManager> manager(new CacheStorageManager( + std::unique_ptr<CacheStorageManager> manager(new CacheStorageManager( old_manager->root_path(), old_manager->cache_task_runner(), old_manager->quota_manager_proxy_.get())); // These values may be NULL, in which case this will be called again later by @@ -194,7 +196,7 @@ void CacheStorageManager::MatchCache( const GURL& origin, const std::string& cache_name, - scoped_ptr<ServiceWorkerFetchRequest> request, + std::unique_ptr<ServiceWorkerFetchRequest> request, const CacheStorageCache::ResponseCallback& callback) { CacheStorage* cache_storage = FindOrCreateCacheStorage(origin); @@ -203,7 +205,7 @@ void CacheStorageManager::MatchAllCaches( const GURL& origin, - scoped_ptr<ServiceWorkerFetchRequest> request, + std::unique_ptr<ServiceWorkerFetchRequest> request, const CacheStorageCache::ResponseCallback& callback) { CacheStorage* cache_storage = FindOrCreateCacheStorage(origin); @@ -226,7 +228,7 @@ const CacheStorageContext::GetUsageInfoCallback& callback) { DCHECK_CURRENTLY_ON(BrowserThread::IO); - scoped_ptr<std::vector<CacheStorageUsageInfo>> usages( + std::unique_ptr<std::vector<CacheStorageUsageInfo>> usages( new std::vector<CacheStorageUsageInfo>()); if (IsMemoryBacked()) { @@ -249,7 +251,7 @@ } void CacheStorageManager::GetAllOriginsUsageGetSizes( - scoped_ptr<std::vector<CacheStorageUsageInfo>> usages, + std::unique_ptr<std::vector<CacheStorageUsageInfo>> usages, const CacheStorageContext::GetUsageInfoCallback& callback) { DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK(usages); @@ -343,7 +345,7 @@ cache_storage->GetSizeThenCloseAllCaches( base::Bind(&CacheStorageManager::DeleteOriginDidClose, weak_ptr_factory_.GetWeakPtr(), origin, callback, - base::Passed(make_scoped_ptr(cache_storage)))); + base::Passed(base::WrapUnique(cache_storage)))); } void CacheStorageManager::DeleteOriginData(const GURL& origin) { @@ -354,7 +356,7 @@ void CacheStorageManager::DeleteOriginDidClose( const GURL& origin, const storage::QuotaClient::DeletionCallback& callback, - scoped_ptr<CacheStorage> cache_storage, + std::unique_ptr<CacheStorage> cache_storage, int64_t origin_size) { // TODO(jkarlin): Deleting the storage leaves any unfinished operations // hanging, resulting in unresolved promises. Fix this by returning early from @@ -404,7 +406,7 @@ cache_task_runner_.get(), request_context_getter_, quota_manager_proxy_, blob_context_, origin); cache_storage_map_.insert( - std::make_pair(origin, make_scoped_ptr(cache_storage))); + std::make_pair(origin, base::WrapUnique(cache_storage))); return cache_storage; } return it->second.get();
diff --git a/content/browser/cache_storage/cache_storage_manager.h b/content/browser/cache_storage/cache_storage_manager.h index ded3703..1793d8f 100644 --- a/content/browser/cache_storage/cache_storage_manager.h +++ b/content/browser/cache_storage/cache_storage_manager.h
@@ -38,12 +38,12 @@ // longer in active use. class CONTENT_EXPORT CacheStorageManager { public: - static scoped_ptr<CacheStorageManager> Create( + static std::unique_ptr<CacheStorageManager> Create( const base::FilePath& path, scoped_refptr<base::SequencedTaskRunner> cache_task_runner, scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy); - static scoped_ptr<CacheStorageManager> Create( + static std::unique_ptr<CacheStorageManager> Create( CacheStorageManager* old_manager); // Map a database identifier (computed from an origin) to the path. @@ -67,10 +67,10 @@ const CacheStorage::StringsAndErrorCallback& callback); void MatchCache(const GURL& origin, const std::string& cache_name, - scoped_ptr<ServiceWorkerFetchRequest> request, + std::unique_ptr<ServiceWorkerFetchRequest> request, const CacheStorageCache::ResponseCallback& callback); void MatchAllCaches(const GURL& origin, - scoped_ptr<ServiceWorkerFetchRequest> request, + std::unique_ptr<ServiceWorkerFetchRequest> request, const CacheStorageCache::ResponseCallback& callback); // This must be called before creating any of the public *Cache functions @@ -91,7 +91,7 @@ friend class CacheStorageMigrationTest; friend class CacheStorageQuotaClient; - typedef std::map<GURL, scoped_ptr<CacheStorage>> CacheStorageMap; + typedef std::map<GURL, std::unique_ptr<CacheStorage>> CacheStorageMap; CacheStorageManager( const base::FilePath& path, @@ -105,7 +105,7 @@ void GetAllOriginsUsage( const CacheStorageContext::GetUsageInfoCallback& callback); void GetAllOriginsUsageGetSizes( - scoped_ptr<std::vector<CacheStorageUsageInfo>> usage_info, + std::unique_ptr<std::vector<CacheStorageUsageInfo>> usage_info, const CacheStorageContext::GetUsageInfoCallback& callback); void GetOriginUsage(const GURL& origin_url, @@ -120,7 +120,7 @@ void DeleteOriginDidClose( const GURL& origin, const storage::QuotaClient::DeletionCallback& callback, - scoped_ptr<CacheStorage> cache_storage, + std::unique_ptr<CacheStorage> cache_storage, int64_t origin_size); scoped_refptr<net::URLRequestContextGetter> url_request_context_getter()
diff --git a/content/browser/cache_storage/cache_storage_manager_unittest.cc b/content/browser/cache_storage/cache_storage_manager_unittest.cc index dec8cfa..95560c86 100644 --- a/content/browser/cache_storage/cache_storage_manager_unittest.cc +++ b/content/browser/cache_storage/cache_storage_manager_unittest.cc
@@ -6,6 +6,7 @@ #include <stddef.h> #include <stdint.h> + #include <utility> #include "base/files/file_path.h" @@ -13,6 +14,7 @@ #include "base/files/scoped_temp_dir.h" #include "base/guid.h" #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/run_loop.h" #include "base/sha1.h" #include "base/stl_util.h" @@ -41,11 +43,11 @@ // Returns a BlobProtocolHandler that uses |blob_storage_context|. Caller owns // the memory. -scoped_ptr<storage::BlobProtocolHandler> CreateMockBlobProtocolHandler( +std::unique_ptr<storage::BlobProtocolHandler> CreateMockBlobProtocolHandler( storage::BlobStorageContext* blob_storage_context) { // The FileSystemContext and thread task runner are not actually used but a // task runner is needed to avoid a DCHECK in BlobURLRequestJob ctor. - return make_scoped_ptr(new storage::BlobProtocolHandler( + return base::WrapUnique(new storage::BlobProtocolHandler( blob_storage_context, NULL, base::ThreadTaskRunnerHandle::Get().get())); } @@ -140,8 +142,8 @@ void CacheMatchCallback( base::RunLoop* run_loop, CacheStorageError error, - scoped_ptr<ServiceWorkerResponse> response, - scoped_ptr<storage::BlobDataHandle> blob_data_handle) { + std::unique_ptr<ServiceWorkerResponse> response, + std::unique_ptr<storage::BlobDataHandle> blob_data_handle) { callback_error_ = error; callback_cache_response_ = std::move(response); callback_data_handle_ = std::move(blob_data_handle); @@ -199,7 +201,7 @@ bool StorageMatch(const GURL& origin, const std::string& cache_name, const GURL& url) { - scoped_ptr<ServiceWorkerFetchRequest> request( + std::unique_ptr<ServiceWorkerFetchRequest> request( new ServiceWorkerFetchRequest()); request->url = url; base::RunLoop loop; @@ -213,7 +215,7 @@ } bool StorageMatchAll(const GURL& origin, const GURL& url) { - scoped_ptr<ServiceWorkerFetchRequest> request( + std::unique_ptr<ServiceWorkerFetchRequest> request( new ServiceWorkerFetchRequest()); request->url = url; base::RunLoop loop; @@ -236,11 +238,11 @@ ServiceWorkerFetchRequest request; request.url = url; - scoped_ptr<storage::BlobDataBuilder> blob_data( + std::unique_ptr<storage::BlobDataBuilder> blob_data( new storage::BlobDataBuilder(base::GenerateGUID())); blob_data->AppendData(url.spec()); - scoped_ptr<storage::BlobDataHandle> blob_handle = + std::unique_ptr<storage::BlobDataHandle> blob_handle = blob_storage_context_->AddFinishedBlob(blob_data.get()); ServiceWorkerResponse response( url, status_code, "OK", blink::WebServiceWorkerResponseTypeDefault, @@ -265,7 +267,7 @@ } bool CacheMatch(CacheStorageCache* cache, const GURL& url) { - scoped_ptr<ServiceWorkerFetchRequest> request( + std::unique_ptr<ServiceWorkerFetchRequest> request( new ServiceWorkerFetchRequest()); request->url = url; base::RunLoop loop; @@ -336,19 +338,19 @@ TestBrowserContext browser_context_; TestBrowserThreadBundle browser_thread_bundle_; - scoped_ptr<net::URLRequestJobFactoryImpl> url_request_job_factory_; + std::unique_ptr<net::URLRequestJobFactoryImpl> url_request_job_factory_; storage::BlobStorageContext* blob_storage_context_; scoped_refptr<MockSpecialStoragePolicy> quota_policy_; scoped_refptr<MockQuotaManager> mock_quota_manager_; scoped_refptr<MockQuotaManagerProxy> quota_manager_proxy_; - scoped_ptr<CacheStorageManager> cache_manager_; + std::unique_ptr<CacheStorageManager> cache_manager_; scoped_refptr<CacheStorageCache> callback_cache_; int callback_bool_; CacheStorageError callback_error_; - scoped_ptr<ServiceWorkerResponse> callback_cache_response_; - scoped_ptr<storage::BlobDataHandle> callback_data_handle_; + std::unique_ptr<ServiceWorkerResponse> callback_cache_response_; + std::unique_ptr<storage::BlobDataHandle> callback_data_handle_; std::vector<std::string> callback_strings_; const GURL origin1_; @@ -516,7 +518,7 @@ EXPECT_TRUE(Open(origin1_, "foo")); EXPECT_TRUE(CachePut(callback_cache_.get(), kTestURL)); EXPECT_TRUE(CacheMatch(callback_cache_.get(), kTestURL)); - scoped_ptr<storage::BlobDataHandle> data_handle = + std::unique_ptr<storage::BlobDataHandle> data_handle = std::move(callback_data_handle_); EXPECT_TRUE(Delete(origin1_, "foo")); @@ -1036,7 +1038,7 @@ return quota_client_->DoesSupport(type); } - scoped_ptr<CacheStorageQuotaClient> quota_client_; + std::unique_ptr<CacheStorageQuotaClient> quota_client_; storage::QuotaStatusCode callback_status_; int64_t callback_quota_usage_ = 0;
diff --git a/content/browser/cache_storage/cache_storage_unittest.cc b/content/browser/cache_storage/cache_storage_unittest.cc index 9c0081b..ee6eaf6 100644 --- a/content/browser/cache_storage/cache_storage_unittest.cc +++ b/content/browser/cache_storage/cache_storage_unittest.cc
@@ -108,7 +108,7 @@ scoped_refptr<MockSpecialStoragePolicy> quota_policy_; scoped_refptr<MockQuotaManager> mock_quota_manager_; scoped_refptr<MockQuotaManagerProxy> quota_manager_proxy_; - scoped_ptr<TestCacheStorage> test_cache_storage_; + std::unique_ptr<TestCacheStorage> test_cache_storage_; scoped_refptr<CacheStorageCache> callback_cache_; CacheStorageError callback_error_;
diff --git a/content/browser/child_process_launcher.cc b/content/browser/child_process_launcher.cc index 47205b6..e67e107e 100644 --- a/content/browser/child_process_launcher.cc +++ b/content/browser/child_process_launcher.cc
@@ -4,6 +4,7 @@ #include "content/browser/child_process_launcher.h" +#include <memory> #include <utility> #include "base/bind.h" @@ -11,7 +12,6 @@ #include "base/files/file_util.h" #include "base/i18n/icu_util.h" #include "base/logging.h" -#include "base/memory/scoped_ptr.h" #include "base/metrics/histogram.h" #include "base/process/launch.h" #include "base/process/process.h" @@ -117,7 +117,7 @@ mojo::edk::ScopedPlatformHandle client_handle, base::CommandLine* cmd_line) { DCHECK_CURRENTLY_ON(BrowserThread::PROCESS_LAUNCHER); - scoped_ptr<SandboxedProcessLauncherDelegate> delegate_deleter(delegate); + std::unique_ptr<SandboxedProcessLauncherDelegate> delegate_deleter(delegate); #if !defined(OS_ANDROID) ZygoteHandle zygote = nullptr; #endif @@ -130,7 +130,7 @@ base::EnvironmentMap env = delegate->GetEnvironment(); base::ScopedFD ipcfd = delegate->TakeIpcFd(); #endif - scoped_ptr<base::CommandLine> cmd_line_deleter(cmd_line); + std::unique_ptr<base::CommandLine> cmd_line_deleter(cmd_line); base::TimeTicks begin_launch_time = base::TimeTicks::Now(); base::Process process; @@ -153,7 +153,7 @@ #elif defined(OS_POSIX) std::string process_type = cmd_line->GetSwitchValueASCII(switches::kProcessType); - scoped_ptr<FileDescriptorInfo> files_to_register( + std::unique_ptr<FileDescriptorInfo> files_to_register( FileDescriptorInfoImpl::Create()); base::ScopedFD mojo_fd(client_handle.release().handle); @@ -304,7 +304,7 @@ broker->EnsureRunning(); const SandboxType sandbox_type = delegate->GetSandboxType(); - scoped_ptr<sandbox::PreExecDelegate> pre_exec_delegate; + std::unique_ptr<sandbox::PreExecDelegate> pre_exec_delegate; if (BootstrapSandboxManager::ShouldEnable()) { BootstrapSandboxManager* sandbox_manager = BootstrapSandboxManager::GetInstance();
diff --git a/content/browser/cocoa/system_hotkey_helper_mac.h b/content/browser/cocoa/system_hotkey_helper_mac.h index 004b2087..19ecb888 100644 --- a/content/browser/cocoa/system_hotkey_helper_mac.h +++ b/content/browser/cocoa/system_hotkey_helper_mac.h
@@ -5,8 +5,9 @@ #ifndef CONTENT_BROWSER_COCOA_SYSTEM_HOTKEY_HELPER_MAC_H_ #define CONTENT_BROWSER_COCOA_SYSTEM_HOTKEY_HELPER_MAC_H_ +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/singleton.h" #include "base/memory/weak_ptr.h" @@ -48,7 +49,7 @@ // Parses the system hotkeys from the plist stored in |dictionary|. void FileDidLoad(NSDictionary* dictionary); - scoped_ptr<SystemHotkeyMap> map_; + std::unique_ptr<SystemHotkeyMap> map_; DISALLOW_COPY_AND_ASSIGN(SystemHotkeyHelperMac); };
diff --git a/content/browser/compositor/browser_compositor_output_surface.cc b/content/browser/compositor/browser_compositor_output_surface.cc index f865702..900845d 100644 --- a/content/browser/compositor/browser_compositor_output_surface.cc +++ b/content/browser/compositor/browser_compositor_output_surface.cc
@@ -21,27 +21,27 @@ const scoped_refptr<cc::ContextProvider>& context_provider, const scoped_refptr<cc::ContextProvider>& worker_context_provider, const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, - scoped_ptr<BrowserCompositorOverlayCandidateValidator> + std::unique_ptr<BrowserCompositorOverlayCandidateValidator> overlay_candidate_validator) : OutputSurface(context_provider, worker_context_provider), vsync_manager_(vsync_manager), reflector_(nullptr), use_begin_frame_scheduling_( - base::CommandLine::ForCurrentProcess() - ->HasSwitch(cc::switches::kEnableBeginFrameScheduling)) { + base::CommandLine::ForCurrentProcess()->HasSwitch( + cc::switches::kEnableBeginFrameScheduling)) { overlay_candidate_validator_ = std::move(overlay_candidate_validator); Initialize(); } BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( - scoped_ptr<cc::SoftwareOutputDevice> software_device, + std::unique_ptr<cc::SoftwareOutputDevice> software_device, const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager) : OutputSurface(std::move(software_device)), vsync_manager_(vsync_manager), reflector_(nullptr), use_begin_frame_scheduling_( - base::CommandLine::ForCurrentProcess() - ->HasSwitch(cc::switches::kEnableBeginFrameScheduling)) { + base::CommandLine::ForCurrentProcess()->HasSwitch( + cc::switches::kEnableBeginFrameScheduling)) { Initialize(); }
diff --git a/content/browser/compositor/browser_compositor_output_surface.h b/content/browser/compositor/browser_compositor_output_surface.h index 9ea5c719..c5ddab1 100644 --- a/content/browser/compositor/browser_compositor_output_surface.h +++ b/content/browser/compositor/browser_compositor_output_surface.h
@@ -5,8 +5,9 @@ #ifndef CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_OUTPUT_SURFACE_H_ #define CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_OUTPUT_SURFACE_H_ +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/threading/non_thread_safe.h" #include "build/build_config.h" #include "cc/output/output_surface.h" @@ -69,12 +70,12 @@ const scoped_refptr<cc::ContextProvider>& context, const scoped_refptr<cc::ContextProvider>& worker_context, const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, - scoped_ptr<BrowserCompositorOverlayCandidateValidator> + std::unique_ptr<BrowserCompositorOverlayCandidateValidator> overlay_candidate_validator); // Constructor used by the software implementation. BrowserCompositorOutputSurface( - scoped_ptr<cc::SoftwareOutputDevice> software_device, + std::unique_ptr<cc::SoftwareOutputDevice> software_device, const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager); scoped_refptr<ui::CompositorVSyncManager> vsync_manager_; @@ -86,7 +87,7 @@ private: void Initialize(); - scoped_ptr<BrowserCompositorOverlayCandidateValidator> + std::unique_ptr<BrowserCompositorOverlayCandidateValidator> overlay_candidate_validator_; DISALLOW_COPY_AND_ASSIGN(BrowserCompositorOutputSurface);
diff --git a/content/browser/compositor/browser_compositor_overlay_candidate_validator_android.cc b/content/browser/compositor/browser_compositor_overlay_candidate_validator_android.cc index 4ed6af6..e04a241 100644 --- a/content/browser/compositor/browser_compositor_overlay_candidate_validator_android.cc +++ b/content/browser/compositor/browser_compositor_overlay_candidate_validator_android.cc
@@ -4,7 +4,9 @@ #include "content/browser/compositor/browser_compositor_overlay_candidate_validator_android.h" -#include "base/memory/scoped_ptr.h" +#include <memory> + +#include "base/memory/ptr_util.h" #include "cc/output/overlay_processor.h" #include "cc/output/overlay_strategy_underlay.h" #include "ui/gfx/geometry/rect_conversions.h" @@ -19,7 +21,8 @@ void BrowserCompositorOverlayCandidateValidatorAndroid::GetStrategies( cc::OverlayProcessor::StrategyList* strategies) { - strategies->push_back(make_scoped_ptr(new cc::OverlayStrategyUnderlay(this))); + strategies->push_back( + base::WrapUnique(new cc::OverlayStrategyUnderlay(this))); } void BrowserCompositorOverlayCandidateValidatorAndroid::CheckOverlaySupport(
diff --git a/content/browser/compositor/browser_compositor_overlay_candidate_validator_mac.h b/content/browser/compositor/browser_compositor_overlay_candidate_validator_mac.h index d3b1bd1..4aee133 100644 --- a/content/browser/compositor/browser_compositor_overlay_candidate_validator_mac.h +++ b/content/browser/compositor/browser_compositor_overlay_candidate_validator_mac.h
@@ -5,8 +5,9 @@ #ifndef CONTENT_BROWSER_COMPOSITOR_OVERLAY_CANDIDATE_VALIDATOR_MAC_H_ #define CONTENT_BROWSER_COMPOSITOR_OVERLAY_CANDIDATE_VALIDATOR_MAC_H_ +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/compositor/browser_compositor_overlay_candidate_validator.h" #include "ui/gfx/native_widget_types.h"
diff --git a/content/browser/compositor/browser_compositor_overlay_candidate_validator_ozone.cc b/content/browser/compositor/browser_compositor_overlay_candidate_validator_ozone.cc index dae75cf..97f2d92 100644 --- a/content/browser/compositor/browser_compositor_overlay_candidate_validator_ozone.cc +++ b/content/browser/compositor/browser_compositor_overlay_candidate_validator_ozone.cc
@@ -5,8 +5,10 @@ #include "content/browser/compositor/browser_compositor_overlay_candidate_validator_ozone.h" #include <stddef.h> + #include <utility> +#include "base/memory/ptr_util.h" #include "cc/output/overlay_strategy_single_on_top.h" #include "cc/output/overlay_strategy_underlay.h" #include "ui/ozone/public/overlay_candidates_ozone.h" @@ -28,7 +30,7 @@ BrowserCompositorOverlayCandidateValidatorOzone:: BrowserCompositorOverlayCandidateValidatorOzone( gfx::AcceleratedWidget widget, - scoped_ptr<ui::OverlayCandidatesOzone> overlay_candidates) + std::unique_ptr<ui::OverlayCandidatesOzone> overlay_candidates) : widget_(widget), overlay_candidates_(std::move(overlay_candidates)), software_mirror_active_(false) {} @@ -40,8 +42,9 @@ void BrowserCompositorOverlayCandidateValidatorOzone::GetStrategies( cc::OverlayProcessor::StrategyList* strategies) { strategies->push_back( - make_scoped_ptr(new cc::OverlayStrategySingleOnTop(this))); - strategies->push_back(make_scoped_ptr(new cc::OverlayStrategyUnderlay(this))); + base::WrapUnique(new cc::OverlayStrategySingleOnTop(this))); + strategies->push_back( + base::WrapUnique(new cc::OverlayStrategyUnderlay(this))); } bool BrowserCompositorOverlayCandidateValidatorOzone::AllowCALayerOverlays() {
diff --git a/content/browser/compositor/browser_compositor_overlay_candidate_validator_ozone.h b/content/browser/compositor/browser_compositor_overlay_candidate_validator_ozone.h index 0ad4855..8afd295f 100644 --- a/content/browser/compositor/browser_compositor_overlay_candidate_validator_ozone.h +++ b/content/browser/compositor/browser_compositor_overlay_candidate_validator_ozone.h
@@ -5,8 +5,9 @@ #ifndef CONTENT_BROWSER_COMPOSITOR_OVERLAY_CANDIDATE_VALIDATOR_OZONE_H_ #define CONTENT_BROWSER_COMPOSITOR_OVERLAY_CANDIDATE_VALIDATOR_OZONE_H_ +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/compositor/browser_compositor_overlay_candidate_validator.h" #include "ui/gfx/native_widget_types.h" @@ -21,7 +22,7 @@ public: BrowserCompositorOverlayCandidateValidatorOzone( gfx::AcceleratedWidget widget, - scoped_ptr<ui::OverlayCandidatesOzone> overlay_candidates); + std::unique_ptr<ui::OverlayCandidatesOzone> overlay_candidates); ~BrowserCompositorOverlayCandidateValidatorOzone() override; // cc::OverlayCandidateValidator implementation. @@ -34,7 +35,7 @@ private: gfx::AcceleratedWidget widget_; - scoped_ptr<ui::OverlayCandidatesOzone> overlay_candidates_; + std::unique_ptr<ui::OverlayCandidatesOzone> overlay_candidates_; bool software_mirror_active_; DISALLOW_COPY_AND_ASSIGN(BrowserCompositorOverlayCandidateValidatorOzone);
diff --git a/content/browser/compositor/buffer_queue.cc b/content/browser/compositor/buffer_queue.cc index cafb6d96..e5c60b9 100644 --- a/content/browser/compositor/buffer_queue.cc +++ b/content/browser/compositor/buffer_queue.cc
@@ -5,6 +5,7 @@ #include "content/browser/compositor/buffer_queue.h" #include "base/containers/adapters.h" +#include "base/memory/ptr_util.h" #include "build/build_config.h" #include "content/browser/compositor/gl_helper.h" #include "content/browser/compositor/image_transport_factory.h" @@ -156,12 +157,12 @@ } } -scoped_ptr<BufferQueue::AllocatedSurface> BufferQueue::RecreateBuffer( - scoped_ptr<AllocatedSurface> surface) { +std::unique_ptr<BufferQueue::AllocatedSurface> BufferQueue::RecreateBuffer( + std::unique_ptr<AllocatedSurface> surface) { if (!surface) return nullptr; - scoped_ptr<AllocatedSurface> new_surface(GetNextSurface()); + std::unique_ptr<AllocatedSurface> new_surface(GetNextSurface()); if (!new_surface) return nullptr; @@ -204,9 +205,9 @@ allocated_count_--; } -scoped_ptr<BufferQueue::AllocatedSurface> BufferQueue::GetNextSurface() { +std::unique_ptr<BufferQueue::AllocatedSurface> BufferQueue::GetNextSurface() { if (!available_surfaces_.empty()) { - scoped_ptr<AllocatedSurface> surface = + std::unique_ptr<AllocatedSurface> surface = std::move(available_surfaces_.back()); available_surfaces_.pop_back(); return surface; @@ -221,7 +222,7 @@ // We don't want to allow anything more than triple buffering. DCHECK_LT(allocated_count_, 4U); - scoped_ptr<gfx::GpuMemoryBuffer> buffer( + std::unique_ptr<gfx::GpuMemoryBuffer> buffer( gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer( size_, gpu::DefaultBufferFormatForImageFormat(internal_format_), gfx::BufferUsage::SCANOUT, surface_id_)); @@ -243,13 +244,13 @@ allocated_count_++; gl->BindTexture(texture_target_, texture); gl->BindTexImage2DCHROMIUM(texture_target_, id); - return make_scoped_ptr(new AllocatedSurface(this, std::move(buffer), texture, - id, gfx::Rect(size_))); + return base::WrapUnique(new AllocatedSurface(this, std::move(buffer), texture, + id, gfx::Rect(size_))); } BufferQueue::AllocatedSurface::AllocatedSurface( BufferQueue* buffer_queue, - scoped_ptr<gfx::GpuMemoryBuffer> buffer, + std::unique_ptr<gfx::GpuMemoryBuffer> buffer, unsigned int texture, unsigned int image, const gfx::Rect& rect)
diff --git a/content/browser/compositor/buffer_queue.h b/content/browser/compositor/buffer_queue.h index 47b4a7dd..772501c5 100644 --- a/content/browser/compositor/buffer_queue.h +++ b/content/browser/compositor/buffer_queue.h
@@ -8,11 +8,11 @@ #include <stddef.h> #include <deque> +#include <memory> #include <vector> #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "content/common/content_export.h" #include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/size.h" @@ -67,13 +67,13 @@ struct CONTENT_EXPORT AllocatedSurface { AllocatedSurface(BufferQueue* buffer_queue, - scoped_ptr<gfx::GpuMemoryBuffer> buffer, + std::unique_ptr<gfx::GpuMemoryBuffer> buffer, unsigned int texture, unsigned int image, const gfx::Rect& rect); ~AllocatedSurface(); BufferQueue* const buffer_queue; - scoped_ptr<gfx::GpuMemoryBuffer> buffer; + std::unique_ptr<gfx::GpuMemoryBuffer> buffer; const unsigned int texture; const unsigned int image; gfx::Rect damage; // This is the damage for this frame from the previous. @@ -93,10 +93,10 @@ void UpdateBufferDamage(const gfx::Rect& damage); // Return a surface, available to be drawn into. - scoped_ptr<AllocatedSurface> GetNextSurface(); + std::unique_ptr<AllocatedSurface> GetNextSurface(); - scoped_ptr<AllocatedSurface> RecreateBuffer( - scoped_ptr<AllocatedSurface> surface); + std::unique_ptr<AllocatedSurface> RecreateBuffer( + std::unique_ptr<AllocatedSurface> surface); gfx::Size size_; scoped_refptr<cc::ContextProvider> context_provider_; @@ -106,14 +106,14 @@ unsigned int internal_format_; // This surface is currently bound. This may be nullptr if no surface has // been bound, or if allocation failed at bind. - scoped_ptr<AllocatedSurface> current_surface_; + std::unique_ptr<AllocatedSurface> current_surface_; // The surface currently on the screen, if any. - scoped_ptr<AllocatedSurface> displayed_surface_; + std::unique_ptr<AllocatedSurface> displayed_surface_; // These are free for use, and are not nullptr. - std::vector<scoped_ptr<AllocatedSurface>> available_surfaces_; + std::vector<std::unique_ptr<AllocatedSurface>> available_surfaces_; // These have been swapped but are not displayed yet. Entries of this deque // may be nullptr, if they represent frames that have been destroyed. - std::deque<scoped_ptr<AllocatedSurface>> in_flight_surfaces_; + std::deque<std::unique_ptr<AllocatedSurface>> in_flight_surfaces_; GLHelper* gl_helper_; gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; int surface_id_;
diff --git a/content/browser/compositor/buffer_queue_unittest.cc b/content/browser/compositor/buffer_queue_unittest.cc index 6e1dc9f..96dec641 100644 --- a/content/browser/compositor/buffer_queue_unittest.cc +++ b/content/browser/compositor/buffer_queue_unittest.cc
@@ -6,9 +6,11 @@ #include <stddef.h> #include <stdint.h> + #include <set> #include <utility> +#include "base/memory/ptr_util.h" #include "cc/test/test_context_provider.h" #include "cc/test/test_web_graphics_context_3d.h" #include "content/browser/compositor/gl_helper.h" @@ -57,7 +59,7 @@ void set_allocate_succeeds(bool value) { allocate_succeeds_ = value; } - scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBuffer( + std::unique_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBuffer( const gfx::Size& size, gfx::BufferFormat format, gfx::BufferUsage usage, @@ -67,7 +69,8 @@ size, format, usage, surface_id); } if (allocate_succeeds_) - return make_scoped_ptr<gfx::GpuMemoryBuffer>(new StubGpuMemoryBufferImpl); + return base::WrapUnique<gfx::GpuMemoryBuffer>( + new StubGpuMemoryBufferImpl); return nullptr; } @@ -99,7 +102,7 @@ InitWithContext(cc::TestWebGraphicsContext3D::Create()); } - void InitWithContext(scoped_ptr<cc::TestWebGraphicsContext3D> context) { + void InitWithContext(std::unique_ptr<cc::TestWebGraphicsContext3D> context) { scoped_refptr<cc::TestContextProvider> context_provider = cc::TestContextProvider::Create(std::move(context)); context_provider->BindToCurrentThread(); @@ -116,11 +119,12 @@ ? output_surface_->current_surface_->image : 0; } - const std::vector<scoped_ptr<BufferQueue::AllocatedSurface>>& + const std::vector<std::unique_ptr<BufferQueue::AllocatedSurface>>& available_surfaces() { return output_surface_->available_surfaces_; } - std::deque<scoped_ptr<BufferQueue::AllocatedSurface>>& in_flight_surfaces() { + std::deque<std::unique_ptr<BufferQueue::AllocatedSurface>>& + in_flight_surfaces() { return output_surface_->in_flight_surfaces_; } @@ -183,8 +187,8 @@ return true; } - scoped_ptr<StubBrowserGpuMemoryBufferManager> gpu_memory_buffer_manager_; - scoped_ptr<BufferQueue> output_surface_; + std::unique_ptr<StubBrowserGpuMemoryBufferManager> gpu_memory_buffer_manager_; + std::unique_ptr<BufferQueue> output_surface_; MockBufferQueue* mock_output_surface_; bool doublebuffering_; bool first_frame_; @@ -222,23 +226,23 @@ public: void SetUp() override { context_ = new MockedContext(); - InitWithContext(scoped_ptr<cc::TestWebGraphicsContext3D>(context_)); + InitWithContext(std::unique_ptr<cc::TestWebGraphicsContext3D>(context_)); } protected: MockedContext* context_; }; -scoped_ptr<BufferQueue> CreateOutputSurfaceWithMock( +std::unique_ptr<BufferQueue> CreateOutputSurfaceWithMock( unsigned int target, MockedContext** context, BrowserGpuMemoryBufferManager* gpu_memory_buffer_manager) { *context = new MockedContext(); scoped_refptr<cc::TestContextProvider> context_provider = cc::TestContextProvider::Create( - scoped_ptr<cc::TestWebGraphicsContext3D>(*context)); + std::unique_ptr<cc::TestWebGraphicsContext3D>(*context)); context_provider->BindToCurrentThread(); - scoped_ptr<BufferQueue> buffer_queue( + std::unique_ptr<BufferQueue> buffer_queue( new BufferQueue(context_provider, target, GL_RGBA, nullptr, gpu_memory_buffer_manager, 1)); buffer_queue->Initialize(); @@ -247,9 +251,9 @@ TEST(BufferQueueStandaloneTest, FboInitialization) { MockedContext* context; - scoped_ptr<BrowserGpuMemoryBufferManager> gpu_memory_buffer_manager( + std::unique_ptr<BrowserGpuMemoryBufferManager> gpu_memory_buffer_manager( new StubBrowserGpuMemoryBufferManager); - scoped_ptr<BufferQueue> output_surface = CreateOutputSurfaceWithMock( + std::unique_ptr<BufferQueue> output_surface = CreateOutputSurfaceWithMock( GL_TEXTURE_2D, &context, gpu_memory_buffer_manager.get()); EXPECT_CALL(*context, bindFramebuffer(GL_FRAMEBUFFER, Ne(0U))); @@ -264,9 +268,9 @@ for (size_t i = 0; i < 2; ++i) { GLenum target = targets[i]; MockedContext* context; - scoped_ptr<BrowserGpuMemoryBufferManager> gpu_memory_buffer_manager( + std::unique_ptr<BrowserGpuMemoryBufferManager> gpu_memory_buffer_manager( new StubBrowserGpuMemoryBufferManager); - scoped_ptr<BufferQueue> output_surface = CreateOutputSurfaceWithMock( + std::unique_ptr<BufferQueue> output_surface = CreateOutputSurfaceWithMock( target, &context, gpu_memory_buffer_manager.get()); EXPECT_CALL(*context, bindTexture(target, Ne(0U))); EXPECT_CALL(*context, destroyImageCHROMIUM(1)); @@ -290,14 +294,14 @@ } TEST(BufferQueueStandaloneTest, CheckBoundFramebuffer) { - scoped_ptr<BrowserGpuMemoryBufferManager> gpu_memory_buffer_manager; - scoped_ptr<BufferQueue> output_surface; + std::unique_ptr<BrowserGpuMemoryBufferManager> gpu_memory_buffer_manager; + std::unique_ptr<BufferQueue> output_surface; scoped_refptr<cc::TestContextProvider> context_provider = cc::TestContextProvider::Create(cc::TestWebGraphicsContext3D::Create()); context_provider->BindToCurrentThread(); gpu_memory_buffer_manager.reset(new StubBrowserGpuMemoryBufferManager); - scoped_ptr<GLHelper> gl_helper; + std::unique_ptr<GLHelper> gl_helper; gl_helper.reset(new GLHelper(context_provider->ContextGL(), context_provider->ContextSupport()));
diff --git a/content/browser/compositor/gl_helper.cc b/content/browser/compositor/gl_helper.cc index 55493e90..fc17815 100644 --- a/content/browser/compositor/gl_helper.cc +++ b/content/browser/compositor/gl_helper.cc
@@ -95,7 +95,7 @@ private: TextureFrameBufferPair texture_and_framebuffer_; - scoped_ptr<content::GLHelper::ScalerInterface> scaler_; + std::unique_ptr<content::GLHelper::ScalerInterface> scaler_; DISALLOW_COPY_AND_ASSIGN(ScalerHolder); }; @@ -320,8 +320,8 @@ GLHelper::ScalerQuality quality_; ReadbackSwizzle swizzle_; ScalerHolder scaler_; - scoped_ptr<content::GLHelperScaling::ShaderInterface> pass1_shader_; - scoped_ptr<content::GLHelperScaling::ShaderInterface> pass2_shader_; + std::unique_ptr<content::GLHelperScaling::ShaderInterface> pass1_shader_; + std::unique_ptr<content::GLHelperScaling::ShaderInterface> pass2_shader_; TextureFrameBufferPair y_; ScopedTexture uv_; TextureFrameBufferPair u_; @@ -421,7 +421,7 @@ gl_->TexImage2D(GL_TEXTURE_2D, 0, format, dst_size.width(), dst_size.height(), 0, format, type, NULL); } - scoped_ptr<ScalerInterface> scaler( + std::unique_ptr<ScalerInterface> scaler( helper_->CreateScaler(quality, src_size, src_subrect, dst_size, vertically_flip_texture, swizzle)); scaler->Scale(src_texture, dst_texture); @@ -447,7 +447,7 @@ } helper_->InitScalerImpl(); - scoped_ptr<ScalerInterface> grayscale_scaler( + std::unique_ptr<ScalerInterface> grayscale_scaler( helper_->scaler_impl_.get()->CreatePlanarScaler( src_size, gfx::Rect(0, 0, (src_size.width() + 3) & ~3, src_size.height()), @@ -802,7 +802,7 @@ GLint log_length = 0; gl_->GetShaderiv(shader, GL_INFO_LOG_LENGTH, &log_length); if (log_length) { - scoped_ptr<GLchar[]> log(new GLchar[log_length]); + std::unique_ptr<GLchar[]> log(new GLchar[log_length]); GLsizei returned_log_length = 0; gl_->GetShaderInfoLog(shader, log_length, &returned_log_length, log.get());
diff --git a/content/browser/compositor/gl_helper.h b/content/browser/compositor/gl_helper.h index ebfc1a3..582c00b9c1 100644 --- a/content/browser/compositor/gl_helper.h +++ b/content/browser/compositor/gl_helper.h
@@ -5,10 +5,11 @@ #ifndef CONTENT_BROWSER_COMPOSITOR_GL_HELPER_H_ #define CONTENT_BROWSER_COMPOSITOR_GL_HELPER_H_ +#include <memory> + #include "base/atomicops.h" #include "base/callback.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "content/common/content_export.h" #include "gpu/command_buffer/client/gles2_interface.h" #include "gpu/command_buffer/common/mailbox_holder.h" @@ -342,9 +343,9 @@ gpu::gles2::GLES2Interface* gl_; gpu::ContextSupport* context_support_; - scoped_ptr<CopyTextureToImpl> copy_texture_to_impl_; - scoped_ptr<GLHelperScaling> scaler_impl_; - scoped_ptr<GLHelperReadbackSupport> readback_support_; + std::unique_ptr<CopyTextureToImpl> copy_texture_to_impl_; + std::unique_ptr<GLHelperScaling> scaler_impl_; + std::unique_ptr<GLHelperReadbackSupport> readback_support_; DISALLOW_COPY_AND_ASSIGN(GLHelper); };
diff --git a/content/browser/compositor/gl_helper_benchmark.cc b/content/browser/compositor/gl_helper_benchmark.cc index 845d82a4..c20ecd0 100644 --- a/content/browser/compositor/gl_helper_benchmark.cc +++ b/content/browser/compositor/gl_helper_benchmark.cc
@@ -110,10 +110,10 @@ base::CloseFile(f); } - scoped_ptr<gpu::GLInProcessContext> context_; + std::unique_ptr<gpu::GLInProcessContext> context_; gpu::gles2::GLES2Interface* gl_; - scoped_ptr<content::GLHelper> helper_; - scoped_ptr<content::GLHelperScaling> helper_scaling_; + std::unique_ptr<content::GLHelper> helper_; + std::unique_ptr<content::GLHelperScaling> helper_scaling_; std::deque<GLHelperScaling::ScaleOp> x_ops_, y_ops_; }; @@ -151,7 +151,7 @@ input.getPixels()); gfx::Rect src_subrect(0, 0, src_size.width(), src_size.height()); - scoped_ptr<content::GLHelper::ScalerInterface> scaler( + std::unique_ptr<content::GLHelper::ScalerInterface> scaler( helper_->CreateScaler(kQualities[q], src_size, src_subrect, dst_size, false, false)); // Scale once beforehand before we start measuring.
diff --git a/content/browser/compositor/gl_helper_scaling.cc b/content/browser/compositor/gl_helper_scaling.cc index 0c7d977..3fe19339 100644 --- a/content/browser/compositor/gl_helper_scaling.cc +++ b/content/browser/compositor/gl_helper_scaling.cc
@@ -169,7 +169,7 @@ ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder( gl_, dst_framebuffer_); DCHECK_GT(dest_textures.size(), 0U); - scoped_ptr<GLenum[]> buffers(new GLenum[dest_textures.size()]); + std::unique_ptr<GLenum[]> buffers(new GLenum[dest_textures.size()]); for (size_t t = 0; t < dest_textures.size(); t++) { ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, dest_textures[t]); gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + t, @@ -232,7 +232,7 @@ GLuint intermediate_texture_; scoped_refptr<ShaderProgram> shader_program_; ScopedFramebuffer dst_framebuffer_; - scoped_ptr<ScalerImpl> subscaler_; + std::unique_ptr<ScalerImpl> subscaler_; }; GLHelperScaling::ScalerStage::ScalerStage(ShaderType shader_,
diff --git a/content/browser/compositor/gl_helper_unittest.cc b/content/browser/compositor/gl_helper_unittest.cc index 697c68b..05f3f6f6 100644 --- a/content/browser/compositor/gl_helper_unittest.cc +++ b/content/browser/compositor/gl_helper_unittest.cc
@@ -124,7 +124,7 @@ json_data.append("]"); std::string error_msg; - scoped_ptr<base::Value> trace_data = + std::unique_ptr<base::Value> trace_data = base::JSONReader::ReadAndReturnError(json_data, 0, NULL, &error_msg); CHECK(trace_data) << "JSON parsing failed (" << error_msg << ") JSON data:" << std::endl @@ -674,10 +674,10 @@ } // Creates an RGBA SkBitmap - scoped_ptr<SkBitmap> CreateTestBitmap(int width, - int height, - int test_pattern) { - scoped_ptr<SkBitmap> bitmap(new SkBitmap); + std::unique_ptr<SkBitmap> CreateTestBitmap(int width, + int height, + int test_pattern) { + std::unique_ptr<SkBitmap> bitmap(new SkBitmap); bitmap->allocPixels(SkImageInfo::Make(width, height, kRGBA_8888_SkColorType, kPremul_SkAlphaType)); @@ -739,7 +739,7 @@ gl_->GenTextures(1, &src_texture); GLuint framebuffer; gl_->GenFramebuffers(1, &framebuffer); - scoped_ptr<SkBitmap> input_pixels = + std::unique_ptr<SkBitmap> input_pixels = CreateTestBitmap(xsize, ysize, test_pattern); BindTextureAndFrameBuffer(src_texture, framebuffer, input_pixels.get(), xsize, ysize); @@ -818,7 +818,7 @@ gl_->GenTextures(1, &src_texture); GLuint framebuffer; gl_->GenFramebuffers(1, &framebuffer); - scoped_ptr<SkBitmap> input_pixels = + std::unique_ptr<SkBitmap> input_pixels = CreateTestBitmap(xsize, ysize, test_pattern); BindTextureAndFrameBuffer(src_texture, framebuffer, input_pixels.get(), xsize, ysize); @@ -1306,7 +1306,7 @@ "pattern: %d %s %s", xsize, ysize, output_xsize, output_ysize, xmargin, ymargin, test_pattern, flip ? "flip" : "noflip", flip ? "mrt" : "nomrt"); - scoped_ptr<ReadbackYUVInterface> yuv_reader( + std::unique_ptr<ReadbackYUVInterface> yuv_reader( helper_->CreateReadbackPipelineYUV( quality, gfx::Size(xsize, ysize), gfx::Rect(0, 0, xsize, ysize), gfx::Size(xsize, ysize), flip, use_mrt)); @@ -1573,10 +1573,10 @@ "8x1 -> 1x1 bilinear4 X\n"); } - scoped_ptr<gpu::GLInProcessContext> context_; + std::unique_ptr<gpu::GLInProcessContext> context_; gpu::gles2::GLES2Interface* gl_; - scoped_ptr<content::GLHelper> helper_; - scoped_ptr<content::GLHelperScaling> helper_scaling_; + std::unique_ptr<content::GLHelper> helper_; + std::unique_ptr<content::GLHelperScaling> helper_scaling_; std::deque<GLHelperScaling::ScaleOp> x_ops_, y_ops_; };
diff --git a/content/browser/compositor/gpu_browser_compositor_output_surface.cc b/content/browser/compositor/gpu_browser_compositor_output_surface.cc index f3eb5f5..e6a7aa1 100644 --- a/content/browser/compositor/gpu_browser_compositor_output_surface.cc +++ b/content/browser/compositor/gpu_browser_compositor_output_surface.cc
@@ -22,7 +22,7 @@ const scoped_refptr<ContextProviderCommandBuffer>& context, const scoped_refptr<ContextProviderCommandBuffer>& worker_context, const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, - scoped_ptr<BrowserCompositorOverlayCandidateValidator> + std::unique_ptr<BrowserCompositorOverlayCandidateValidator> overlay_candidate_validator) : BrowserCompositorOutputSurface(context, worker_context,
diff --git a/content/browser/compositor/gpu_browser_compositor_output_surface.h b/content/browser/compositor/gpu_browser_compositor_output_surface.h index 4133bc3..950a23a 100644 --- a/content/browser/compositor/gpu_browser_compositor_output_surface.h +++ b/content/browser/compositor/gpu_browser_compositor_output_surface.h
@@ -33,7 +33,7 @@ const scoped_refptr<ContextProviderCommandBuffer>& context, const scoped_refptr<ContextProviderCommandBuffer>& worker_context, const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, - scoped_ptr<BrowserCompositorOverlayCandidateValidator> + std::unique_ptr<BrowserCompositorOverlayCandidateValidator> overlay_candidate_validator); ~GpuBrowserCompositorOutputSurface() override; @@ -76,7 +76,7 @@ base::TimeDelta interval)> update_vsync_parameters_callback_; - scoped_ptr<ReflectorTexture> reflector_texture_; + std::unique_ptr<ReflectorTexture> reflector_texture_; DISALLOW_COPY_AND_ASSIGN(GpuBrowserCompositorOutputSurface); };
diff --git a/content/browser/compositor/gpu_process_transport_factory.cc b/content/browser/compositor/gpu_process_transport_factory.cc index 9a4ad65..14718e5b 100644 --- a/content/browser/compositor/gpu_process_transport_factory.cc +++ b/content/browser/compositor/gpu_process_transport_factory.cc
@@ -10,6 +10,7 @@ #include "base/bind.h" #include "base/command_line.h" #include "base/location.h" +#include "base/memory/ptr_util.h" #include "base/metrics/histogram.h" #include "base/single_thread_task_runner.h" #include "base/thread_task_runner_handle.h" @@ -89,7 +90,7 @@ int surface_id; BrowserCompositorOutputSurface* surface; ReflectorImpl* reflector; - scoped_ptr<cc::OnscreenDisplayClient> display_client; + std::unique_ptr<cc::OnscreenDisplayClient> display_client; PerCompositorData() : surface_id(0), surface(nullptr), reflector(nullptr) {} }; @@ -100,7 +101,7 @@ callback_factory_(this) { cc::SetClientNameForMetrics("Browser"); - surface_manager_ = make_scoped_ptr(new cc::SurfaceManager); + surface_manager_ = base::WrapUnique(new cc::SurfaceManager); task_graph_runner_->Start("CompositorTileWorker1", base::SimpleThread::Options()); @@ -118,7 +119,7 @@ task_graph_runner_->Shutdown(); } -scoped_ptr<WebGraphicsContext3DCommandBufferImpl> +std::unique_ptr<WebGraphicsContext3DCommandBufferImpl> GpuProcessTransportFactory::CreateOffscreenCommandBufferContext() { CauseForGpuLaunch cause = CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; @@ -127,38 +128,38 @@ return CreateContextCommon(gpu_channel_host, gpu::kNullSurfaceHandle); } -scoped_ptr<cc::SoftwareOutputDevice> +std::unique_ptr<cc::SoftwareOutputDevice> GpuProcessTransportFactory::CreateSoftwareOutputDevice( ui::Compositor* compositor) { #if defined(MOJO_RUNNER_CLIENT) if (IsRunningInMojoShell()) { - return scoped_ptr<cc::SoftwareOutputDevice>( + return std::unique_ptr<cc::SoftwareOutputDevice>( new SoftwareOutputDeviceMus(compositor)); } #endif #if defined(OS_WIN) - return scoped_ptr<cc::SoftwareOutputDevice>( + return std::unique_ptr<cc::SoftwareOutputDevice>( new SoftwareOutputDeviceWin(software_backing_.get(), compositor)); #elif defined(USE_OZONE) return SoftwareOutputDeviceOzone::Create(compositor); #elif defined(USE_X11) - return scoped_ptr<cc::SoftwareOutputDevice>(new SoftwareOutputDeviceX11( - compositor)); + return std::unique_ptr<cc::SoftwareOutputDevice>( + new SoftwareOutputDeviceX11(compositor)); #elif defined(OS_MACOSX) - return scoped_ptr<cc::SoftwareOutputDevice>( + return std::unique_ptr<cc::SoftwareOutputDevice>( new SoftwareOutputDeviceMac(compositor)); #else NOTREACHED(); - return scoped_ptr<cc::SoftwareOutputDevice>(); + return std::unique_ptr<cc::SoftwareOutputDevice>(); #endif } -scoped_ptr<BrowserCompositorOverlayCandidateValidator> +std::unique_ptr<BrowserCompositorOverlayCandidateValidator> CreateOverlayCandidateValidator(gfx::AcceleratedWidget widget) { - scoped_ptr<BrowserCompositorOverlayCandidateValidator> validator; + std::unique_ptr<BrowserCompositorOverlayCandidateValidator> validator; #if defined(USE_OZONE) - scoped_ptr<ui::OverlayCandidatesOzone> overlay_candidates = + std::unique_ptr<ui::OverlayCandidatesOzone> overlay_candidates = ui::OzonePlatform::GetInstance() ->GetOverlayManager() ->CreateOverlayCandidates(widget); @@ -324,9 +325,9 @@ } } - scoped_ptr<BrowserCompositorOutputSurface> surface; + std::unique_ptr<BrowserCompositorOutputSurface> surface; if (!create_gpu_output_surface) { - surface = make_scoped_ptr(new SoftwareBrowserCompositorOutputSurface( + surface = base::WrapUnique(new SoftwareBrowserCompositorOutputSurface( CreateSoftwareOutputDevice(compositor.get()), compositor->vsync_manager())); } else { @@ -334,10 +335,10 @@ ContextProvider::Capabilities capabilities = context_provider->ContextCapabilities(); if (!data->surface_id) { - surface = make_scoped_ptr(new OffscreenBrowserCompositorOutputSurface( + surface = base::WrapUnique(new OffscreenBrowserCompositorOutputSurface( context_provider, shared_worker_context_provider_, compositor->vsync_manager(), - scoped_ptr<BrowserCompositorOverlayCandidateValidator>())); + std::unique_ptr<BrowserCompositorOverlayCandidateValidator>())); } else if (capabilities.gpu.surfaceless) { GLenum target = GL_TEXTURE_2D; GLenum format = GL_RGB; @@ -346,18 +347,18 @@ format = GL_RGBA; #endif surface = - make_scoped_ptr(new GpuSurfacelessBrowserCompositorOutputSurface( + base::WrapUnique(new GpuSurfacelessBrowserCompositorOutputSurface( context_provider, shared_worker_context_provider_, data->surface_id, compositor->vsync_manager(), CreateOverlayCandidateValidator(compositor->widget()), target, format, BrowserGpuMemoryBufferManager::current())); } else { - scoped_ptr<BrowserCompositorOverlayCandidateValidator> validator; + std::unique_ptr<BrowserCompositorOverlayCandidateValidator> validator; #if !defined(OS_MACOSX) // Overlays are only supported on surfaceless output surfaces on Mac. validator = CreateOverlayCandidateValidator(compositor->widget()); #endif - surface = make_scoped_ptr(new GpuBrowserCompositorOutputSurface( + surface = base::WrapUnique(new GpuBrowserCompositorOutputSurface( context_provider, shared_worker_context_provider_, compositor->vsync_manager(), std::move(validator))); } @@ -380,13 +381,13 @@ // OnscreenDisplayClient associated with that context, then return a // SurfaceDisplayOutputSurface set up to draw to the display's surface. cc::SurfaceManager* manager = surface_manager_.get(); - scoped_ptr<cc::OnscreenDisplayClient> display_client( + std::unique_ptr<cc::OnscreenDisplayClient> display_client( new cc::OnscreenDisplayClient( std::move(surface), manager, HostSharedBitmapManager::current(), BrowserGpuMemoryBufferManager::current(), compositor->GetRendererSettings(), compositor->task_runner())); - scoped_ptr<cc::SurfaceDisplayOutputSurface> output_surface( + std::unique_ptr<cc::SurfaceDisplayOutputSurface> output_surface( new cc::SurfaceDisplayOutputSurface( manager, compositor->surface_id_allocator(), context_provider, shared_worker_context_provider_)); @@ -397,13 +398,13 @@ compositor->SetOutputSurface(std::move(output_surface)); } -scoped_ptr<ui::Reflector> GpuProcessTransportFactory::CreateReflector( +std::unique_ptr<ui::Reflector> GpuProcessTransportFactory::CreateReflector( ui::Compositor* source_compositor, ui::Layer* target_layer) { PerCompositorData* source_data = per_compositor_data_[source_compositor]; DCHECK(source_data); - scoped_ptr<ReflectorImpl> reflector( + std::unique_ptr<ReflectorImpl> reflector( new ReflectorImpl(source_compositor, target_layer)); source_data->reflector = reflector.get(); if (BrowserCompositorOutputSurface* source_surface = source_data->surface) @@ -440,7 +441,7 @@ // GLHelper created in this case would be lost/leaked if we just reset() // on the |gl_helper_| variable directly. So instead we call reset() on a // local scoped_ptr. - scoped_ptr<GLHelper> helper = std::move(gl_helper_); + std::unique_ptr<GLHelper> helper = std::move(gl_helper_); // If there are any observer left at this point, make sure they clean up // before we destroy the GLHelper. @@ -482,10 +483,10 @@ return this; } -scoped_ptr<cc::SurfaceIdAllocator> +std::unique_ptr<cc::SurfaceIdAllocator> GpuProcessTransportFactory::CreateSurfaceIdAllocator() { - scoped_ptr<cc::SurfaceIdAllocator> allocator = - make_scoped_ptr(new cc::SurfaceIdAllocator(next_surface_id_namespace_++)); + std::unique_ptr<cc::SurfaceIdAllocator> allocator = base::WrapUnique( + new cc::SurfaceIdAllocator(next_surface_id_namespace_++)); if (GetSurfaceManager()) allocator->RegisterSurfaceIdNamespace(GetSurfaceManager()); return allocator; @@ -606,7 +607,7 @@ return data; } -scoped_ptr<WebGraphicsContext3DCommandBufferImpl> +std::unique_ptr<WebGraphicsContext3DCommandBufferImpl> GpuProcessTransportFactory::CreateContextCommon( scoped_refptr<gpu::GpuChannelHost> gpu_channel_host, gpu::SurfaceHandle surface_handle) { @@ -642,7 +643,7 @@ bool automatic_flushes = false; GURL url("chrome://gpu/GpuProcessTransportFactory::CreateContextCommon"); - scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( + std::unique_ptr<WebGraphicsContext3DCommandBufferImpl> context( new WebGraphicsContext3DCommandBufferImpl( surface_handle, url, gpu_channel_host.get(), attributes, gfx::PreferIntegratedGpu, share_resources, automatic_flushes, @@ -669,7 +670,7 @@ shared_main_thread_contexts_; shared_main_thread_contexts_ = NULL; - scoped_ptr<GLHelper> lost_gl_helper = std::move(gl_helper_); + std::unique_ptr<GLHelper> lost_gl_helper = std::move(gl_helper_); FOR_EACH_OBSERVER(ImageTransportFactoryObserver, observer_list_,
diff --git a/content/browser/compositor/gpu_process_transport_factory.h b/content/browser/compositor/gpu_process_transport_factory.h index f4e007a..1996a84 100644 --- a/content/browser/compositor/gpu_process_transport_factory.h +++ b/content/browser/compositor/gpu_process_transport_factory.h
@@ -8,11 +8,11 @@ #include <stdint.h> #include <map> +#include <memory> #include "base/id_map.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/observer_list.h" #include "build/build_config.h" @@ -48,13 +48,13 @@ ~GpuProcessTransportFactory() override; - scoped_ptr<WebGraphicsContext3DCommandBufferImpl> + std::unique_ptr<WebGraphicsContext3DCommandBufferImpl> CreateOffscreenCommandBufferContext(); // ui::ContextFactory implementation. void CreateOutputSurface(base::WeakPtr<ui::Compositor> compositor) override; - scoped_ptr<ui::Reflector> CreateReflector(ui::Compositor* source, - ui::Layer* target) override; + std::unique_ptr<ui::Reflector> CreateReflector(ui::Compositor* source, + ui::Layer* target) override; void RemoveReflector(ui::Reflector* reflector) override; void RemoveCompositor(ui::Compositor* compositor) override; scoped_refptr<cc::ContextProvider> SharedMainThreadContextProvider() override; @@ -64,7 +64,7 @@ cc::SharedBitmapManager* GetSharedBitmapManager() override; gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() override; cc::TaskGraphRunner* GetTaskGraphRunner() override; - scoped_ptr<cc::SurfaceIdAllocator> CreateSurfaceIdAllocator() override; + std::unique_ptr<cc::SurfaceIdAllocator> CreateSurfaceIdAllocator() override; void ResizeDisplay(ui::Compositor* compositor, const gfx::Size& size) override; @@ -89,12 +89,12 @@ struct PerCompositorData; PerCompositorData* CreatePerCompositorData(ui::Compositor* compositor); - scoped_ptr<cc::SoftwareOutputDevice> CreateSoftwareOutputDevice( + std::unique_ptr<cc::SoftwareOutputDevice> CreateSoftwareOutputDevice( ui::Compositor* compositor); void EstablishedGpuChannel(base::WeakPtr<ui::Compositor> compositor, bool create_gpu_output_surface, int num_attempts); - scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateContextCommon( + std::unique_ptr<WebGraphicsContext3DCommandBufferImpl> CreateContextCommon( scoped_refptr<gpu::GpuChannelHost> gpu_channel_host, gpu::SurfaceHandle surface_handle); @@ -104,15 +104,15 @@ typedef std::map<ui::Compositor*, PerCompositorData*> PerCompositorDataMap; PerCompositorDataMap per_compositor_data_; scoped_refptr<ContextProviderCommandBuffer> shared_main_thread_contexts_; - scoped_ptr<GLHelper> gl_helper_; + std::unique_ptr<GLHelper> gl_helper_; base::ObserverList<ImageTransportFactoryObserver> observer_list_; - scoped_ptr<cc::SurfaceManager> surface_manager_; + std::unique_ptr<cc::SurfaceManager> surface_manager_; uint32_t next_surface_id_namespace_; - scoped_ptr<cc::SingleThreadTaskGraphRunner> task_graph_runner_; + std::unique_ptr<cc::SingleThreadTaskGraphRunner> task_graph_runner_; scoped_refptr<ContextProviderCommandBuffer> shared_worker_context_provider_; #if defined(OS_WIN) - scoped_ptr<OutputDeviceBacking> software_backing_; + std::unique_ptr<OutputDeviceBacking> software_backing_; #endif // The contents of this map and its methods may only be used on the compositor
diff --git a/content/browser/compositor/gpu_surfaceless_browser_compositor_output_surface.cc b/content/browser/compositor/gpu_surfaceless_browser_compositor_output_surface.cc index 5e85a4e3..ecd3a0cb 100644 --- a/content/browser/compositor/gpu_surfaceless_browser_compositor_output_surface.cc +++ b/content/browser/compositor/gpu_surfaceless_browser_compositor_output_surface.cc
@@ -25,7 +25,7 @@ const scoped_refptr<ContextProviderCommandBuffer>& worker_context, int surface_id, const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, - scoped_ptr<BrowserCompositorOverlayCandidateValidator> + std::unique_ptr<BrowserCompositorOverlayCandidateValidator> overlay_candidate_validator, unsigned int target, unsigned int internalformat,
diff --git a/content/browser/compositor/gpu_surfaceless_browser_compositor_output_surface.h b/content/browser/compositor/gpu_surfaceless_browser_compositor_output_surface.h index 2341219..4bc208a 100644 --- a/content/browser/compositor/gpu_surfaceless_browser_compositor_output_surface.h +++ b/content/browser/compositor/gpu_surfaceless_browser_compositor_output_surface.h
@@ -24,7 +24,7 @@ const scoped_refptr<ContextProviderCommandBuffer>& worker_context, int surface_id, const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, - scoped_ptr<BrowserCompositorOverlayCandidateValidator> + std::unique_ptr<BrowserCompositorOverlayCandidateValidator> overlay_candidate_validator, unsigned int target, unsigned int internalformat, @@ -46,8 +46,8 @@ gfx::SwapResult result) override; unsigned int internalformat_; - scoped_ptr<GLHelper> gl_helper_; - scoped_ptr<BufferQueue> output_surface_; + std::unique_ptr<GLHelper> gl_helper_; + std::unique_ptr<BufferQueue> output_surface_; gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; };
diff --git a/content/browser/compositor/image_transport_factory.cc b/content/browser/compositor/image_transport_factory.cc index 6f06a97..de8f075 100644 --- a/content/browser/compositor/image_transport_factory.cc +++ b/content/browser/compositor/image_transport_factory.cc
@@ -32,7 +32,7 @@ } void ImageTransportFactory::InitializeForUnitTests( - scoped_ptr<ImageTransportFactory> factory) { + std::unique_ptr<ImageTransportFactory> factory) { DCHECK(!g_factory); DCHECK(!g_initialized_for_unit_tests); g_initialized_for_unit_tests = true;
diff --git a/content/browser/compositor/image_transport_factory.h b/content/browser/compositor/image_transport_factory.h index 744d2c05..8a398bd 100644 --- a/content/browser/compositor/image_transport_factory.h +++ b/content/browser/compositor/image_transport_factory.h
@@ -5,10 +5,10 @@ #ifndef CONTENT_BROWSER_COMPOSITOR_IMAGE_TRANSPORT_FACTORY_H_ #define CONTENT_BROWSER_COMPOSITOR_IMAGE_TRANSPORT_FACTORY_H_ +#include <memory> #include <string> #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "build/build_config.h" #include "cc/surfaces/surface_id_allocator.h" #include "content/common/content_export.h" @@ -64,7 +64,8 @@ // Initializes the global transport factory for unit tests using the provided // context factory. - static void InitializeForUnitTests(scoped_ptr<ImageTransportFactory> factory); + static void InitializeForUnitTests( + std::unique_ptr<ImageTransportFactory> factory); // Terminates the global transport factory. static void Terminate();
diff --git a/content/browser/compositor/offscreen_browser_compositor_output_surface.cc b/content/browser/compositor/offscreen_browser_compositor_output_surface.cc index eaadce55..35a3a6ce 100644 --- a/content/browser/compositor/offscreen_browser_compositor_output_surface.cc +++ b/content/browser/compositor/offscreen_browser_compositor_output_surface.cc
@@ -35,7 +35,7 @@ const scoped_refptr<ContextProviderCommandBuffer>& context, const scoped_refptr<ContextProviderCommandBuffer>& worker_context, const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, - scoped_ptr<BrowserCompositorOverlayCandidateValidator> + std::unique_ptr<BrowserCompositorOverlayCandidateValidator> overlay_candidate_validator) : BrowserCompositorOutputSurface(context, worker_context,
diff --git a/content/browser/compositor/offscreen_browser_compositor_output_surface.h b/content/browser/compositor/offscreen_browser_compositor_output_surface.h index abbb20c0..3af0c85 100644 --- a/content/browser/compositor/offscreen_browser_compositor_output_surface.h +++ b/content/browser/compositor/offscreen_browser_compositor_output_surface.h
@@ -7,9 +7,10 @@ #include <stdint.h> +#include <memory> + #include "base/cancelable_callback.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "build/build_config.h" #include "content/browser/compositor/browser_compositor_output_surface.h" @@ -29,7 +30,7 @@ const scoped_refptr<ContextProviderCommandBuffer>& context, const scoped_refptr<ContextProviderCommandBuffer>& worker_context, const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, - scoped_ptr<BrowserCompositorOverlayCandidateValidator> + std::unique_ptr<BrowserCompositorOverlayCandidateValidator> overlay_candidate_validator); ~OffscreenBrowserCompositorOutputSurface() override; @@ -55,7 +56,7 @@ uint32_t fbo_; bool is_backbuffer_discarded_; - scoped_ptr<ReflectorTexture> reflector_texture_; + std::unique_ptr<ReflectorTexture> reflector_texture_; base::WeakPtrFactory<OffscreenBrowserCompositorOutputSurface> weak_ptr_factory_;
diff --git a/content/browser/compositor/reflector_impl.h b/content/browser/compositor/reflector_impl.h index ca1a89f..b1eb6cf4 100644 --- a/content/browser/compositor/reflector_impl.h +++ b/content/browser/compositor/reflector_impl.h
@@ -5,9 +5,10 @@ #ifndef CONTENT_BROWSER_COMPOSITOR_REFLECTOR_IMPL_H_ #define CONTENT_BROWSER_COMPOSITOR_REFLECTOR_IMPL_H_ +#include <memory> + #include "base/callback.h" #include "base/id_map.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_vector.h" #include "base/memory/weak_ptr.h" #include "base/synchronization/lock.h"
diff --git a/content/browser/compositor/reflector_impl_unittest.cc b/content/browser/compositor/reflector_impl_unittest.cc index cebaf51..e05af8b 100644 --- a/content/browser/compositor/reflector_impl_unittest.cc +++ b/content/browser/compositor/reflector_impl_unittest.cc
@@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/browser/compositor/reflector_impl.h" + +#include "base/memory/ptr_util.h" #include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "build/build_config.h" @@ -10,7 +13,6 @@ #include "cc/test/test_web_graphics_context_3d.h" #include "content/browser/compositor/browser_compositor_output_surface.h" #include "content/browser/compositor/browser_compositor_overlay_candidate_validator.h" -#include "content/browser/compositor/reflector_impl.h" #include "content/browser/compositor/reflector_texture.h" #include "content/browser/compositor/test/no_transport_image_transport_factory.h" #include "testing/gtest/include/gtest/gtest.h" @@ -57,12 +59,12 @@ }; #endif // defined(USE_OZONE) -scoped_ptr<BrowserCompositorOverlayCandidateValidator> +std::unique_ptr<BrowserCompositorOverlayCandidateValidator> CreateTestValidatorOzone() { #if defined(USE_OZONE) - return scoped_ptr<BrowserCompositorOverlayCandidateValidator>( + return std::unique_ptr<BrowserCompositorOverlayCandidateValidator>( new BrowserCompositorOverlayCandidateValidatorOzone( - 0, scoped_ptr<ui::OverlayCandidatesOzone>( + 0, std::unique_ptr<ui::OverlayCandidatesOzone>( new TestOverlayCandidatesOzone()))); #else return nullptr; @@ -109,7 +111,7 @@ #endif private: - scoped_ptr<ReflectorTexture> reflector_texture_; + std::unique_ptr<ReflectorTexture> reflector_texture_; }; const gfx::Rect kSubRect(0, 0, 64, 64); @@ -123,7 +125,7 @@ ui::ContextFactory* context_factory = ui::InitializeContextFactoryForTests(enable_pixel_output); ImageTransportFactory::InitializeForUnitTests( - scoped_ptr<ImageTransportFactory>( + std::unique_ptr<ImageTransportFactory>( new NoTransportImageTransportFactory)); message_loop_.reset(new base::MessageLoop()); task_runner_ = message_loop_->task_runner(); @@ -133,7 +135,7 @@ compositor_->SetAcceleratedWidget(gfx::kNullAcceleratedWidget); context_provider_ = cc::TestContextProvider::Create(cc::TestWebGraphicsContext3D::Create()); - output_surface_ = scoped_ptr<TestOutputSurface>( + output_surface_ = std::unique_ptr<TestOutputSurface>( new TestOutputSurface(context_provider_, compositor_->vsync_manager())); CHECK(output_surface_->BindToClient(&output_surface_client_)); @@ -146,7 +148,7 @@ } void SetUpReflector() { - reflector_ = make_scoped_ptr( + reflector_ = base::WrapUnique( new ReflectorImpl(compositor_.get(), mirroring_layer_.get())); reflector_->OnSourceSurfaceReady(output_surface_.get()); } @@ -155,7 +157,7 @@ if (reflector_) reflector_->RemoveMirroringLayer(mirroring_layer_.get()); cc::TextureMailbox mailbox; - scoped_ptr<cc::SingleReleaseCallback> release; + std::unique_ptr<cc::SingleReleaseCallback> release; if (mirroring_layer_->PrepareTextureMailbox(&mailbox, &release, false)) { release->Run(gpu::SyncToken(), false); } @@ -170,13 +172,13 @@ scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; scoped_refptr<cc::ContextProvider> context_provider_; cc::FakeOutputSurfaceClient output_surface_client_; - scoped_ptr<base::MessageLoop> message_loop_; + std::unique_ptr<base::MessageLoop> message_loop_; scoped_refptr<base::SingleThreadTaskRunner> task_runner_; - scoped_ptr<ui::Compositor> compositor_; - scoped_ptr<ui::Layer> root_layer_; - scoped_ptr<ui::Layer> mirroring_layer_; - scoped_ptr<ReflectorImpl> reflector_; - scoped_ptr<TestOutputSurface> output_surface_; + std::unique_ptr<ui::Compositor> compositor_; + std::unique_ptr<ui::Layer> root_layer_; + std::unique_ptr<ui::Layer> mirroring_layer_; + std::unique_ptr<ReflectorImpl> reflector_; + std::unique_ptr<TestOutputSurface> output_surface_; }; namespace {
diff --git a/content/browser/compositor/reflector_texture.h b/content/browser/compositor/reflector_texture.h index cc8f98c..09e1508 100644 --- a/content/browser/compositor/reflector_texture.h +++ b/content/browser/compositor/reflector_texture.h
@@ -7,9 +7,10 @@ #include <stdint.h> +#include <memory> + #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/compositor/owned_mailbox.h" #include "content/common/content_export.h" @@ -39,7 +40,7 @@ private: scoped_refptr<OwnedMailbox> mailbox_; - scoped_ptr<GLHelper> gl_helper_; + std::unique_ptr<GLHelper> gl_helper_; uint32_t texture_id_; DISALLOW_COPY_AND_ASSIGN(ReflectorTexture);
diff --git a/content/browser/compositor/software_browser_compositor_output_surface.cc b/content/browser/compositor/software_browser_compositor_output_surface.cc index 151ed5fc..4413c4c3 100644 --- a/content/browser/compositor/software_browser_compositor_output_surface.cc +++ b/content/browser/compositor/software_browser_compositor_output_surface.cc
@@ -22,7 +22,7 @@ namespace content { SoftwareBrowserCompositorOutputSurface::SoftwareBrowserCompositorOutputSurface( - scoped_ptr<cc::SoftwareOutputDevice> software_device, + std::unique_ptr<cc::SoftwareOutputDevice> software_device, const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager) : BrowserCompositorOutputSurface(std::move(software_device), vsync_manager), weak_factory_(this) {}
diff --git a/content/browser/compositor/software_browser_compositor_output_surface.h b/content/browser/compositor/software_browser_compositor_output_surface.h index 9e8bbcf..90a5fc9 100644 --- a/content/browser/compositor/software_browser_compositor_output_surface.h +++ b/content/browser/compositor/software_browser_compositor_output_surface.h
@@ -25,7 +25,7 @@ : public BrowserCompositorOutputSurface { public: SoftwareBrowserCompositorOutputSurface( - scoped_ptr<cc::SoftwareOutputDevice> software_device, + std::unique_ptr<cc::SoftwareOutputDevice> software_device, const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager); ~SoftwareBrowserCompositorOutputSurface() override;
diff --git a/content/browser/compositor/software_browser_compositor_output_surface_unittest.cc b/content/browser/compositor/software_browser_compositor_output_surface_unittest.cc index 51a2c77..7dd7707 100644 --- a/content/browser/compositor/software_browser_compositor_output_surface_unittest.cc +++ b/content/browser/compositor/software_browser_compositor_output_surface_unittest.cc
@@ -51,7 +51,7 @@ } private: - scoped_ptr<gfx::VSyncProvider> vsync_provider_; + std::unique_ptr<gfx::VSyncProvider> vsync_provider_; DISALLOW_COPY_AND_ASSIGN(FakeSoftwareOutputDevice); }; @@ -66,14 +66,14 @@ void SetUp() override; void TearDown() override; - scoped_ptr<content::BrowserCompositorOutputSurface> CreateSurface( - scoped_ptr<cc::SoftwareOutputDevice> device); + std::unique_ptr<content::BrowserCompositorOutputSurface> CreateSurface( + std::unique_ptr<cc::SoftwareOutputDevice> device); protected: - scoped_ptr<content::BrowserCompositorOutputSurface> output_surface_; + std::unique_ptr<content::BrowserCompositorOutputSurface> output_surface_; - scoped_ptr<base::MessageLoop> message_loop_; - scoped_ptr<ui::Compositor> compositor_; + std::unique_ptr<base::MessageLoop> message_loop_; + std::unique_ptr<ui::Compositor> compositor_; DISALLOW_COPY_AND_ASSIGN(SoftwareBrowserCompositorOutputSurfaceTest); }; @@ -104,17 +104,17 @@ ui::TerminateContextFactoryForTests(); } -scoped_ptr<content::BrowserCompositorOutputSurface> +std::unique_ptr<content::BrowserCompositorOutputSurface> SoftwareBrowserCompositorOutputSurfaceTest::CreateSurface( - scoped_ptr<cc::SoftwareOutputDevice> device) { - return scoped_ptr<content::BrowserCompositorOutputSurface>( + std::unique_ptr<cc::SoftwareOutputDevice> device) { + return std::unique_ptr<content::BrowserCompositorOutputSurface>( new content::SoftwareBrowserCompositorOutputSurface( std::move(device), compositor_->vsync_manager())); } TEST_F(SoftwareBrowserCompositorOutputSurfaceTest, NoVSyncProvider) { cc::FakeOutputSurfaceClient output_surface_client; - scoped_ptr<cc::SoftwareOutputDevice> software_device( + std::unique_ptr<cc::SoftwareOutputDevice> software_device( new cc::SoftwareOutputDevice()); output_surface_ = CreateSurface(std::move(software_device)); CHECK(output_surface_->BindToClient(&output_surface_client)); @@ -128,7 +128,7 @@ TEST_F(SoftwareBrowserCompositorOutputSurfaceTest, VSyncProviderUpdates) { cc::FakeOutputSurfaceClient output_surface_client; - scoped_ptr<cc::SoftwareOutputDevice> software_device( + std::unique_ptr<cc::SoftwareOutputDevice> software_device( new FakeSoftwareOutputDevice()); output_surface_ = CreateSurface(std::move(software_device)); CHECK(output_surface_->BindToClient(&output_surface_client));
diff --git a/content/browser/compositor/software_output_device_mus.cc b/content/browser/compositor/software_output_device_mus.cc index ca5fb95df..a577a2fc5 100644 --- a/content/browser/compositor/software_output_device_mus.cc +++ b/content/browser/compositor/software_output_device_mus.cc
@@ -56,8 +56,9 @@ // TODO(rjkroege): This makes an additional copy. Improve the // bitmap_uploader API to remove. - scoped_ptr<std::vector<unsigned char>> data(new std::vector<unsigned char>( - pixels, pixels + rowBytes * viewport_pixel_size_.height())); + std::unique_ptr<std::vector<unsigned char>> data( + new std::vector<unsigned char>( + pixels, pixels + rowBytes * viewport_pixel_size_.height())); uploader->SetBitmap(viewport_pixel_size_.width(), viewport_pixel_size_.height(), std::move(data), bitmap_uploader::BitmapUploader::BGRA);
diff --git a/content/browser/compositor/software_output_device_ozone.cc b/content/browser/compositor/software_output_device_ozone.cc index 7de2de2..c65cda5 100644 --- a/content/browser/compositor/software_output_device_ozone.cc +++ b/content/browser/compositor/software_output_device_ozone.cc
@@ -2,8 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/memory/scoped_ptr.h" #include "content/browser/compositor/software_output_device_ozone.h" + +#include <memory> + #include "ui/compositor/compositor.h" #include "ui/gfx/skia_util.h" #include "ui/gfx/vsync_provider.h" @@ -14,9 +16,9 @@ namespace content { // static -scoped_ptr<SoftwareOutputDeviceOzone> SoftwareOutputDeviceOzone::Create( +std::unique_ptr<SoftwareOutputDeviceOzone> SoftwareOutputDeviceOzone::Create( ui::Compositor* compositor) { - scoped_ptr<SoftwareOutputDeviceOzone> result( + std::unique_ptr<SoftwareOutputDeviceOzone> result( new SoftwareOutputDeviceOzone(compositor)); if (!result->surface_ozone_) return nullptr;
diff --git a/content/browser/compositor/software_output_device_ozone.h b/content/browser/compositor/software_output_device_ozone.h index 60476d81..00990e0 100644 --- a/content/browser/compositor/software_output_device_ozone.h +++ b/content/browser/compositor/software_output_device_ozone.h
@@ -5,8 +5,9 @@ #ifndef CONTENT_BROWSER_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_OZONE_H_ #define CONTENT_BROWSER_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_OZONE_H_ +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "cc/output/software_output_device.h" #include "content/common/content_export.h" #include "ui/gfx/native_widget_types.h" @@ -24,7 +25,7 @@ class CONTENT_EXPORT SoftwareOutputDeviceOzone : public cc::SoftwareOutputDevice { public: - static scoped_ptr<SoftwareOutputDeviceOzone> Create( + static std::unique_ptr<SoftwareOutputDeviceOzone> Create( ui::Compositor* compositor); ~SoftwareOutputDeviceOzone() override; @@ -37,7 +38,7 @@ explicit SoftwareOutputDeviceOzone(ui::Compositor* compositor); ui::Compositor* compositor_; - scoped_ptr<ui::SurfaceOzoneCanvas> surface_ozone_; + std::unique_ptr<ui::SurfaceOzoneCanvas> surface_ozone_; DISALLOW_COPY_AND_ASSIGN(SoftwareOutputDeviceOzone); };
diff --git a/content/browser/compositor/software_output_device_ozone_unittest.cc b/content/browser/compositor/software_output_device_ozone_unittest.cc index 71c8bd94..8ff6181 100644 --- a/content/browser/compositor/software_output_device_ozone_unittest.cc +++ b/content/browser/compositor/software_output_device_ozone_unittest.cc
@@ -2,11 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/browser/compositor/software_output_device_ozone.h" + +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" #include "base/thread_task_runner_handle.h" -#include "content/browser/compositor/software_output_device_ozone.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/skia/include/core/SkCanvas.h" #include "ui/compositor/compositor.h" @@ -63,14 +65,14 @@ void TearDown() override; protected: - scoped_ptr<content::SoftwareOutputDeviceOzone> output_device_; + std::unique_ptr<content::SoftwareOutputDeviceOzone> output_device_; bool enable_pixel_output_; private: - scoped_ptr<ui::Compositor> compositor_; - scoped_ptr<base::MessageLoop> message_loop_; + std::unique_ptr<ui::Compositor> compositor_; + std::unique_ptr<base::MessageLoop> message_loop_; TestPlatformWindowDelegate window_delegate_; - scoped_ptr<ui::PlatformWindow> window_; + std::unique_ptr<ui::PlatformWindow> window_; DISALLOW_COPY_AND_ASSIGN(SoftwareOutputDeviceOzoneTest); };
diff --git a/content/browser/compositor/software_output_device_win.h b/content/browser/compositor/software_output_device_win.h index 5c80340..61066ce 100644 --- a/content/browser/compositor/software_output_device_win.h +++ b/content/browser/compositor/software_output_device_win.h
@@ -5,13 +5,13 @@ #ifndef CONTENT_BROWSER_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_WIN_H_ #define CONTENT_BROWSER_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_WIN_H_ -#include <windows.h> #include <stddef.h> +#include <windows.h> +#include <memory> #include <vector> #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "cc/output/software_output_device.h" #include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkRefCnt.h" @@ -41,7 +41,7 @@ size_t GetMaxByteSize(); std::vector<SoftwareOutputDeviceWin*> devices_; - scoped_ptr<base::SharedMemory> backing_; + std::unique_ptr<base::SharedMemory> backing_; size_t created_byte_size_; DISALLOW_COPY_AND_ASSIGN(OutputDeviceBacking);
diff --git a/content/browser/compositor/surface_utils.cc b/content/browser/compositor/surface_utils.cc index 4f4b3ba..a0b878b7 100644 --- a/content/browser/compositor/surface_utils.cc +++ b/content/browser/compositor/surface_utils.cc
@@ -30,9 +30,9 @@ #if !defined(OS_ANDROID) || defined(USE_AURA) void CopyFromCompositingSurfaceFinished( const content::ReadbackRequestCallback& callback, - scoped_ptr<cc::SingleReleaseCallback> release_callback, - scoped_ptr<SkBitmap> bitmap, - scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock, + std::unique_ptr<cc::SingleReleaseCallback> release_callback, + std::unique_ptr<SkBitmap> bitmap, + std::unique_ptr<SkAutoLockPixels> bitmap_pixels_lock, bool result) { bitmap_pixels_lock.reset(); @@ -59,7 +59,7 @@ const gfx::Size& dst_size_in_pixel, const SkColorType color_type, const content::ReadbackRequestCallback& callback, - scoped_ptr<cc::CopyOutputResult> result) { + std::unique_ptr<cc::CopyOutputResult> result) { #if defined(OS_ANDROID) && !defined(USE_AURA) // TODO(wjmaclean): See if there's an equivalent pathway for Android and // implement it here. @@ -72,7 +72,7 @@ // TODO(siva.gunturi): We should be able to validate the format here using // GLHelper::IsReadbackConfigSupported before we processs the result. // See crbug.com/415682 and crbug.com/415131. - scoped_ptr<SkBitmap> bitmap(new SkBitmap); + std::unique_ptr<SkBitmap> bitmap(new SkBitmap); if (!bitmap->tryAllocPixels(SkImageInfo::Make( dst_size_in_pixel.width(), dst_size_in_pixel.height(), color_type, kOpaque_SkAlphaType))) { @@ -87,12 +87,12 @@ if (!gl_helper) return; - scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock( + std::unique_ptr<SkAutoLockPixels> bitmap_pixels_lock( new SkAutoLockPixels(*bitmap)); uint8_t* pixels = static_cast<uint8_t*>(bitmap->getPixels()); cc::TextureMailbox texture_mailbox; - scoped_ptr<cc::SingleReleaseCallback> release_callback; + std::unique_ptr<cc::SingleReleaseCallback> release_callback; result->TakeTexture(&texture_mailbox, &release_callback); DCHECK(texture_mailbox.IsTexture()); @@ -112,14 +112,14 @@ const gfx::Size& dst_size_in_pixel, const SkColorType preferred_color_type, const content::ReadbackRequestCallback& callback, - scoped_ptr<cc::CopyOutputResult> result) { + std::unique_ptr<cc::CopyOutputResult> result) { SkColorType color_type = preferred_color_type; if (color_type != kN32_SkColorType && color_type != kAlpha_8_SkColorType) { // Switch back to default colortype if format not supported. color_type = kN32_SkColorType; } DCHECK(result->HasBitmap()); - scoped_ptr<SkBitmap> source = result->TakeBitmap(); + std::unique_ptr<SkBitmap> source = result->TakeBitmap(); DCHECK(source); SkBitmap scaled_bitmap; if (source->width() != dst_size_in_pixel.width() || @@ -158,7 +158,7 @@ namespace content { -scoped_ptr<cc::SurfaceIdAllocator> CreateSurfaceIdAllocator() { +std::unique_ptr<cc::SurfaceIdAllocator> CreateSurfaceIdAllocator() { #if defined(OS_ANDROID) return CompositorImpl::CreateSurfaceIdAllocator(); #else @@ -180,7 +180,7 @@ const gfx::Size& dst_size_in_pixel, const SkColorType color_type, const ReadbackRequestCallback& callback, - scoped_ptr<cc::CopyOutputResult> result) { + std::unique_ptr<cc::CopyOutputResult> result) { if (result->IsEmpty() || result->size().IsEmpty()) { callback.Run(SkBitmap(), READBACK_FAILED); return;
diff --git a/content/browser/compositor/surface_utils.h b/content/browser/compositor/surface_utils.h index 6d986a9c8..54f7a32 100644 --- a/content/browser/compositor/surface_utils.h +++ b/content/browser/compositor/surface_utils.h
@@ -5,7 +5,8 @@ #ifndef CONTENT_BROWSER_COMPOSITOR_SURFACE_UTILS_H_ #define CONTENT_BROWSER_COMPOSITOR_SURFACE_UTILS_H_ -#include "base/memory/scoped_ptr.h" +#include <memory> + #include "content/common/content_export.h" #include "content/public/browser/readback_types.h" #include "third_party/skia/include/core/SkImageInfo.h" @@ -19,7 +20,7 @@ namespace content { -scoped_ptr<cc::SurfaceIdAllocator> CreateSurfaceIdAllocator(); +std::unique_ptr<cc::SurfaceIdAllocator> CreateSurfaceIdAllocator(); CONTENT_EXPORT cc::SurfaceManager* GetSurfaceManager(); @@ -28,7 +29,7 @@ const gfx::Size& dst_size_in_pixel, const SkColorType color_type, const ReadbackRequestCallback& callback, - scoped_ptr<cc::CopyOutputResult> result); + std::unique_ptr<cc::CopyOutputResult> result); } // namespace content
diff --git a/content/browser/compositor/test/no_transport_image_transport_factory.cc b/content/browser/compositor/test/no_transport_image_transport_factory.cc index f58d11fb..e7c46e0 100644 --- a/content/browser/compositor/test/no_transport_image_transport_factory.cc +++ b/content/browser/compositor/test/no_transport_image_transport_factory.cc
@@ -24,7 +24,7 @@ new ui::InProcessContextFactory(true, surface_manager_.get())) {} NoTransportImageTransportFactory::~NoTransportImageTransportFactory() { - scoped_ptr<GLHelper> lost_gl_helper = std::move(gl_helper_); + std::unique_ptr<GLHelper> lost_gl_helper = std::move(gl_helper_); FOR_EACH_OBSERVER( ImageTransportFactoryObserver, observer_list_, OnLostResources()); }
diff --git a/content/browser/compositor/test/no_transport_image_transport_factory.h b/content/browser/compositor/test/no_transport_image_transport_factory.h index 52f4ebe..ccfee379 100644 --- a/content/browser/compositor/test/no_transport_image_transport_factory.h +++ b/content/browser/compositor/test/no_transport_image_transport_factory.h
@@ -5,8 +5,9 @@ #ifndef CONTENT_BROWSER_COMPOSITOR_TEST_NO_TRANSPORT_IMAGE_TRANSPORT_FACTORY_H_ #define CONTENT_BROWSER_COMPOSITOR_TEST_NO_TRANSPORT_IMAGE_TRANSPORT_FACTORY_H_ +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/observer_list.h" #include "build/build_config.h" #include "content/browser/compositor/image_transport_factory.h" @@ -41,10 +42,10 @@ #endif private: - scoped_ptr<cc::SurfaceManager> surface_manager_; - scoped_ptr<ui::ContextFactory> context_factory_; + std::unique_ptr<cc::SurfaceManager> surface_manager_; + std::unique_ptr<ui::ContextFactory> context_factory_; scoped_refptr<cc::ContextProvider> context_provider_; - scoped_ptr<GLHelper> gl_helper_; + std::unique_ptr<GLHelper> gl_helper_; base::ObserverList<ImageTransportFactoryObserver> observer_list_; DISALLOW_COPY_AND_ASSIGN(NoTransportImageTransportFactory);
diff --git a/content/browser/cross_site_transfer_browsertest.cc b/content/browser/cross_site_transfer_browsertest.cc index 1b7c099e..658519c3 100644 --- a/content/browser/cross_site_transfer_browsertest.cc +++ b/content/browser/cross_site_transfer_browsertest.cc
@@ -130,7 +130,7 @@ base::Closure run_loop_quit_closure_; // This lives on the UI thread. - scoped_ptr<base::RunLoop> run_loop_; + std::unique_ptr<base::RunLoop> run_loop_; // Set on the IO thread while |run_loop_| is non-nullptr, read on the UI // thread after deleting run_loop_.
diff --git a/content/browser/database_tracker_unittest.cc b/content/browser/database_tracker_unittest.cc index 189257f..1d6061a 100644 --- a/content/browser/database_tracker_unittest.cc +++ b/content/browser/database_tracker_unittest.cc
@@ -5,11 +5,12 @@ #include <stddef.h> #include <stdint.h> +#include <memory> + #include "base/files/file.h" #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" -#include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" #include "base/strings/utf_string_conversions.h" #include "base/thread_task_runner_handle.h"
diff --git a/content/browser/device_sensors/ambient_light_mac.cc b/content/browser/device_sensors/ambient_light_mac.cc index 6f8d3d9..c660679 100644 --- a/content/browser/device_sensors/ambient_light_mac.cc +++ b/content/browser/device_sensors/ambient_light_mac.cc
@@ -23,8 +23,8 @@ } // namespace // static -scoped_ptr<AmbientLightSensor> AmbientLightSensor::Create() { - scoped_ptr<AmbientLightSensor> light_sensor(new AmbientLightSensor); +std::unique_ptr<AmbientLightSensor> AmbientLightSensor::Create() { + std::unique_ptr<AmbientLightSensor> light_sensor(new AmbientLightSensor); return light_sensor->Init() ? std::move(light_sensor) : nullptr; }
diff --git a/content/browser/device_sensors/ambient_light_mac.h b/content/browser/device_sensors/ambient_light_mac.h index 36eff8b..6d4af75 100644 --- a/content/browser/device_sensors/ambient_light_mac.h +++ b/content/browser/device_sensors/ambient_light_mac.h
@@ -8,8 +8,9 @@ #include <IOKit/IOKitLib.h> #include <stdint.h> +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" namespace content { @@ -17,7 +18,7 @@ class AmbientLightSensor { public: // Create AmbientLightSensor object, return NULL if no valid is sensor found. - static scoped_ptr<AmbientLightSensor> Create(); + static std::unique_ptr<AmbientLightSensor> Create(); ~AmbientLightSensor();
diff --git a/content/browser/device_sensors/data_fetcher_shared_memory.h b/content/browser/device_sensors/data_fetcher_shared_memory.h index e1e97e3..607cbb73 100644 --- a/content/browser/device_sensors/data_fetcher_shared_memory.h +++ b/content/browser/device_sensors/data_fetcher_shared_memory.h
@@ -53,13 +53,13 @@ #endif #if defined(OS_CHROMEOS) - scoped_ptr<SensorManagerChromeOS> sensor_manager_; + std::unique_ptr<SensorManagerChromeOS> sensor_manager_; #elif defined(OS_MACOSX) void Fetch(unsigned consumer_bitmask) override; FetcherType GetType() const override; - scoped_ptr<AmbientLightSensor> ambient_light_sensor_; - scoped_ptr<SuddenMotionSensor> sudden_motion_sensor_; + std::unique_ptr<AmbientLightSensor> ambient_light_sensor_; + std::unique_ptr<SuddenMotionSensor> sudden_motion_sensor_; #elif defined(OS_WIN) class SensorEventSink; class SensorEventSinkMotion;
diff --git a/content/browser/device_sensors/data_fetcher_shared_memory_base.cc b/content/browser/device_sensors/data_fetcher_shared_memory_base.cc index be3780e..2689b60 100644 --- a/content/browser/device_sensors/data_fetcher_shared_memory_base.cc +++ b/content/browser/device_sensors/data_fetcher_shared_memory_base.cc
@@ -56,7 +56,7 @@ unsigned consumers_bitmask_; DataFetcherSharedMemoryBase* fetcher_; - scoped_ptr<base::RepeatingTimer> timer_; + std::unique_ptr<base::RepeatingTimer> timer_; DISALLOW_COPY_AND_ASSIGN(PollingThread); }; @@ -226,7 +226,7 @@ if (buffer_size == 0) return nullptr; - scoped_ptr<base::SharedMemory> new_shared_mem(new base::SharedMemory); + std::unique_ptr<base::SharedMemory> new_shared_mem(new base::SharedMemory); if (new_shared_mem->CreateAndMapAnonymous(buffer_size)) { if (void* mem = new_shared_mem->memory()) { memset(mem, 0, buffer_size);
diff --git a/content/browser/device_sensors/data_fetcher_shared_memory_base.h b/content/browser/device_sensors/data_fetcher_shared_memory_base.h index f36ad7c4..f6431f8 100644 --- a/content/browser/device_sensors/data_fetcher_shared_memory_base.h +++ b/content/browser/device_sensors/data_fetcher_shared_memory_base.h
@@ -6,9 +6,9 @@ #define CONTENT_BROWSER_DEVICE_SENSORS_DATA_FETCHER_SHARED_MEMORY_BASE_H_ #include <map> +#include <memory> #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/shared_memory.h" #include "base/message_loop/message_loop.h" #include "content/browser/device_sensors/device_sensors_consts.h" @@ -89,7 +89,7 @@ unsigned started_consumers_; - scoped_ptr<PollingThread> polling_thread_; + std::unique_ptr<PollingThread> polling_thread_; // Owning pointers. Objects in the map are deleted in dtor. typedef std::map<ConsumerType, base::SharedMemory*> SharedMemoryMap;
diff --git a/content/browser/device_sensors/device_inertial_sensor_service.h b/content/browser/device_sensors/device_inertial_sensor_service.h index f25abc6..bd3cf0c 100644 --- a/content/browser/device_sensors/device_inertial_sensor_service.h +++ b/content/browser/device_sensors/device_inertial_sensor_service.h
@@ -5,9 +5,10 @@ #ifndef CONTENT_BROWSER_DEVICE_SENSORS_DEVICE_INERTIAL_SENSOR_SERVICE_H_ #define CONTENT_BROWSER_DEVICE_SENSORS_DEVICE_INERTIAL_SENSOR_SERVICE_H_ +#include <memory> + #include "base/callback_forward.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/shared_memory.h" #include "base/memory/singleton.h" #include "base/threading/thread_checker.h" @@ -61,7 +62,7 @@ int num_orientation_readers_; int num_orientation_absolute_readers_; bool is_shutdown_; - scoped_ptr<DataFetcherSharedMemory> data_fetcher_; + std::unique_ptr<DataFetcherSharedMemory> data_fetcher_; base::ThreadChecker thread_checker_; DISALLOW_COPY_AND_ASSIGN(DeviceInertialSensorService);
diff --git a/content/browser/device_sensors/sensor_manager_android.h b/content/browser/device_sensors/sensor_manager_android.h index 0eb2f6c..67d28b9b 100644 --- a/content/browser/device_sensors/sensor_manager_android.h +++ b/content/browser/device_sensors/sensor_manager_android.h
@@ -5,9 +5,10 @@ #ifndef CONTENT_BROWSER_DEVICE_SENSORS_SENSOR_MANAGER_ANDROID_H_ #define CONTENT_BROWSER_DEVICE_SENSORS_SENSOR_MANAGER_ANDROID_H_ +#include <memory> + #include "base/android/scoped_java_ref.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/synchronization/lock.h" #include "content/browser/device_sensors/device_sensors_consts.h" #include "content/common/content_export.h"
diff --git a/content/browser/device_sensors/sensor_manager_android_unittest.cc b/content/browser/device_sensors/sensor_manager_android_unittest.cc index 133b1b5..04aa6497 100644 --- a/content/browser/device_sensors/sensor_manager_android_unittest.cc +++ b/content/browser/device_sensors/sensor_manager_android_unittest.cc
@@ -4,8 +4,9 @@ #include "content/browser/device_sensors/sensor_manager_android.h" +#include <memory> + #include "base/android/jni_android.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "content/browser/device_sensors/device_sensors_consts.h" #include "content/public/test/test_browser_thread_bundle.h" @@ -61,10 +62,10 @@ ASSERT_TRUE(buffer->data.hasGamma); } - scoped_ptr<DeviceLightHardwareBuffer> light_buffer_; - scoped_ptr<DeviceMotionHardwareBuffer> motion_buffer_; - scoped_ptr<DeviceOrientationHardwareBuffer> orientation_buffer_; - scoped_ptr<DeviceOrientationHardwareBuffer> orientation_absolute_buffer_; + std::unique_ptr<DeviceLightHardwareBuffer> light_buffer_; + std::unique_ptr<DeviceMotionHardwareBuffer> motion_buffer_; + std::unique_ptr<DeviceOrientationHardwareBuffer> orientation_buffer_; + std::unique_ptr<DeviceOrientationHardwareBuffer> orientation_absolute_buffer_; content::TestBrowserThreadBundle thread_bundle_; };
diff --git a/content/browser/device_sensors/sensor_manager_chromeos_unittest.cc b/content/browser/device_sensors/sensor_manager_chromeos_unittest.cc index 7693e4d..deb3e9d 100644 --- a/content/browser/device_sensors/sensor_manager_chromeos_unittest.cc +++ b/content/browser/device_sensors/sensor_manager_chromeos_unittest.cc
@@ -4,8 +4,9 @@ #include "content/browser/device_sensors/sensor_manager_chromeos.h" +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "chromeos/accelerometer/accelerometer_types.h" #include "content/common/device_sensors/device_motion_hardware_buffer.h" #include "content/common/device_sensors/device_orientation_hardware_buffer.h" @@ -75,9 +76,9 @@ } private: - scoped_ptr<TestSensorManagerChromeOS> sensor_manager_; - scoped_ptr<DeviceMotionHardwareBuffer> motion_buffer_; - scoped_ptr<DeviceOrientationHardwareBuffer> orientation_buffer_; + std::unique_ptr<TestSensorManagerChromeOS> sensor_manager_; + std::unique_ptr<DeviceMotionHardwareBuffer> motion_buffer_; + std::unique_ptr<DeviceOrientationHardwareBuffer> orientation_buffer_; DISALLOW_COPY_AND_ASSIGN(SensorManagerChromeOSTest); };
diff --git a/content/browser/devtools/browser_devtools_agent_host.h b/content/browser/devtools/browser_devtools_agent_host.h index 908d48a..8f9bf63a 100644 --- a/content/browser/devtools/browser_devtools_agent_host.h +++ b/content/browser/devtools/browser_devtools_agent_host.h
@@ -39,12 +39,13 @@ bool Close() override; bool DispatchProtocolMessage(const std::string& message) override; - scoped_ptr<devtools::io::IOHandler> io_handler_; - scoped_ptr<devtools::memory::MemoryHandler> memory_handler_; - scoped_ptr<devtools::system_info::SystemInfoHandler> system_info_handler_; - scoped_ptr<devtools::tethering::TetheringHandler> tethering_handler_; - scoped_ptr<devtools::tracing::TracingHandler> tracing_handler_; - scoped_ptr<DevToolsProtocolHandler> protocol_handler_; + std::unique_ptr<devtools::io::IOHandler> io_handler_; + std::unique_ptr<devtools::memory::MemoryHandler> memory_handler_; + std::unique_ptr<devtools::system_info::SystemInfoHandler> + system_info_handler_; + std::unique_ptr<devtools::tethering::TetheringHandler> tethering_handler_; + std::unique_ptr<devtools::tracing::TracingHandler> tracing_handler_; + std::unique_ptr<DevToolsProtocolHandler> protocol_handler_; }; } // namespace content
diff --git a/content/browser/devtools/devtools_frame_trace_recorder.cc b/content/browser/devtools/devtools_frame_trace_recorder.cc index d575638..0771f8f1 100644 --- a/content/browser/devtools/devtools_frame_trace_recorder.cc +++ b/content/browser/devtools/devtools_frame_trace_recorder.cc
@@ -78,7 +78,7 @@ TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID_AND_TIMESTAMP( TRACE_DISABLED_BY_DEFAULT("devtools.screenshot"), "Screenshot", 1, timestamp.ToInternalValue(), - scoped_ptr<base::trace_event::ConvertableToTraceFormat>( + std::unique_ptr<base::trace_event::ConvertableToTraceFormat>( new TraceableDevToolsScreenshot(bitmap))); }
diff --git a/content/browser/devtools/devtools_frame_trace_recorder.h b/content/browser/devtools/devtools_frame_trace_recorder.h index 79c6f16..236e14d 100644 --- a/content/browser/devtools/devtools_frame_trace_recorder.h +++ b/content/browser/devtools/devtools_frame_trace_recorder.h
@@ -5,9 +5,10 @@ #ifndef CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_FRAME_TRACE_RECORDER_H_ #define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_FRAME_TRACE_RECORDER_H_ +#include <memory> + #include "base/compiler_specific.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" namespace cc { @@ -33,7 +34,7 @@ private: DISALLOW_COPY_AND_ASSIGN(DevToolsFrameTraceRecorder); - scoped_ptr<cc::CompositorFrameMetadata> last_metadata_; + std::unique_ptr<cc::CompositorFrameMetadata> last_metadata_; }; } // namespace content
diff --git a/content/browser/devtools/devtools_manager.h b/content/browser/devtools/devtools_manager.h index f803c13..54d2f99 100644 --- a/content/browser/devtools/devtools_manager.h +++ b/content/browser/devtools/devtools_manager.h
@@ -5,9 +5,10 @@ #ifndef CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_MANAGER_H_ #define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_MANAGER_H_ +#include <memory> + #include "base/compiler_specific.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/singleton.h" #include "content/common/content_export.h" #include "content/public/browser/devtools_manager_delegate.h" @@ -35,7 +36,7 @@ private: friend struct base::DefaultSingletonTraits<DevToolsManager>; - scoped_ptr<DevToolsManagerDelegate> delegate_; + std::unique_ptr<DevToolsManagerDelegate> delegate_; int attached_hosts_count_; DISALLOW_COPY_AND_ASSIGN(DevToolsManager);
diff --git a/content/browser/devtools/devtools_manager_unittest.cc b/content/browser/devtools/devtools_manager_unittest.cc index 24d8dc0..f0ed8f8 100644 --- a/content/browser/devtools/devtools_manager_unittest.cc +++ b/content/browser/devtools/devtools_manager_unittest.cc
@@ -2,13 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/browser/devtools/devtools_manager.h" + +#include <memory> + #include "base/location.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/single_thread_task_runner.h" #include "base/thread_task_runner_handle.h" #include "base/time/time.h" -#include "content/browser/devtools/devtools_manager.h" #include "content/browser/devtools/shared_worker_devtools_manager.h" #include "content/browser/shared_worker/shared_worker_instance.h" #include "content/browser/shared_worker/worker_storage_partition.h"
diff --git a/content/browser/devtools/devtools_netlog_observer.cc b/content/browser/devtools/devtools_netlog_observer.cc index 6a2a3c4..a11142d6 100644 --- a/content/browser/devtools/devtools_netlog_observer.cc +++ b/content/browser/devtools/devtools_netlog_observer.cc
@@ -78,7 +78,7 @@ switch (entry.type()) { case net::NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST_HEADERS: { - scoped_ptr<base::Value> event_params(entry.ParametersToValue()); + std::unique_ptr<base::Value> event_params(entry.ParametersToValue()); std::string request_line; net::HttpRequestHeaders request_headers; @@ -100,7 +100,7 @@ break; } case net::NetLog::TYPE_HTTP_TRANSACTION_HTTP2_SEND_REQUEST_HEADERS: { - scoped_ptr<base::Value> event_params(entry.ParametersToValue()); + std::unique_ptr<base::Value> event_params(entry.ParametersToValue()); net::SpdyHeaderBlock request_headers; if (!net::SpdyHeaderBlockFromNetLogParam(event_params.get(), @@ -121,7 +121,7 @@ break; } case net::NetLog::TYPE_HTTP_TRANSACTION_READ_RESPONSE_HEADERS: { - scoped_ptr<base::Value> event_params(entry.ParametersToValue()); + std::unique_ptr<base::Value> event_params(entry.ParametersToValue()); scoped_refptr<net::HttpResponseHeaders> response_headers;
diff --git a/content/browser/devtools/devtools_protocol_handler.cc b/content/browser/devtools/devtools_protocol_handler.cc index e92ef84..c7bba21 100644 --- a/content/browser/devtools/devtools_protocol_handler.cc +++ b/content/browser/devtools/devtools_protocol_handler.cc
@@ -9,6 +9,7 @@ #include "base/bind.h" #include "base/json/json_reader.h" #include "base/json/json_writer.h" +#include "base/memory/ptr_util.h" #include "content/browser/devtools/devtools_agent_host_impl.h" #include "content/browser/devtools/devtools_manager.h" #include "content/public/browser/devtools_manager_delegate.h" @@ -26,14 +27,15 @@ const int kStatusInvalidRequest = -32600; const int kStatusNoSuchMethod = -32601; -scoped_ptr<base::DictionaryValue> TakeDictionary(base::DictionaryValue* dict, - const std::string& key) { - scoped_ptr<base::Value> value; +std::unique_ptr<base::DictionaryValue> TakeDictionary( + base::DictionaryValue* dict, + const std::string& key) { + std::unique_ptr<base::Value> value; dict->Remove(key, &value); base::DictionaryValue* result = nullptr; if (value) value.release()->GetAsDictionary(&result); - return make_scoped_ptr(result); + return base::WrapUnique(result); } } // namespace @@ -47,7 +49,8 @@ void DevToolsProtocolHandler::HandleMessage(int session_id, const std::string& message) { - scoped_ptr<base::DictionaryValue> command = ParseCommand(session_id, message); + std::unique_ptr<base::DictionaryValue> command = + ParseCommand(session_id, message); if (!command) return; if (PassCommandToDelegate(session_id, command.get())) @@ -58,7 +61,8 @@ bool DevToolsProtocolHandler::HandleOptionalMessage(int session_id, const std::string& message, int* call_id) { - scoped_ptr<base::DictionaryValue> command = ParseCommand(session_id, message); + std::unique_ptr<base::DictionaryValue> command = + ParseCommand(session_id, message); if (!command) return true; if (PassCommandToDelegate(session_id, command.get())) @@ -74,7 +78,7 @@ if (!delegate) return false; - scoped_ptr<base::DictionaryValue> response( + std::unique_ptr<base::DictionaryValue> response( delegate->HandleCommand(agent_host_, command)); if (response) { client_.SendMessage(session_id, *response); @@ -84,10 +88,10 @@ return false; } -scoped_ptr<base::DictionaryValue> DevToolsProtocolHandler::ParseCommand( +std::unique_ptr<base::DictionaryValue> DevToolsProtocolHandler::ParseCommand( int session_id, const std::string& message) { - scoped_ptr<base::Value> value = base::JSONReader::Read(message); + std::unique_ptr<base::Value> value = base::JSONReader::Read(message); if (!value || !value->IsType(base::Value::TYPE_DICTIONARY)) { client_.SendError( DevToolsCommandId(DevToolsCommandId::kNoId, session_id), @@ -95,8 +99,8 @@ return nullptr; } - scoped_ptr<base::DictionaryValue> command = - make_scoped_ptr(static_cast<base::DictionaryValue*>(value.release())); + std::unique_ptr<base::DictionaryValue> command = + base::WrapUnique(static_cast<base::DictionaryValue*>(value.release())); int call_id = DevToolsCommandId::kNoId; bool ok = command->GetInteger(kIdParam, &call_id) && call_id >= 0; if (!ok) { @@ -120,7 +124,7 @@ void DevToolsProtocolHandler::HandleCommand( int session_id, - scoped_ptr<base::DictionaryValue> command) { + std::unique_ptr<base::DictionaryValue> command) { int call_id = DevToolsCommandId::kNoId; std::string method; command->GetInteger(kIdParam, &call_id); @@ -141,7 +145,7 @@ bool DevToolsProtocolHandler::HandleOptionalCommand( int session_id, - scoped_ptr<base::DictionaryValue> command, + std::unique_ptr<base::DictionaryValue> command, int* call_id) { *call_id = DevToolsCommandId::kNoId; std::string method;
diff --git a/content/browser/devtools/devtools_protocol_handler.h b/content/browser/devtools/devtools_protocol_handler.h index 32f49287..d9fc156 100644 --- a/content/browser/devtools/devtools_protocol_handler.h +++ b/content/browser/devtools/devtools_protocol_handler.h
@@ -28,12 +28,14 @@ DevToolsProtocolDispatcher* dispatcher() { return &dispatcher_; } private: - scoped_ptr<base::DictionaryValue> ParseCommand(int session_id, - const std::string& message); + std::unique_ptr<base::DictionaryValue> ParseCommand( + int session_id, + const std::string& message); bool PassCommandToDelegate(int session_id, base::DictionaryValue* command); - void HandleCommand(int session_id, scoped_ptr<base::DictionaryValue> command); + void HandleCommand(int session_id, + std::unique_ptr<base::DictionaryValue> command); bool HandleOptionalCommand(int session_id, - scoped_ptr<base::DictionaryValue> command, + std::unique_ptr<base::DictionaryValue> command, int* call_id); DevToolsAgentHost* agent_host_;
diff --git a/content/browser/devtools/forwarding_agent_host.h b/content/browser/devtools/forwarding_agent_host.h index 2b6ccce..dc8c426 100644 --- a/content/browser/devtools/forwarding_agent_host.h +++ b/content/browser/devtools/forwarding_agent_host.h
@@ -5,8 +5,9 @@ #ifndef CONTENT_BROWSER_DEVTOOLS_FORWARDING_AGENT_HOST_H_ #define CONTENT_BROWSER_DEVTOOLS_FORWARDING_AGENT_HOST_H_ +#include <memory> + #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/devtools/devtools_agent_host_impl.h" #include "content/public/browser/devtools_external_agent_proxy.h" #include "content/public/browser/devtools_external_agent_proxy_delegate.h" @@ -38,7 +39,7 @@ bool Activate() override; bool Close() override; - scoped_ptr<DevToolsExternalAgentProxyDelegate> delegate_; + std::unique_ptr<DevToolsExternalAgentProxyDelegate> delegate_; }; } // namespace content
diff --git a/content/browser/devtools/protocol/devtools_protocol_browsertest.cc b/content/browser/devtools/protocol/devtools_protocol_browsertest.cc index 3f47111..5652259 100644 --- a/content/browser/devtools/protocol/devtools_protocol_browsertest.cc +++ b/content/browser/devtools/protocol/devtools_protocol_browsertest.cc
@@ -47,12 +47,12 @@ protected: void SendCommand(const std::string& method, - scoped_ptr<base::DictionaryValue> params) { + std::unique_ptr<base::DictionaryValue> params) { SendCommand(method, std::move(params), true); } void SendCommand(const std::string& method, - scoped_ptr<base::DictionaryValue> params, + std::unique_ptr<base::DictionaryValue> params, bool wait) { in_dispatch_ = true; base::DictionaryValue command; @@ -115,7 +115,7 @@ RunMessageLoop(); } - scoped_ptr<base::DictionaryValue> result_; + std::unique_ptr<base::DictionaryValue> result_; scoped_refptr<DevToolsAgentHost> agent_host_; int last_sent_id_; std::vector<int> result_ids_; @@ -124,8 +124,9 @@ private: void DispatchProtocolMessage(DevToolsAgentHost* agent_host, const std::string& message) override { - scoped_ptr<base::DictionaryValue> root(static_cast<base::DictionaryValue*>( - base::JSONReader::Read(message).release())); + std::unique_ptr<base::DictionaryValue> root( + static_cast<base::DictionaryValue*>( + base::JSONReader::Read(message).release())); int id; if (root->GetInteger("id", &id)) { result_ids_.push_back(id); @@ -163,7 +164,7 @@ int modifier, int windowsKeyCode, int nativeKeyCode) { - scoped_ptr<base::DictionaryValue> params(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); params->SetString("type", type); params->SetInteger("modifiers", modifier); params->SetInteger("windowsVirtualKeyCode", windowsKeyCode); @@ -263,7 +264,7 @@ shell()->web_contents(), "domAutomationController.send(window.innerHeight)", &old_height)); - scoped_ptr<base::DictionaryValue> params(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); params->SetInteger("x", old_width / 2); params->SetInteger("y", old_height / 2); params->SetDouble("scaleFactor", 2.0); @@ -293,7 +294,7 @@ "domAutomationController.send(document.body.scrollTop)", &scroll_top)); ASSERT_EQ(0, scroll_top); - scoped_ptr<base::DictionaryValue> params(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); params->SetInteger("x", 0); params->SetInteger("y", 0); params->SetInteger("xDistance", 0); @@ -317,7 +318,7 @@ "domAutomationController.send(document.body.scrollTop)", &scroll_top)); ASSERT_EQ(0, scroll_top); - scoped_ptr<base::DictionaryValue> params(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); params->SetInteger("x", 16); params->SetInteger("y", 16); params->SetString("gestureSourceType", "touch"); @@ -341,7 +342,7 @@ Attach(); SendCommand("Page.enable", nullptr, false); - scoped_ptr<base::DictionaryValue> params(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); test_url = GetTestUrl("devtools", "navigation.html"); params->SetString("url", test_url.spec()); TestNavigationObserver navigation_observer(shell()->web_contents()); @@ -491,7 +492,7 @@ IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, EvaluateInBlankPage) { NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); Attach(); - scoped_ptr<base::DictionaryValue> params(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); params->SetString("expression", "window"); SendCommand("Runtime.evaluate", std::move(params), true); bool wasThrown = true; @@ -506,7 +507,7 @@ NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 1); Attach(); NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); - scoped_ptr<base::DictionaryValue> params(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); params->SetString("expression", "window"); SendCommand("Runtime.evaluate", std::move(params), true); bool wasThrown = true;
diff --git a/content/browser/devtools/protocol/devtools_protocol_client.cc b/content/browser/devtools/protocol/devtools_protocol_client.cc index 9ca03f9d..5f132d9 100644 --- a/content/browser/devtools/protocol/devtools_protocol_client.cc +++ b/content/browser/devtools/protocol/devtools_protocol_client.cc
@@ -53,7 +53,7 @@ void DevToolsProtocolClient::SendNotification( const std::string& method, - scoped_ptr<base::DictionaryValue> params) { + std::unique_ptr<base::DictionaryValue> params) { base::DictionaryValue notification; notification.SetString(kMethodParam, method); if (params) @@ -66,7 +66,7 @@ void DevToolsProtocolClient::SendSuccess( DevToolsCommandId command_id, - scoped_ptr<base::DictionaryValue> params) { + std::unique_ptr<base::DictionaryValue> params) { base::DictionaryValue response; response.SetInteger(kIdParam, command_id.call_id);
diff --git a/content/browser/devtools/protocol/devtools_protocol_client.h b/content/browser/devtools/protocol/devtools_protocol_client.h index ba1a0d7..87003f49 100644 --- a/content/browser/devtools/protocol/devtools_protocol_client.h +++ b/content/browser/devtools/protocol/devtools_protocol_client.h
@@ -5,9 +5,10 @@ #ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_DEVTOOLS_PROTOCOL_CLIENT_H_ #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_DEVTOOLS_PROTOCOL_CLIENT_H_ +#include <memory> + #include "base/callback.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/values.h" namespace content { @@ -65,9 +66,9 @@ protected: void SendSuccess(DevToolsCommandId command_id, - scoped_ptr<base::DictionaryValue> params); + std::unique_ptr<base::DictionaryValue> params); void SendNotification(const std::string& method, - scoped_ptr<base::DictionaryValue> params); + std::unique_ptr<base::DictionaryValue> params); private: friend class DevToolsProtocolDispatcher;
diff --git a/content/browser/devtools/protocol/devtools_protocol_handler_generator.py b/content/browser/devtools/protocol/devtools_protocol_handler_generator.py index 2f244625..fc1893e 100755 --- a/content/browser/devtools/protocol/devtools_protocol_handler_generator.py +++ b/content/browser/devtools/protocol/devtools_protocol_handler_generator.py
@@ -31,6 +31,7 @@ #include <utility> +#include "base/memory/ptr_util.h" #include "content/browser/devtools/protocol/devtools_protocol_client.h" namespace content { @@ -49,7 +50,7 @@ } template<class T> -base::Value* CreateValue(scoped_ptr<T>& param) { +base::Value* CreateValue(std::unique_ptr<T>& param) { return param.release(); } @@ -78,7 +79,7 @@ public: using CommandHandler = base::Callback<bool(DevToolsCommandId, - scoped_ptr<base::DictionaryValue>)>; + std::unique_ptr<base::DictionaryValue>)>; explicit DevToolsProtocolDispatcher(DevToolsProtocolDelegate* notifier); ~DevToolsProtocolDispatcher(); @@ -127,9 +128,9 @@ return new ${declared_name}Builder<kNoneSet>(); } - scoped_ptr<base::DictionaryValue> ToValue() { + std::unique_ptr<base::DictionaryValue> ToValue() { static_assert(MASK == kAllSet, "required properties missing"); - return make_scoped_ptr(dict_->DeepCopy()); + return base::WrapUnique(dict_->DeepCopy()); } private: @@ -145,7 +146,7 @@ return reinterpret_cast<T*>(this); } - scoped_ptr<base::DictionaryValue> dict_; + std::unique_ptr<base::DictionaryValue> dict_; }; typedef ${declared_name}Builder<0> ${declared_name}; @@ -237,7 +238,7 @@ tmpl_callback = string.Template("""\ bool On${Domain}${Command}( DevToolsCommandId command_id, - scoped_ptr<base::DictionaryValue> params); + std::unique_ptr<base::DictionaryValue> params); """) tmpl_field = string.Template("""\ @@ -319,22 +320,22 @@ """) tmpl_init_client = string.Template("""\ - ${domain}_handler_->SetClient(make_scoped_ptr( + ${domain}_handler_->SetClient(base::WrapUnique( new devtools::${domain}::Client(notifier_))); """) tmpl_callback_impl = string.Template("""\ bool DevToolsProtocolDispatcher::On${Domain}${Command}( DevToolsCommandId command_id, - scoped_ptr<base::DictionaryValue> params) { + std::unique_ptr<base::DictionaryValue> params) { ${prep}\ Response response = ${domain}_handler_->${Command}(${args}); - scoped_ptr<base::DictionaryValue> protocol_response; + std::unique_ptr<base::DictionaryValue> protocol_response; if (client_.SendError(command_id, response)) return true; if (response.IsFallThrough()) return false; - scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); ${wrap}\ client_.SendSuccess(command_id, std::move(result)); return true; @@ -348,7 +349,7 @@ tmpl_callback_async_impl = string.Template("""\ bool DevToolsProtocolDispatcher::On${Domain}${Command}( DevToolsCommandId command_id, - scoped_ptr<base::DictionaryValue> params) { + std::unique_ptr<base::DictionaryValue> params) { ${prep}\ Response response = ${domain}_handler_->${Command}(${args}); if (client_.SendError(command_id, response)) @@ -402,7 +403,7 @@ "${param}_found ? ${param_pass} : nullptr") tmpl_object_pass = string.Template( - "make_scoped_ptr<base::DictionaryValue>(${name}->DeepCopy())") + "base::WrapUnique<base::DictionaryValue>(${name}->DeepCopy())") tmpl_client_impl = string.Template("""\ namespace ${domain} { @@ -565,7 +566,7 @@ def ResolveObject(json, mapping): mapping["Type"] = "Dictionary" - mapping["storage_type"] = "scoped_ptr<base::DictionaryValue>" + mapping["storage_type"] = "std::unique_ptr<base::DictionaryValue>" mapping["raw_type"] = "base::DictionaryValue*" mapping["pass_template"] = tmpl_object_pass mapping["init"] = " = nullptr" @@ -583,7 +584,7 @@ mapping["arg_out"] = "&out_%s" % mapping["param"] else: mapping["param_type"] = "base::DictionaryValue" - mapping["pass_type"] = "scoped_ptr<base::DictionaryValue>" + mapping["pass_type"] = "std::unique_ptr<base::DictionaryValue>" mapping["arg_out"] = "out_%s.get()" % mapping["param"] mapping["prep_req"] = tmpl_prep_req.substitute(mapping)
diff --git a/content/browser/devtools/protocol/emulation_handler.cc b/content/browser/devtools/protocol/emulation_handler.cc index 6b124e3..12c377a 100644 --- a/content/browser/devtools/protocol/emulation_handler.cc +++ b/content/browser/devtools/protocol/emulation_handler.cc
@@ -85,7 +85,7 @@ GeolocationServiceContext* geolocation_context = GetWebContents()->GetGeolocationServiceContext(); - scoped_ptr<Geoposition> geoposition(new Geoposition()); + std::unique_ptr<Geoposition> geoposition(new Geoposition()); if (latitude && longitude && accuracy) { geoposition->latitude = *latitude; geoposition->longitude = *longitude; @@ -146,7 +146,7 @@ const int* screen_height, const int* position_x, const int* position_y, - const scoped_ptr<base::DictionaryValue>& screen_orientation) { + const std::unique_ptr<base::DictionaryValue>& screen_orientation) { const static int max_size = 10000000; const static double max_scale = 10; const static int max_orientation_angle = 360;
diff --git a/content/browser/devtools/protocol/emulation_handler.h b/content/browser/devtools/protocol/emulation_handler.h index a5aec63..e61862e 100644 --- a/content/browser/devtools/protocol/emulation_handler.h +++ b/content/browser/devtools/protocol/emulation_handler.h
@@ -52,7 +52,7 @@ const int* screen_height, const int* position_x, const int* position_y, - const scoped_ptr<base::DictionaryValue>& screen_orientation); + const std::unique_ptr<base::DictionaryValue>& screen_orientation); Response ClearDeviceMetricsOverride(); private:
diff --git a/content/browser/devtools/protocol/input_handler.cc b/content/browser/devtools/protocol/input_handler.cc index 08c3cf2..48e901af 100644 --- a/content/browser/devtools/protocol/input_handler.cc +++ b/content/browser/devtools/protocol/input_handler.cc
@@ -141,7 +141,7 @@ host_ = host; } -void InputHandler::SetClient(scoped_ptr<Client> client) { +void InputHandler::SetClient(std::unique_ptr<Client> client) { client_.swap(client); }
diff --git a/content/browser/devtools/protocol/input_handler.h b/content/browser/devtools/protocol/input_handler.h index 1bb7be9..6e548a5 100644 --- a/content/browser/devtools/protocol/input_handler.h +++ b/content/browser/devtools/protocol/input_handler.h
@@ -35,7 +35,7 @@ virtual ~InputHandler(); void SetRenderWidgetHost(RenderWidgetHostImpl* host); - void SetClient(scoped_ptr<Client> client); + void SetClient(std::unique_ptr<Client> client); void OnSwapCompositorFrame(const cc::CompositorFrameMetadata& frame_metadata); Response DispatchKeyEvent(const std::string& type, @@ -124,7 +124,7 @@ SyntheticGesture::Result result); RenderWidgetHostImpl* host_; - scoped_ptr<Client> client_; + std::unique_ptr<Client> client_; float page_scale_factor_; gfx::SizeF scrollable_viewport_size_; base::WeakPtrFactory<InputHandler> weak_factory_;
diff --git a/content/browser/devtools/protocol/inspector_handler.cc b/content/browser/devtools/protocol/inspector_handler.cc index 8e018a84..8777c6a 100644 --- a/content/browser/devtools/protocol/inspector_handler.cc +++ b/content/browser/devtools/protocol/inspector_handler.cc
@@ -19,7 +19,7 @@ InspectorHandler::~InspectorHandler() { } -void InspectorHandler::SetClient(scoped_ptr<Client> client) { +void InspectorHandler::SetClient(std::unique_ptr<Client> client) { client_.swap(client); }
diff --git a/content/browser/devtools/protocol/inspector_handler.h b/content/browser/devtools/protocol/inspector_handler.h index 52325c4..cee8949 100644 --- a/content/browser/devtools/protocol/inspector_handler.h +++ b/content/browser/devtools/protocol/inspector_handler.h
@@ -22,7 +22,7 @@ InspectorHandler(); virtual ~InspectorHandler(); - void SetClient(scoped_ptr<Client> client); + void SetClient(std::unique_ptr<Client> client); void SetRenderFrameHost(RenderFrameHostImpl* host); void TargetCrashed(); @@ -32,7 +32,7 @@ Response Disable(); private: - scoped_ptr<Client> client_; + std::unique_ptr<Client> client_; RenderFrameHostImpl* host_; DISALLOW_COPY_AND_ASSIGN(InspectorHandler);
diff --git a/content/browser/devtools/protocol/io_handler.cc b/content/browser/devtools/protocol/io_handler.cc index 59bef41..64dfd95 100644 --- a/content/browser/devtools/protocol/io_handler.cc +++ b/content/browser/devtools/protocol/io_handler.cc
@@ -28,7 +28,7 @@ IOHandler::~IOHandler() {} -void IOHandler::SetClient(scoped_ptr<Client> client) { +void IOHandler::SetClient(std::unique_ptr<Client> client) { client_.swap(client); }
diff --git a/content/browser/devtools/protocol/io_handler.h b/content/browser/devtools/protocol/io_handler.h index 951df50..e952bd06 100644 --- a/content/browser/devtools/protocol/io_handler.h +++ b/content/browser/devtools/protocol/io_handler.h
@@ -26,7 +26,7 @@ explicit IOHandler(DevToolsIOContext* io_context); ~IOHandler(); - void SetClient(scoped_ptr<Client> client); + void SetClient(std::unique_ptr<Client> client); // Protocol methods. Response Read(DevToolsCommandId command_id, const std::string& handle, @@ -37,7 +37,7 @@ void ReadComplete(DevToolsCommandId command_id, const scoped_refptr<base::RefCountedString>& data, int status); - scoped_ptr<Client> client_; + std::unique_ptr<Client> client_; DevToolsIOContext* io_context_; base::WeakPtrFactory<IOHandler> weak_factory_;
diff --git a/content/browser/devtools/protocol/network_handler.cc b/content/browser/devtools/protocol/network_handler.cc index 5163f19b..46e0704 100644 --- a/content/browser/devtools/protocol/network_handler.cc +++ b/content/browser/devtools/protocol/network_handler.cc
@@ -201,7 +201,7 @@ host_ = host; } -void NetworkHandler::SetClient(scoped_ptr<Client> client) { +void NetworkHandler::SetClient(std::unique_ptr<Client> client) { client_.swap(client); }
diff --git a/content/browser/devtools/protocol/network_handler.h b/content/browser/devtools/protocol/network_handler.h index 3b1456b..9e1c1fc 100644 --- a/content/browser/devtools/protocol/network_handler.h +++ b/content/browser/devtools/protocol/network_handler.h
@@ -25,7 +25,7 @@ virtual ~NetworkHandler(); void SetRenderFrameHost(RenderFrameHostImpl* host); - void SetClient(scoped_ptr<Client> client); + void SetClient(std::unique_ptr<Client> client); Response ClearBrowserCache(); Response ClearBrowserCookies(); @@ -50,7 +50,7 @@ void SendDeleteCookieResponse(DevToolsCommandId command_id); RenderFrameHostImpl* host_; - scoped_ptr<Client> client_; + std::unique_ptr<Client> client_; base::WeakPtrFactory<NetworkHandler> weak_factory_; DISALLOW_COPY_AND_ASSIGN(NetworkHandler);
diff --git a/content/browser/devtools/protocol/page_handler.cc b/content/browser/devtools/protocol/page_handler.cc index d4f6c397..2da5a3a 100644 --- a/content/browser/devtools/protocol/page_handler.cc +++ b/content/browser/devtools/protocol/page_handler.cc
@@ -136,7 +136,7 @@ } } -void PageHandler::SetClient(scoped_ptr<Client> client) { +void PageHandler::SetClient(std::unique_ptr<Client> client) { client_.swap(client); }
diff --git a/content/browser/devtools/protocol/page_handler.h b/content/browser/devtools/protocol/page_handler.h index 067d958..6dbca0a 100644 --- a/content/browser/devtools/protocol/page_handler.h +++ b/content/browser/devtools/protocol/page_handler.h
@@ -37,7 +37,7 @@ ~PageHandler() override; void SetRenderFrameHost(RenderFrameHostImpl* host); - void SetClient(scoped_ptr<Client> client); + void SetClient(std::unique_ptr<Client> client); void Detached(); void OnSwapCompositorFrame(const cc::CompositorFrameMetadata& frame_metadata); void OnSynchronousSwapCompositorFrame(const cc::CompositorFrameMetadata& @@ -118,10 +118,10 @@ int frame_counter_; int frames_in_flight_; - scoped_ptr<ColorPicker> color_picker_; + std::unique_ptr<ColorPicker> color_picker_; RenderFrameHostImpl* host_; - scoped_ptr<Client> client_; + std::unique_ptr<Client> client_; NotificationRegistrar registrar_; base::WeakPtrFactory<PageHandler> weak_factory_;
diff --git a/content/browser/devtools/protocol/security_handler.cc b/content/browser/devtools/protocol/security_handler.cc index 7784651..913602e 100644 --- a/content/browser/devtools/protocol/security_handler.cc +++ b/content/browser/devtools/protocol/security_handler.cc
@@ -63,7 +63,7 @@ SecurityHandler::~SecurityHandler() { } -void SecurityHandler::SetClient(scoped_ptr<Client> client) { +void SecurityHandler::SetClient(std::unique_ptr<Client> client) { client_.swap(client); }
diff --git a/content/browser/devtools/protocol/security_handler.h b/content/browser/devtools/protocol/security_handler.h index 3f9ce2b1..5f5fe68f 100644 --- a/content/browser/devtools/protocol/security_handler.h +++ b/content/browser/devtools/protocol/security_handler.h
@@ -22,7 +22,7 @@ SecurityHandler(); ~SecurityHandler() override; - void SetClient(scoped_ptr<Client> client); + void SetClient(std::unique_ptr<Client> client); void SetRenderFrameHost(RenderFrameHost* host); Response Enable(); @@ -36,7 +36,7 @@ SecurityStyle security_style, const SecurityStyleExplanations& security_style_explanations) override; - scoped_ptr<Client> client_; + std::unique_ptr<Client> client_; bool enabled_; RenderFrameHost* host_;
diff --git a/content/browser/devtools/protocol/service_worker_handler.cc b/content/browser/devtools/protocol/service_worker_handler.cc index b2f5c25..911df10 100644 --- a/content/browser/devtools/protocol/service_worker_handler.cc +++ b/content/browser/devtools/protocol/service_worker_handler.cc
@@ -262,7 +262,7 @@ partition->GetServiceWorkerContext()); } -void ServiceWorkerHandler::SetClient(scoped_ptr<Client> client) { +void ServiceWorkerHandler::SetClient(std::unique_ptr<Client> client) { client_.swap(client); }
diff --git a/content/browser/devtools/protocol/service_worker_handler.h b/content/browser/devtools/protocol/service_worker_handler.h index 02dcd8c4..5f44679 100644 --- a/content/browser/devtools/protocol/service_worker_handler.h +++ b/content/browser/devtools/protocol/service_worker_handler.h
@@ -42,7 +42,7 @@ ~ServiceWorkerHandler() override; void SetRenderFrameHost(RenderFrameHostImpl* render_frame_host); - void SetClient(scoped_ptr<Client> client); + void SetClient(std::unique_ptr<Client> client); void UpdateHosts(); void Detached(); @@ -92,7 +92,7 @@ void ClearForceUpdate(); scoped_refptr<ServiceWorkerContextWrapper> context_; - scoped_ptr<Client> client_; + std::unique_ptr<Client> client_; ServiceWorkerDevToolsAgentHost::Map attached_hosts_; bool enabled_; std::set<GURL> urls_;
diff --git a/content/browser/devtools/protocol/system_info_handler.cc b/content/browser/devtools/protocol/system_info_handler.cc index 5a9d53a..2c139c4 100644 --- a/content/browser/devtools/protocol/system_info_handler.cc +++ b/content/browser/devtools/protocol/system_info_handler.cc
@@ -5,10 +5,12 @@ #include "content/browser/devtools/protocol/system_info_handler.h" #include <stdint.h> + #include <utility> #include "base/bind.h" #include "base/command_line.h" +#include "base/memory/ptr_util.h" #include "content/browser/gpu/compositor_util.h" #include "content/public/browser/gpu_data_manager.h" #include "gpu/config/gpu_feature_type.h" @@ -145,7 +147,7 @@ SystemInfoHandler::~SystemInfoHandler() { } -void SystemInfoHandler::SetClient(scoped_ptr<Client> client) { +void SystemInfoHandler::SetClient(std::unique_ptr<Client> client) { client_.swap(client); } @@ -197,7 +199,8 @@ for (const auto& device : gpu_info.secondary_gpus) devices.push_back(GPUDeviceToProtocol(device)); - scoped_ptr<base::DictionaryValue> aux_attributes(new base::DictionaryValue); + std::unique_ptr<base::DictionaryValue> aux_attributes( + new base::DictionaryValue); AuxGPUInfoEnumerator enumerator(aux_attributes.get()); gpu_info.EnumerateFields(&enumerator); @@ -205,7 +208,7 @@ GPUInfo::Create() ->set_devices(devices) ->set_aux_attributes(std::move(aux_attributes)) - ->set_feature_status(make_scoped_ptr(GetFeatureStatus())) + ->set_feature_status(base::WrapUnique(GetFeatureStatus())) ->set_driver_bug_workarounds(GetDriverBugWorkarounds()); client_->SendGetInfoResponse(
diff --git a/content/browser/devtools/protocol/system_info_handler.h b/content/browser/devtools/protocol/system_info_handler.h index 40b14e8..281d08bb 100644 --- a/content/browser/devtools/protocol/system_info_handler.h +++ b/content/browser/devtools/protocol/system_info_handler.h
@@ -23,7 +23,7 @@ SystemInfoHandler(); ~SystemInfoHandler(); - void SetClient(scoped_ptr<Client> client); + void SetClient(std::unique_ptr<Client> client); Response GetInfo(DevToolsCommandId command_id); @@ -47,7 +47,7 @@ mutable base::Lock lock_; std::set<int> active_observers_; - scoped_ptr<Client> client_; + std::unique_ptr<Client> client_; base::WeakPtrFactory<SystemInfoHandler> weak_factory_; DISALLOW_COPY_AND_ASSIGN(SystemInfoHandler);
diff --git a/content/browser/devtools/protocol/tethering_handler.cc b/content/browser/devtools/protocol/tethering_handler.cc index 1718261..5d07f60a 100644 --- a/content/browser/devtools/protocol/tethering_handler.cc +++ b/content/browser/devtools/protocol/tethering_handler.cc
@@ -27,7 +27,7 @@ using Response = DevToolsProtocolClient::Response; using CreateServerSocketCallback = - base::Callback<scoped_ptr<net::ServerSocket>(std::string*)>; + base::Callback<std::unique_ptr<net::ServerSocket>(std::string*)>; class SocketPump { public: @@ -146,9 +146,9 @@ private: - scoped_ptr<net::StreamSocket> client_socket_; - scoped_ptr<net::ServerSocket> server_socket_; - scoped_ptr<net::StreamSocket> accepted_socket_; + std::unique_ptr<net::StreamSocket> client_socket_; + std::unique_ptr<net::ServerSocket> server_socket_; + std::unique_ptr<net::StreamSocket> accepted_socket_; int pending_writes_; bool pending_destruction_; }; @@ -217,8 +217,8 @@ AcceptedCallback accepted_callback_; CreateServerSocketCallback socket_callback_; - scoped_ptr<net::ServerSocket> socket_; - scoped_ptr<net::StreamSocket> accept_socket_; + std::unique_ptr<net::ServerSocket> socket_; + std::unique_ptr<net::StreamSocket> accept_socket_; uint16_t port_; }; @@ -268,7 +268,7 @@ BoundSocket::AcceptedCallback callback = base::Bind( &TetheringHandler::TetheringImpl::Accepted, base::Unretained(this)); - scoped_ptr<BoundSocket> bound_socket( + std::unique_ptr<BoundSocket> bound_socket( new BoundSocket(callback, socket_callback_)); if (!bound_socket->Listen(port)) { SendInternalError(command_id, "Could not bind port"); @@ -338,7 +338,7 @@ } } -void TetheringHandler::SetClient(scoped_ptr<Client> client) { +void TetheringHandler::SetClient(std::unique_ptr<Client> client) { client_.swap(client); }
diff --git a/content/browser/devtools/protocol/tethering_handler.h b/content/browser/devtools/protocol/tethering_handler.h index fc6b8e50..f45ac9c 100644 --- a/content/browser/devtools/protocol/tethering_handler.h +++ b/content/browser/devtools/protocol/tethering_handler.h
@@ -24,13 +24,13 @@ public: using Response = DevToolsProtocolClient::Response; using CreateServerSocketCallback = - base::Callback<scoped_ptr<net::ServerSocket>(std::string*)>; + base::Callback<std::unique_ptr<net::ServerSocket>(std::string*)>; TetheringHandler(const CreateServerSocketCallback& socket_callback, scoped_refptr<base::SingleThreadTaskRunner> task_runner); ~TetheringHandler(); - void SetClient(scoped_ptr<Client> client); + void SetClient(std::unique_ptr<Client> client); Response Bind(DevToolsCommandId command_id, int port); Response Unbind(DevToolsCommandId command_id, int port); @@ -46,7 +46,7 @@ void SendInternalError(DevToolsCommandId command_id, const std::string& message); - scoped_ptr<Client> client_; + std::unique_ptr<Client> client_; CreateServerSocketCallback socket_callback_; scoped_refptr<base::SingleThreadTaskRunner> task_runner_; bool is_active_;
diff --git a/content/browser/devtools/protocol/tracing_handler.cc b/content/browser/devtools/protocol/tracing_handler.cc index e7de4c75..59cbfc9 100644 --- a/content/browser/devtools/protocol/tracing_handler.cc +++ b/content/browser/devtools/protocol/tracing_handler.cc
@@ -48,10 +48,11 @@ return out_str; } -scoped_ptr<base::Value> ConvertDictKeyStyle(const base::Value& value) { +std::unique_ptr<base::Value> ConvertDictKeyStyle(const base::Value& value) { const base::DictionaryValue* dict = nullptr; if (value.GetAsDictionary(&dict)) { - scoped_ptr<base::DictionaryValue> out_dict(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> out_dict( + new base::DictionaryValue()); for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { out_dict->Set(ConvertFromCamelCase(it.key(), '_'), @@ -62,7 +63,7 @@ const base::ListValue* list = nullptr; if (value.GetAsList(&list)) { - scoped_ptr<base::ListValue> out_list(new base::ListValue()); + std::unique_ptr<base::ListValue> out_list(new base::ListValue()); for (const auto& value : *list) out_list->Append(ConvertDictKeyStyle(*value)); return std::move(out_list); @@ -141,7 +142,7 @@ TracingHandler::~TracingHandler() { } -void TracingHandler::SetClient(scoped_ptr<Client> client) { +void TracingHandler::SetClient(std::unique_ptr<Client> client) { client_.swap(client); } @@ -177,7 +178,7 @@ const std::string* options, const double* buffer_usage_reporting_interval, const std::string* transfer_mode, - const scoped_ptr<base::DictionaryValue>& config) { + const std::unique_ptr<base::DictionaryValue>& config) { if (IsTracing()) return Response::InternalError("Tracing is already started"); @@ -339,9 +340,9 @@ // static base::trace_event::TraceConfig TracingHandler::GetTraceConfigFromDevToolsConfig( const base::DictionaryValue& devtools_config) { - scoped_ptr<base::Value> value = ConvertDictKeyStyle(devtools_config); + std::unique_ptr<base::Value> value = ConvertDictKeyStyle(devtools_config); DCHECK(value && value->IsType(base::Value::TYPE_DICTIONARY)); - scoped_ptr<base::DictionaryValue> tracing_dict( + std::unique_ptr<base::DictionaryValue> tracing_dict( static_cast<base::DictionaryValue*>(value.release())); std::string mode;
diff --git a/content/browser/devtools/protocol/tracing_handler.h b/content/browser/devtools/protocol/tracing_handler.h index be3e6e4..019cd9c3 100644 --- a/content/browser/devtools/protocol/tracing_handler.h +++ b/content/browser/devtools/protocol/tracing_handler.h
@@ -41,7 +41,7 @@ DevToolsIOContext* io_context); virtual ~TracingHandler(); - void SetClient(scoped_ptr<Client> client); + void SetClient(std::unique_ptr<Client> client); void Detached(); void OnTraceDataCollected(const std::string& trace_fragment); @@ -54,7 +54,7 @@ const std::string* options, const double* buffer_usage_reporting_interval, const std::string* transfer_mode, - const scoped_ptr<base::DictionaryValue>& config); + const std::unique_ptr<base::DictionaryValue>& config); Response End(DevToolsCommandId command_id); Response GetCategories(DevToolsCommandId command); Response RequestMemoryDump(DevToolsCommandId command_id); @@ -80,10 +80,10 @@ GetTraceConfigFromDevToolsConfig( const base::DictionaryValue& devtools_config); - scoped_ptr<base::Timer> buffer_usage_poll_timer_; + std::unique_ptr<base::Timer> buffer_usage_poll_timer_; Target target_; - scoped_ptr<Client> client_; + std::unique_ptr<Client> client_; DevToolsIOContext* io_context_; int frame_tree_node_id_; bool did_initiate_recording_;
diff --git a/content/browser/devtools/protocol/tracing_handler_unittest.cc b/content/browser/devtools/protocol/tracing_handler_unittest.cc index 8182f45..85b01d8 100644 --- a/content/browser/devtools/protocol/tracing_handler_unittest.cc +++ b/content/browser/devtools/protocol/tracing_handler_unittest.cc
@@ -57,9 +57,9 @@ } TEST(TracingHandlerTest, GetTraceConfigFromDevToolsConfig) { - scoped_ptr<base::Value> value = base::JSONReader::Read( - kCustomTraceConfigStringDevToolsStyle); - scoped_ptr<base::DictionaryValue> devtools_style_dict( + std::unique_ptr<base::Value> value = + base::JSONReader::Read(kCustomTraceConfigStringDevToolsStyle); + std::unique_ptr<base::DictionaryValue> devtools_style_dict( static_cast<base::DictionaryValue*>(value.release())); base::trace_event::TraceConfig trace_config =
diff --git a/content/browser/devtools/render_frame_devtools_agent_host.h b/content/browser/devtools/render_frame_devtools_agent_host.h index 24d05358..beedd88 100644 --- a/content/browser/devtools/render_frame_devtools_agent_host.h +++ b/content/browser/devtools/render_frame_devtools_agent_host.h
@@ -6,10 +6,10 @@ #define CONTENT_BROWSER_DEVTOOLS_RENDER_FRAME_DEVTOOLS_AGENT_HOST_H_ #include <map> +#include <memory> #include "base/compiler_specific.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "build/build_config.h" #include "content/browser/devtools/devtools_agent_host_impl.h" #include "content/common/content_export.h" @@ -142,28 +142,28 @@ class FrameHostHolder; - scoped_ptr<FrameHostHolder> current_; - scoped_ptr<FrameHostHolder> pending_; + std::unique_ptr<FrameHostHolder> current_; + std::unique_ptr<FrameHostHolder> pending_; // Stores per-host state between DisconnectWebContents and ConnectWebContents. - scoped_ptr<FrameHostHolder> disconnected_; + std::unique_ptr<FrameHostHolder> disconnected_; - scoped_ptr<devtools::dom::DOMHandler> dom_handler_; - scoped_ptr<devtools::input::InputHandler> input_handler_; - scoped_ptr<devtools::inspector::InspectorHandler> inspector_handler_; - scoped_ptr<devtools::io::IOHandler> io_handler_; - scoped_ptr<devtools::network::NetworkHandler> network_handler_; - scoped_ptr<devtools::page::PageHandler> page_handler_; - scoped_ptr<devtools::security::SecurityHandler> security_handler_; - scoped_ptr<devtools::service_worker::ServiceWorkerHandler> + std::unique_ptr<devtools::dom::DOMHandler> dom_handler_; + std::unique_ptr<devtools::input::InputHandler> input_handler_; + std::unique_ptr<devtools::inspector::InspectorHandler> inspector_handler_; + std::unique_ptr<devtools::io::IOHandler> io_handler_; + std::unique_ptr<devtools::network::NetworkHandler> network_handler_; + std::unique_ptr<devtools::page::PageHandler> page_handler_; + std::unique_ptr<devtools::security::SecurityHandler> security_handler_; + std::unique_ptr<devtools::service_worker::ServiceWorkerHandler> service_worker_handler_; - scoped_ptr<devtools::tracing::TracingHandler> tracing_handler_; - scoped_ptr<devtools::emulation::EmulationHandler> emulation_handler_; - scoped_ptr<DevToolsFrameTraceRecorder> frame_trace_recorder_; + std::unique_ptr<devtools::tracing::TracingHandler> tracing_handler_; + std::unique_ptr<devtools::emulation::EmulationHandler> emulation_handler_; + std::unique_ptr<DevToolsFrameTraceRecorder> frame_trace_recorder_; #if defined(OS_ANDROID) - scoped_ptr<PowerSaveBlockerImpl> power_save_blocker_; + std::unique_ptr<PowerSaveBlockerImpl> power_save_blocker_; #endif - scoped_ptr<DevToolsProtocolHandler> protocol_handler_; + std::unique_ptr<DevToolsProtocolHandler> protocol_handler_; bool current_frame_crashed_; // PlzNavigate
diff --git a/content/browser/devtools/service_worker_devtools_agent_host.h b/content/browser/devtools/service_worker_devtools_agent_host.h index a5f15ee..a758a04 100644 --- a/content/browser/devtools/service_worker_devtools_agent_host.h +++ b/content/browser/devtools/service_worker_devtools_agent_host.h
@@ -46,8 +46,8 @@ private: ~ServiceWorkerDevToolsAgentHost() override; - scoped_ptr<ServiceWorkerIdentifier> service_worker_; - scoped_ptr<devtools::network::NetworkHandler> network_handler_; + std::unique_ptr<ServiceWorkerIdentifier> service_worker_; + std::unique_ptr<devtools::network::NetworkHandler> network_handler_; DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDevToolsAgentHost); };
diff --git a/content/browser/devtools/shared_worker_devtools_agent_host.h b/content/browser/devtools/shared_worker_devtools_agent_host.h index 5ac6d6b..742f0c7 100644 --- a/content/browser/devtools/shared_worker_devtools_agent_host.h +++ b/content/browser/devtools/shared_worker_devtools_agent_host.h
@@ -32,7 +32,7 @@ friend class SharedWorkerDevToolsManagerTest; ~SharedWorkerDevToolsAgentHost() override; - scoped_ptr<SharedWorkerInstance> shared_worker_; + std::unique_ptr<SharedWorkerInstance> shared_worker_; DISALLOW_COPY_AND_ASSIGN(SharedWorkerDevToolsAgentHost); };
diff --git a/content/browser/devtools/shared_worker_devtools_manager_unittest.cc b/content/browser/devtools/shared_worker_devtools_manager_unittest.cc index c6f86d5..9ea09268 100644 --- a/content/browser/devtools/shared_worker_devtools_manager_unittest.cc +++ b/content/browser/devtools/shared_worker_devtools_manager_unittest.cc
@@ -6,8 +6,9 @@ #include <stddef.h> +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" #include "base/run_loop.h" #include "content/browser/browser_thread_impl.h" @@ -91,8 +92,8 @@ base::MessageLoopForIO message_loop_; BrowserThreadImpl ui_thread_; - scoped_ptr<TestBrowserContext> browser_context_; - scoped_ptr<WorkerStoragePartition> partition_; + std::unique_ptr<TestBrowserContext> browser_context_; + std::unique_ptr<WorkerStoragePartition> partition_; const WorkerStoragePartitionId partition_id_; SharedWorkerDevToolsManager* manager_; }; @@ -194,7 +195,8 @@ blink::WebSharedWorkerCreationContextTypeNonsecure); // Created -> GetDevToolsAgentHost -> Register -> Started -> Destroyed - scoped_ptr<TestDevToolsClientHost> client_host1(new TestDevToolsClientHost()); + std::unique_ptr<TestDevToolsClientHost> client_host1( + new TestDevToolsClientHost()); CheckWorkerNotExist(2, 1); manager_->WorkerCreated(2, 1, instance1); CheckWorkerState(2, 1, WorkerState::WORKER_UNINSPECTED); @@ -211,7 +213,8 @@ EXPECT_EQ(agent_host1.get(), manager_->GetDevToolsAgentHostForWorker(2, 1)); // Created -> Started -> GetDevToolsAgentHost -> Register -> Destroyed - scoped_ptr<TestDevToolsClientHost> client_host2(new TestDevToolsClientHost()); + std::unique_ptr<TestDevToolsClientHost> client_host2( + new TestDevToolsClientHost()); manager_->WorkerCreated(2, 2, instance2); CheckWorkerState(2, 2, WorkerState::WORKER_UNINSPECTED); manager_->WorkerReadyForInspection(2, 2); @@ -270,7 +273,8 @@ blink::WebContentSecurityPolicyTypeReport, blink::WebAddressSpacePublic, browser_context_->GetResourceContext(), partition_id_, blink::WebSharedWorkerCreationContextTypeNonsecure); - scoped_ptr<TestDevToolsClientHost> client_host(new TestDevToolsClientHost()); + std::unique_ptr<TestDevToolsClientHost> client_host( + new TestDevToolsClientHost()); // Created -> GetDevToolsAgentHost -> Register -> Destroyed manager_->WorkerCreated(3, 1, instance); CheckWorkerState(3, 1, WorkerState::WORKER_UNINSPECTED);
diff --git a/content/browser/devtools/worker_devtools_agent_host.h b/content/browser/devtools/worker_devtools_agent_host.h index 4f21257a..0f0f543 100644 --- a/content/browser/devtools/worker_devtools_agent_host.h +++ b/content/browser/devtools/worker_devtools_agent_host.h
@@ -65,7 +65,7 @@ void WorkerCreated(); void OnDispatchOnInspectorFrontend(const DevToolsMessageChunk& message); - scoped_ptr<DevToolsProtocolHandler> protocol_handler_; + std::unique_ptr<DevToolsProtocolHandler> protocol_handler_; DevToolsMessageChunkProcessor chunk_processor_; WorkerState state_; WorkerId worker_id_;
diff --git a/content/browser/dom_storage/dom_storage_area.h b/content/browser/dom_storage/dom_storage_area.h index 50082fde..4e91b60 100644 --- a/content/browser/dom_storage/dom_storage_area.h +++ b/content/browser/dom_storage/dom_storage_area.h
@@ -8,13 +8,13 @@ #include <stddef.h> #include <stdint.h> +#include <memory> #include <string> #include "base/files/file_path.h" #include "base/gtest_prod_util.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/strings/nullable_string16.h" #include "base/strings/string16.h" #include "content/common/content_export.h" @@ -171,11 +171,11 @@ base::FilePath directory_; scoped_refptr<DOMStorageTaskRunner> task_runner_; scoped_refptr<DOMStorageMap> map_; - scoped_ptr<DOMStorageDatabaseAdapter> backing_; + std::unique_ptr<DOMStorageDatabaseAdapter> backing_; scoped_refptr<SessionStorageDatabase> session_storage_backing_; bool is_initial_import_done_; bool is_shutdown_; - scoped_ptr<CommitBatch> commit_batch_; + std::unique_ptr<CommitBatch> commit_batch_; int commit_batches_in_flight_; base::TimeTicks start_time_; RateLimiter data_rate_limiter_;
diff --git a/content/browser/dom_storage/dom_storage_context_wrapper.cc b/content/browser/dom_storage/dom_storage_context_wrapper.cc index b0ec4d5a..bde121a 100644 --- a/content/browser/dom_storage/dom_storage_context_wrapper.cc +++ b/content/browser/dom_storage/dom_storage_context_wrapper.cc
@@ -11,6 +11,7 @@ #include "base/bind_helpers.h" #include "base/files/file_path.h" #include "base/location.h" +#include "base/memory/ptr_util.h" #include "base/memory/weak_ptr.h" #include "base/single_thread_task_runner.h" #include "base/strings/utf_string_conversions.h" @@ -104,7 +105,7 @@ mojom::LevelDBWrapperRequest request); // Maps between an origin and its prefixed LevelDB view. - std::map<url::Origin, scoped_ptr<LevelDBWrapperImpl>> level_db_wrappers_; + std::map<url::Origin, std::unique_ptr<LevelDBWrapperImpl>> level_db_wrappers_; std::string mojo_user_id_; base::FilePath subdirectory_; @@ -115,7 +116,7 @@ CONNECTION_FINISHED } connection_state_; - scoped_ptr<MojoAppConnection> profile_app_connection_; + std::unique_ptr<MojoAppConnection> profile_app_connection_; profile::ProfileServicePtr profile_service_; filesystem::DirectoryPtr directory_; @@ -215,13 +216,11 @@ mojom::LevelDBWrapperRequest request) { auto found = level_db_wrappers_.find(origin); if (found == level_db_wrappers_.end()) { - level_db_wrappers_[origin] = make_scoped_ptr(new LevelDBWrapperImpl( - database_.get(), - origin.Serialize(), + level_db_wrappers_[origin] = base::WrapUnique(new LevelDBWrapperImpl( + database_.get(), origin.Serialize(), kPerStorageAreaQuota + kPerStorageAreaOverQuotaAllowance, base::Bind(&MojoState::OnLevelDDWrapperHasNoBindings, - base::Unretained(this), - origin))); + base::Unretained(this), origin))); found = level_db_wrappers_.find(origin); }
diff --git a/content/browser/dom_storage/dom_storage_context_wrapper.h b/content/browser/dom_storage/dom_storage_context_wrapper.h index 56196a1..30bd48d 100644 --- a/content/browser/dom_storage/dom_storage_context_wrapper.h +++ b/content/browser/dom_storage/dom_storage_context_wrapper.h
@@ -80,7 +80,7 @@ // An inner class to keep all mojo-ish details together and not bleed them // through the public interface. class MojoState; - scoped_ptr<MojoState> mojo_state_; + std::unique_ptr<MojoState> mojo_state_; scoped_refptr<DOMStorageContextImpl> context_;
diff --git a/content/browser/dom_storage/dom_storage_database.h b/content/browser/dom_storage/dom_storage_database.h index 72f5d73..7541637 100644 --- a/content/browser/dom_storage/dom_storage_database.h +++ b/content/browser/dom_storage/dom_storage_database.h
@@ -6,10 +6,10 @@ #define CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_DATABASE_H_ #include <map> +#include <memory> #include "base/files/file_path.h" #include "base/gtest_prod_util.h" -#include "base/memory/scoped_ptr.h" #include "base/strings/nullable_string16.h" #include "base/strings/string16.h" #include "content/common/content_export.h" @@ -108,7 +108,7 @@ // Path to the database on disk. const base::FilePath file_path_; - scoped_ptr<sql::Connection> db_; + std::unique_ptr<sql::Connection> db_; bool failed_to_open_; bool tried_to_recreate_; bool known_to_be_empty_;
diff --git a/content/browser/dom_storage/dom_storage_message_filter.h b/content/browser/dom_storage/dom_storage_message_filter.h index 791ddf16..a4894e9 100644 --- a/content/browser/dom_storage/dom_storage_message_filter.h +++ b/content/browser/dom_storage/dom_storage_message_filter.h
@@ -7,9 +7,10 @@ #include <stdint.h> +#include <memory> + #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/dom_storage/dom_storage_context_impl.h" #include "content/common/dom_storage/dom_storage_types.h" #include "content/public/browser/browser_message_filter.h" @@ -83,7 +84,7 @@ const base::NullableString16& old_value); scoped_refptr<DOMStorageContextImpl> context_; - scoped_ptr<DOMStorageHost> host_; + std::unique_ptr<DOMStorageHost> host_; int connection_dispatching_message_for_; DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageMessageFilter);
diff --git a/content/browser/dom_storage/local_storage_database_adapter.h b/content/browser/dom_storage/local_storage_database_adapter.h index a8db4a3..77dad2d 100644 --- a/content/browser/dom_storage/local_storage_database_adapter.h +++ b/content/browser/dom_storage/local_storage_database_adapter.h
@@ -5,9 +5,10 @@ #ifndef CONTENT_BROWSER_DOM_STORAGE_LOCAL_STORAGE_DATABASE_ADAPTER_H_ #define CONTENT_BROWSER_DOM_STORAGE_LOCAL_STORAGE_DATABASE_ADAPTER_H_ +#include <memory> + #include "base/gtest_prod_util.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/dom_storage/dom_storage_database_adapter.h" #include "content/common/content_export.h" @@ -41,7 +42,7 @@ FRIEND_TEST_ALL_PREFIXES(DOMStorageAreaTest, DeleteOrigin); FRIEND_TEST_ALL_PREFIXES(DOMStorageAreaTest, PurgeMemory); - scoped_ptr<DOMStorageDatabase> db_; + std::unique_ptr<DOMStorageDatabase> db_; DISALLOW_COPY_AND_ASSIGN(LocalStorageDatabaseAdapter); };
diff --git a/content/browser/dom_storage/session_storage_database.cc b/content/browser/dom_storage/session_storage_database.cc index 0aea7c7..ae90b0f 100644 --- a/content/browser/dom_storage/session_storage_database.cc +++ b/content/browser/dom_storage/session_storage_database.cc
@@ -276,7 +276,7 @@ options.snapshot = db_->GetSnapshot(); std::string namespace_prefix = NamespacePrefix(); - scoped_ptr<leveldb::Iterator> it(db_->NewIterator(options)); + std::unique_ptr<leveldb::Iterator> it(db_->NewIterator(options)); it->Seek(namespace_prefix); // If the key is not found, the status of the iterator won't be IsNotFound(), // but the iterator will be invalid. @@ -447,7 +447,8 @@ const std::string& namespace_id, std::map<std::string, std::string>* areas) { std::string namespace_start_key = NamespaceStartKey(namespace_id); - scoped_ptr<leveldb::Iterator> it(db_->NewIterator(leveldb::ReadOptions())); + std::unique_ptr<leveldb::Iterator> it( + db_->NewIterator(leveldb::ReadOptions())); it->Seek(namespace_start_key); // If the key is not found, the status of the iterator won't be IsNotFound(), // but the iterator will be invalid. @@ -500,7 +501,8 @@ // If this was the only area in the namespace, delete the namespace start key, // too. std::string namespace_start_key = NamespaceStartKey(namespace_id); - scoped_ptr<leveldb::Iterator> it(db_->NewIterator(leveldb::ReadOptions())); + std::unique_ptr<leveldb::Iterator> it( + db_->NewIterator(leveldb::ReadOptions())); it->Seek(namespace_start_key); if (!ConsistencyCheck(it->Valid())) return false; @@ -559,7 +561,7 @@ const leveldb::ReadOptions& options, DOMStorageValuesMap* result, bool only_keys) { - scoped_ptr<leveldb::Iterator> it(db_->NewIterator(options)); + std::unique_ptr<leveldb::Iterator> it(db_->NewIterator(options)); std::string map_start_key = MapRefCountKey(map_id); it->Seek(map_start_key); // If the key is not found, the status of the iterator won't be IsNotFound(),
diff --git a/content/browser/dom_storage/session_storage_database.h b/content/browser/dom_storage/session_storage_database.h index d4e80e43..7ca2da7 100644 --- a/content/browser/dom_storage/session_storage_database.h +++ b/content/browser/dom_storage/session_storage_database.h
@@ -8,12 +8,12 @@ #include <stdint.h> #include <map> +#include <memory> #include <string> #include "base/files/file_path.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/synchronization/lock.h" #include "content/common/content_export.h" #include "content/common/dom_storage/dom_storage_types.h" @@ -191,7 +191,7 @@ static std::string MapKey(const std::string& map_id, const std::string& key); static const char* NextMapIdKey(); - scoped_ptr<leveldb::DB> db_; + std::unique_ptr<leveldb::DB> db_; base::FilePath file_path_; // For protecting the database opening code. Also guards the variables below.
diff --git a/content/browser/dom_storage/session_storage_database_unittest.cc b/content/browser/dom_storage/session_storage_database_unittest.cc index 8ca4b08..9440e0d 100644 --- a/content/browser/dom_storage/session_storage_database_unittest.cc +++ b/content/browser/dom_storage/session_storage_database_unittest.cc
@@ -184,7 +184,7 @@ void SessionStorageDatabaseTest::ReadData(DataMap* data) const { leveldb::DB* leveldb = db_->db_.get(); - scoped_ptr<leveldb::Iterator> it( + std::unique_ptr<leveldb::Iterator> it( leveldb->NewIterator(leveldb::ReadOptions())); for (it->SeekToFirst(); it->Valid(); it->Next()) { (*data)[it->key().ToString()] = it->value().ToString(); @@ -298,7 +298,7 @@ void SessionStorageDatabaseTest::DumpData() const { LOG(WARNING) << "---- Session storage contents"; - scoped_ptr<leveldb::Iterator> it( + std::unique_ptr<leveldb::Iterator> it( db_->db_->NewIterator(leveldb::ReadOptions())); for (it->SeekToFirst(); it->Valid(); it->Next()) { int64_t dummy_map_id;
diff --git a/content/browser/file_descriptor_info_impl.cc b/content/browser/file_descriptor_info_impl.cc index f071b42..1f33da2 100644 --- a/content/browser/file_descriptor_info_impl.cc +++ b/content/browser/file_descriptor_info_impl.cc
@@ -11,8 +11,8 @@ namespace content { // static -scoped_ptr<FileDescriptorInfo> FileDescriptorInfoImpl::Create() { - return scoped_ptr<FileDescriptorInfo>(new FileDescriptorInfoImpl()); +std::unique_ptr<FileDescriptorInfo> FileDescriptorInfoImpl::Create() { + return std::unique_ptr<FileDescriptorInfo>(new FileDescriptorInfoImpl()); } FileDescriptorInfoImpl::FileDescriptorInfoImpl() {
diff --git a/content/browser/file_descriptor_info_impl.h b/content/browser/file_descriptor_info_impl.h index 2195eb9..010e797 100644 --- a/content/browser/file_descriptor_info_impl.h +++ b/content/browser/file_descriptor_info_impl.h
@@ -7,9 +7,9 @@ #include <stddef.h> +#include <memory> #include <vector> -#include "base/memory/scoped_ptr.h" #include "content/common/content_export.h" #include "content/public/browser/file_descriptor_info.h" @@ -17,7 +17,7 @@ class FileDescriptorInfoImpl : public FileDescriptorInfo { public: - CONTENT_EXPORT static scoped_ptr<FileDescriptorInfo> Create(); + CONTENT_EXPORT static std::unique_ptr<FileDescriptorInfo> Create(); ~FileDescriptorInfoImpl() override; void Share(int id, base::PlatformFile fd) override;
diff --git a/content/browser/file_descriptor_info_impl_unittest.cc b/content/browser/file_descriptor_info_impl_unittest.cc index c92200f..e14dc312 100644 --- a/content/browser/file_descriptor_info_impl_unittest.cc +++ b/content/browser/file_descriptor_info_impl_unittest.cc
@@ -39,7 +39,7 @@ TEST_F(FileDescriptorInfoTest, Transfer) { int testingId = 42; - scoped_ptr<FileDescriptorInfo> target(FileDescriptorInfoImpl::Create()); + std::unique_ptr<FileDescriptorInfo> target(FileDescriptorInfoImpl::Create()); base::ScopedFD fd(GetSafeFd()); int raw_fd = fd.get(); @@ -55,7 +55,7 @@ TEST_F(FileDescriptorInfoTest, Share) { int testingId = 42; - scoped_ptr<FileDescriptorInfo> target(FileDescriptorInfoImpl::Create()); + std::unique_ptr<FileDescriptorInfo> target(FileDescriptorInfoImpl::Create()); base::ScopedFD fd(GetSafeFd()); int raw_fd = fd.get(); @@ -72,7 +72,7 @@ TEST_F(FileDescriptorInfoTest, GetMappingWithIDAdjustment) { int testingId1 = 42; int testingId2 = 43; - scoped_ptr<FileDescriptorInfo> target(FileDescriptorInfoImpl::Create()); + std::unique_ptr<FileDescriptorInfo> target(FileDescriptorInfoImpl::Create()); target->Transfer(testingId1, base::ScopedFD(GetSafeFd())); target->Transfer(testingId2, base::ScopedFD(GetSafeFd()));
diff --git a/content/browser/font_list_async.cc b/content/browser/font_list_async.cc index 730f673..70834861 100644 --- a/content/browser/font_list_async.cc +++ b/content/browser/font_list_async.cc
@@ -17,15 +17,15 @@ // Just executes the given callback with the parameter. void ReturnFontListToOriginalThread( - const base::Callback<void(scoped_ptr<base::ListValue>)>& callback, - scoped_ptr<base::ListValue> result) { + const base::Callback<void(std::unique_ptr<base::ListValue>)>& callback, + std::unique_ptr<base::ListValue> result) { callback.Run(std::move(result)); } void GetFontListInBlockingPool( BrowserThread::ID calling_thread_id, - const base::Callback<void(scoped_ptr<base::ListValue>)>& callback) { - scoped_ptr<base::ListValue> result(GetFontList_SlowBlocking()); + const base::Callback<void(std::unique_ptr<base::ListValue>)>& callback) { + std::unique_ptr<base::ListValue> result(GetFontList_SlowBlocking()); BrowserThread::PostTask(calling_thread_id, FROM_HERE, base::Bind(&ReturnFontListToOriginalThread, callback, base::Passed(&result))); @@ -34,7 +34,7 @@ } // namespace void GetFontListAsync( - const base::Callback<void(scoped_ptr<base::ListValue>)>& callback) { + const base::Callback<void(std::unique_ptr<base::ListValue>)>& callback) { BrowserThread::ID id; bool well_known_thread = BrowserThread::GetCurrentThreadIdentifier(&id); DCHECK(well_known_thread)
diff --git a/content/browser/gamepad/gamepad_platform_data_fetcher_linux.h b/content/browser/gamepad/gamepad_platform_data_fetcher_linux.h index 763f1911..a260760d 100644 --- a/content/browser/gamepad/gamepad_platform_data_fetcher_linux.h +++ b/content/browser/gamepad/gamepad_platform_data_fetcher_linux.h
@@ -7,11 +7,11 @@ #include <stddef.h> +#include <memory> #include <string> #include "base/compiler_specific.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/gamepad/gamepad_data_fetcher.h" extern "C" { @@ -41,7 +41,7 @@ // File descriptor for the /dev/input/js* devices. -1 if not in use. int device_fd_[blink::WebGamepads::itemsLengthCap]; - scoped_ptr<device::UdevLinux> udev_; + std::unique_ptr<device::UdevLinux> udev_; DISALLOW_COPY_AND_ASSIGN(GamepadPlatformDataFetcherLinux); };
diff --git a/content/browser/gamepad/gamepad_platform_data_fetcher_mac.h b/content/browser/gamepad/gamepad_platform_data_fetcher_mac.h index ebfe57e..d373fee3 100644 --- a/content/browser/gamepad/gamepad_platform_data_fetcher_mac.h +++ b/content/browser/gamepad/gamepad_platform_data_fetcher_mac.h
@@ -5,20 +5,20 @@ #ifndef CONTENT_BROWSER_GAMEPAD_GAMEPAD_PLATFORM_DATA_FETCHER_MAC_H_ #define CONTENT_BROWSER_GAMEPAD_GAMEPAD_PLATFORM_DATA_FETCHER_MAC_H_ +#include <CoreFoundation/CoreFoundation.h> +#include <IOKit/hid/IOHIDManager.h> #include <stddef.h> +#include <memory> + #include "base/compiler_specific.h" #include "base/mac/scoped_cftyperef.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "build/build_config.h" #include "content/browser/gamepad/gamepad_data_fetcher.h" #include "content/browser/gamepad/xbox_data_fetcher_mac.h" #include "content/common/gamepad_hardware_buffer.h" -#include <CoreFoundation/CoreFoundation.h> -#include <IOKit/hid/IOHIDManager.h> - #if defined(__OBJC__) @class NSArray; #else @@ -74,7 +74,7 @@ void SanitizeGamepadData(size_t index, blink::WebGamepad* pad); - scoped_ptr<XboxDataFetcher> xbox_fetcher_; + std::unique_ptr<XboxDataFetcher> xbox_fetcher_; // Side-band data that's not passed to the consumer, but we need to maintain // to update data_.
diff --git a/content/browser/gamepad/gamepad_platform_data_fetcher_win.h b/content/browser/gamepad/gamepad_platform_data_fetcher_win.h index 53356698..4fbd1cf0 100644 --- a/content/browser/gamepad/gamepad_platform_data_fetcher_win.h +++ b/content/browser/gamepad/gamepad_platform_data_fetcher_win.h
@@ -5,6 +5,8 @@ #ifndef CONTENT_BROWSER_GAMEPAD_GAMEPAD_PLATFORM_DATA_FETCHER_WIN_H_ #define CONTENT_BROWSER_GAMEPAD_GAMEPAD_PLATFORM_DATA_FETCHER_WIN_H_ +#include <memory> + #include "build/build_config.h" #ifndef WIN32_LEAN_AND_MEAN @@ -18,7 +20,6 @@ #include "base/compiler_specific.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/message_loop/message_loop.h" #include "base/scoped_native_library.h" @@ -86,7 +87,7 @@ }; PlatformPadState platform_pad_state_[blink::WebGamepads::itemsLengthCap]; - scoped_ptr<RawInputDataFetcher> raw_input_fetcher_; + std::unique_ptr<RawInputDataFetcher> raw_input_fetcher_; DISALLOW_COPY_AND_ASSIGN(GamepadPlatformDataFetcherWin); };
diff --git a/content/browser/gamepad/gamepad_provider.cc b/content/browser/gamepad/gamepad_provider.cc index fea94e0..e006ca2 100644 --- a/content/browser/gamepad/gamepad_provider.cc +++ b/content/browser/gamepad/gamepad_provider.cc
@@ -50,10 +50,10 @@ have_scheduled_do_poll_(false), devices_changed_(true), ever_had_user_gesture_(false) { - Initialize(scoped_ptr<GamepadDataFetcher>()); + Initialize(std::unique_ptr<GamepadDataFetcher>()); } -GamepadProvider::GamepadProvider(scoped_ptr<GamepadDataFetcher> fetcher) +GamepadProvider::GamepadProvider(std::unique_ptr<GamepadDataFetcher> fetcher) : is_paused_(true), have_scheduled_do_poll_(false), devices_changed_(true), @@ -124,7 +124,7 @@ devices_changed_ = true; } -void GamepadProvider::Initialize(scoped_ptr<GamepadDataFetcher> fetcher) { +void GamepadProvider::Initialize(std::unique_ptr<GamepadDataFetcher> fetcher) { size_t data_size = sizeof(GamepadHardwareBuffer); base::SystemMonitor* monitor = base::SystemMonitor::Get(); if (monitor) @@ -158,7 +158,7 @@ } void GamepadProvider::DoInitializePollingThread( - scoped_ptr<GamepadDataFetcher> fetcher) { + std::unique_ptr<GamepadDataFetcher> fetcher) { DCHECK(base::MessageLoop::current() == polling_thread_->message_loop()); DCHECK(!data_fetcher_.get()); // Should only initialize once.
diff --git a/content/browser/gamepad/gamepad_provider.h b/content/browser/gamepad/gamepad_provider.h index fa15411..91613898 100644 --- a/content/browser/gamepad/gamepad_provider.h +++ b/content/browser/gamepad/gamepad_provider.h
@@ -5,13 +5,13 @@ #ifndef CONTENT_BROWSER_GAMEPAD_GAMEPAD_PROVIDER_H_ #define CONTENT_BROWSER_GAMEPAD_GAMEPAD_PROVIDER_H_ +#include <memory> #include <utility> #include <vector> #include "base/callback_forward.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/shared_memory.h" #include "base/memory/weak_ptr.h" #include "base/synchronization/lock.h" @@ -35,7 +35,7 @@ GamepadProvider(); // Manually specifies the data fetcher. Used for testing. - explicit GamepadProvider(scoped_ptr<GamepadDataFetcher> fetcher); + explicit GamepadProvider(std::unique_ptr<GamepadDataFetcher> fetcher); ~GamepadProvider() override; @@ -59,11 +59,11 @@ void OnDevicesChanged(base::SystemMonitor::DeviceType type) override; private: - void Initialize(scoped_ptr<GamepadDataFetcher> fetcher); + void Initialize(std::unique_ptr<GamepadDataFetcher> fetcher); // Method for setting up the platform-specific data fetcher. Takes ownership // of |fetcher|. - void DoInitializePollingThread(scoped_ptr<GamepadDataFetcher> fetcher); + void DoInitializePollingThread(std::unique_ptr<GamepadDataFetcher> fetcher); // Method for sending pause hints to the low-level data fetcher. Runs on // polling_thread_. @@ -147,16 +147,16 @@ }; // Used to detect connections and disconnections. - scoped_ptr<PadState[]> pad_states_; + std::unique_ptr<PadState[]> pad_states_; // Only used on the polling thread. - scoped_ptr<GamepadDataFetcher> data_fetcher_; + std::unique_ptr<GamepadDataFetcher> data_fetcher_; base::Lock shared_memory_lock_; base::SharedMemory gamepad_shared_memory_; // Polling is done on this background thread. - scoped_ptr<base::Thread> polling_thread_; + std::unique_ptr<base::Thread> polling_thread_; static GamepadProvider* instance_;
diff --git a/content/browser/gamepad/gamepad_provider_unittest.cc b/content/browser/gamepad/gamepad_provider_unittest.cc index 7e3a29c..e9675d6 100644 --- a/content/browser/gamepad/gamepad_provider_unittest.cc +++ b/content/browser/gamepad/gamepad_provider_unittest.cc
@@ -2,12 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/browser/gamepad/gamepad_provider.h" + +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "build/build_config.h" #include "content/browser/gamepad/gamepad_data_fetcher.h" -#include "content/browser/gamepad/gamepad_provider.h" #include "content/browser/gamepad/gamepad_test_helpers.h" #include "content/common/gamepad_hardware_buffer.h" #include "content/common/gamepad_messages.h" @@ -49,7 +51,7 @@ GamepadProvider* CreateProvider(const WebGamepads& test_data) { mock_data_fetcher_ = new MockGamepadDataFetcher(test_data); provider_.reset(new GamepadProvider( - scoped_ptr<GamepadDataFetcher>(mock_data_fetcher_))); + std::unique_ptr<GamepadDataFetcher>(mock_data_fetcher_))); return provider_.get(); } @@ -57,7 +59,7 @@ GamepadProviderTest() { } - scoped_ptr<GamepadProvider> provider_; + std::unique_ptr<GamepadProvider> provider_; // Pointer owned by the provider. MockGamepadDataFetcher* mock_data_fetcher_; @@ -94,7 +96,7 @@ // Renderer-side, pull data out of poll buffer. base::SharedMemoryHandle handle = provider->GetSharedMemoryHandleForProcess( base::GetCurrentProcessHandle()); - scoped_ptr<base::SharedMemory> shared_memory( + std::unique_ptr<base::SharedMemory> shared_memory( new base::SharedMemory(handle, true)); EXPECT_TRUE(shared_memory->Map(sizeof(GamepadHardwareBuffer))); void* mem = shared_memory->memory();
diff --git a/content/browser/gamepad/gamepad_service.cc b/content/browser/gamepad/gamepad_service.cc index 411ae0118..ef56d31 100644 --- a/content/browser/gamepad/gamepad_service.cc +++ b/content/browser/gamepad/gamepad_service.cc
@@ -27,7 +27,7 @@ SetInstance(this); } -GamepadService::GamepadService(scoped_ptr<GamepadDataFetcher> fetcher) +GamepadService::GamepadService(std::unique_ptr<GamepadDataFetcher> fetcher) : provider_(new GamepadProvider(std::move(fetcher))), num_active_consumers_(0), gesture_callback_pending_(false) {
diff --git a/content/browser/gamepad/gamepad_service.h b/content/browser/gamepad/gamepad_service.h index 22bea8c0..d4536393 100644 --- a/content/browser/gamepad/gamepad_service.h +++ b/content/browser/gamepad/gamepad_service.h
@@ -5,11 +5,11 @@ #ifndef CONTENT_BROWSER_GAMEPAD_GAMEPAD_SERVICE_H_ #define CONTENT_BROWSER_GAMEPAD_GAMEPAD_SERVICE_H_ +#include <memory> #include <set> #include "base/callback_forward.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/shared_memory.h" #include "base/memory/singleton.h" #include "base/threading/thread_checker.h" @@ -88,7 +88,7 @@ // Constructor for testing. This specifies the data fetcher to use for a // provider, bypassing the default platform one. - GamepadService(scoped_ptr<GamepadDataFetcher> fetcher); + GamepadService(std::unique_ptr<GamepadDataFetcher> fetcher); virtual ~GamepadService(); @@ -111,7 +111,7 @@ mutable bool did_observe_user_gesture; }; - scoped_ptr<GamepadProvider> provider_; + std::unique_ptr<GamepadProvider> provider_; base::ThreadChecker thread_checker_;
diff --git a/content/browser/gamepad/gamepad_service_unittest.cc b/content/browser/gamepad/gamepad_service_unittest.cc index 5b9d1c2..db16d6b5 100644 --- a/content/browser/gamepad/gamepad_service_unittest.cc +++ b/content/browser/gamepad/gamepad_service_unittest.cc
@@ -2,13 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/browser/gamepad/gamepad_service.h" + #include <string.h> +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/run_loop.h" #include "content/browser/gamepad/gamepad_consumer.h" -#include "content/browser/gamepad/gamepad_service.h" #include "content/browser/gamepad/gamepad_test_helpers.h" #include "content/public/test/test_browser_thread_bundle.h" #include "testing/gtest/include/gtest/gtest.h" @@ -69,7 +71,7 @@ private: MockGamepadDataFetcher* fetcher_; GamepadService* service_; - scoped_ptr<ConnectionListener> connection_listener_; + std::unique_ptr<ConnectionListener> connection_listener_; TestBrowserThreadBundle browser_thread_; WebGamepads test_data_; @@ -92,7 +94,7 @@ void GamepadServiceTest::SetUp() { fetcher_ = new MockGamepadDataFetcher(test_data_); - service_ = new GamepadService(scoped_ptr<GamepadDataFetcher>(fetcher_)); + service_ = new GamepadService(std::unique_ptr<GamepadDataFetcher>(fetcher_)); connection_listener_.reset((new ConnectionListener)); service_->ConsumerBecameActive(connection_listener_.get()); }
diff --git a/content/browser/gamepad/gamepad_test_helpers.cc b/content/browser/gamepad/gamepad_test_helpers.cc index fc79dcb..ed78e2e 100644 --- a/content/browser/gamepad/gamepad_test_helpers.cc +++ b/content/browser/gamepad/gamepad_test_helpers.cc
@@ -54,7 +54,7 @@ const blink::WebGamepads& test_data) { data_fetcher_ = new MockGamepadDataFetcher(test_data); gamepad_service_ = - new GamepadService(scoped_ptr<GamepadDataFetcher>(data_fetcher_)); + new GamepadService(std::unique_ptr<GamepadDataFetcher>(data_fetcher_)); } GamepadServiceTestConstructor::~GamepadServiceTestConstructor() {
diff --git a/content/browser/gamepad/gamepad_test_helpers.h b/content/browser/gamepad/gamepad_test_helpers.h index 5e30f99..4b44f2b7f 100644 --- a/content/browser/gamepad/gamepad_test_helpers.h +++ b/content/browser/gamepad/gamepad_test_helpers.h
@@ -5,8 +5,9 @@ #ifndef CONTENT_BROWSER_GAMEPAD_GAMEPAD_TEST_HELPERS_H_ #define CONTENT_BROWSER_GAMEPAD_GAMEPAD_TEST_HELPERS_H_ +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" #include "base/synchronization/lock.h" #include "base/synchronization/waitable_event.h"
diff --git a/content/browser/gamepad/raw_input_data_fetcher_win.cc b/content/browser/gamepad/raw_input_data_fetcher_win.cc index 0693eef9..0e53508 100644 --- a/content/browser/gamepad/raw_input_data_fetcher_win.cc +++ b/content/browser/gamepad/raw_input_data_fetcher_win.cc
@@ -62,7 +62,7 @@ RAWINPUTDEVICE* RawInputDataFetcher::GetRawInputDevices(DWORD flags) { size_t usage_count = arraysize(DeviceUsages); - scoped_ptr<RAWINPUTDEVICE[]> devices(new RAWINPUTDEVICE[usage_count]); + std::unique_ptr<RAWINPUTDEVICE[]> devices(new RAWINPUTDEVICE[usage_count]); for (size_t i = 0; i < usage_count; ++i) { devices[i].dwFlags = flags; devices[i].usUsagePage = 1; @@ -87,7 +87,8 @@ } // Register to receive raw HID input. - scoped_ptr<RAWINPUTDEVICE[]> devices(GetRawInputDevices(RIDEV_INPUTSINK)); + std::unique_ptr<RAWINPUTDEVICE[]> devices( + GetRawInputDevices(RIDEV_INPUTSINK)); if (!RegisterRawInputDevices(devices.get(), arraysize(DeviceUsages), sizeof(RAWINPUTDEVICE))) { PLOG(ERROR) << "RegisterRawInputDevices() failed for RIDEV_INPUTSINK"; @@ -109,7 +110,7 @@ // Stop receiving raw input. DCHECK(window_); - scoped_ptr<RAWINPUTDEVICE[]> devices(GetRawInputDevices(RIDEV_REMOVE)); + std::unique_ptr<RAWINPUTDEVICE[]> devices(GetRawInputDevices(RIDEV_REMOVE)); if (!RegisterRawInputDevices(devices.get(), arraysize(DeviceUsages), sizeof(RAWINPUTDEVICE))) { @@ -144,7 +145,8 @@ } DCHECK_EQ(0u, result); - scoped_ptr<RAWINPUTDEVICELIST[]> device_list(new RAWINPUTDEVICELIST[count]); + std::unique_ptr<RAWINPUTDEVICELIST[]> device_list( + new RAWINPUTDEVICELIST[count]); result = GetRawInputDeviceList(device_list.get(), &count, sizeof(RAWINPUTDEVICELIST)); if (result == static_cast<UINT>(-1)) { @@ -190,7 +192,7 @@ } DCHECK_EQ(0u, result); - scoped_ptr<uint8_t[]> di_buffer(new uint8_t[size]); + std::unique_ptr<uint8_t[]> di_buffer(new uint8_t[size]); RID_DEVICE_INFO* device_info = reinterpret_cast<RID_DEVICE_INFO*>(di_buffer.get()); result = GetRawInputDeviceInfo(hDevice, RIDI_DEVICEINFO, @@ -213,7 +215,7 @@ if (!valid_type) return NULL; - scoped_ptr<RawGamepadInfo> gamepad_info(new RawGamepadInfo); + std::unique_ptr<RawGamepadInfo> gamepad_info(new RawGamepadInfo); gamepad_info->handle = hDevice; gamepad_info->report_id = 0; gamepad_info->vendor_id = device_info->hid.dwVendorId; @@ -232,7 +234,7 @@ } DCHECK_EQ(0u, result); - scoped_ptr<wchar_t[]> name_buffer(new wchar_t[size]); + std::unique_ptr<wchar_t[]> name_buffer(new wchar_t[size]); result = GetRawInputDeviceInfo(hDevice, RIDI_DEVICENAME, name_buffer.get(), &size); if (result == static_cast<UINT>(-1)) { @@ -287,7 +289,8 @@ // Query button information. USHORT count = caps.NumberInputButtonCaps; if (count > 0) { - scoped_ptr<HIDP_BUTTON_CAPS[]> button_caps(new HIDP_BUTTON_CAPS[count]); + std::unique_ptr<HIDP_BUTTON_CAPS[]> button_caps( + new HIDP_BUTTON_CAPS[count]); status = hidp_get_button_caps_( HidP_Input, button_caps.get(), &count, gamepad_info->preparsed_data); DCHECK_EQ(HIDP_STATUS_SUCCESS, status); @@ -305,7 +308,7 @@ // Query axis information. count = caps.NumberInputValueCaps; - scoped_ptr<HIDP_VALUE_CAPS[]> axes_caps(new HIDP_VALUE_CAPS[count]); + std::unique_ptr<HIDP_VALUE_CAPS[]> axes_caps(new HIDP_VALUE_CAPS[count]); status = hidp_get_value_caps_(HidP_Input, axes_caps.get(), &count, gamepad_info->preparsed_data); @@ -377,7 +380,8 @@ reinterpret_cast<PCHAR>(input->data.hid.bRawData), input->data.hid.dwSizeHid); - scoped_ptr<USAGE_AND_PAGE[]> usages(new USAGE_AND_PAGE[buttons_length]); + std::unique_ptr<USAGE_AND_PAGE[]> usages( + new USAGE_AND_PAGE[buttons_length]); status = hidp_get_usages_ex_(HidP_Input, 0, @@ -445,7 +449,7 @@ DCHECK_EQ(0u, result); // Retrieve the input record. - scoped_ptr<uint8_t[]> buffer(new uint8_t[size]); + std::unique_ptr<uint8_t[]> buffer(new uint8_t[size]); RAWINPUT* input = reinterpret_cast<RAWINPUT*>(buffer.get()); result = GetRawInputData( input_handle, RID_INPUT, buffer.get(), &size, sizeof(RAWINPUTHEADER));
diff --git a/content/browser/gamepad/raw_input_data_fetcher_win.h b/content/browser/gamepad/raw_input_data_fetcher_win.h index 69b780d5..b65e6c9b 100644 --- a/content/browser/gamepad/raw_input_data_fetcher_win.h +++ b/content/browser/gamepad/raw_input_data_fetcher_win.h
@@ -5,24 +5,23 @@ #ifndef CONTENT_BROWSER_GAMEPAD_RAW_INPUT_DATA_FETCHER_WIN_H_ #define CONTENT_BROWSER_GAMEPAD_RAW_INPUT_DATA_FETCHER_WIN_H_ -#include "build/build_config.h" - #include <stdint.h> #include <stdlib.h> #include <Unknwn.h> #include <WinDef.h> #include <windows.h> - #include <hidsdi.h> + #include <map> +#include <memory> #include <vector> #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/message_loop/message_loop.h" #include "base/scoped_native_library.h" #include "base/win/message_window.h" +#include "build/build_config.h" #include "content/browser/gamepad/gamepad_data_fetcher.h" #include "content/browser/gamepad/gamepad_standard_mappings.h" #include "third_party/WebKit/public/platform/WebGamepads.h" @@ -41,7 +40,7 @@ ~RawGamepadInfo(); HANDLE handle; - scoped_ptr<uint8_t[]> ppd_buffer; + std::unique_ptr<uint8_t[]> ppd_buffer; PHIDP_PREPARSED_DATA preparsed_data; uint32_t report_id; @@ -120,7 +119,7 @@ bool GetHidDllFunctions(); base::ScopedNativeLibrary hid_dll_; - scoped_ptr<base::win::MessageWindow> window_; + std::unique_ptr<base::win::MessageWindow> window_; bool rawinput_available_; bool filter_xinput_; bool events_monitored_;
diff --git a/content/browser/gamepad/xbox_data_fetcher_mac.h b/content/browser/gamepad/xbox_data_fetcher_mac.h index 599a63c..e4b98ff 100644 --- a/content/browser/gamepad/xbox_data_fetcher_mac.h +++ b/content/browser/gamepad/xbox_data_fetcher_mac.h
@@ -10,13 +10,13 @@ #include <stddef.h> #include <stdint.h> +#include <memory> #include <set> #include "base/mac/scoped_cftyperef.h" #include "base/mac/scoped_ioobject.h" #include "base/mac/scoped_ioplugininterface.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" class XboxController { public: @@ -119,7 +119,7 @@ // byte header (type, total length) so we can reframe the packet data // ourselves. uint16_t read_buffer_size_; - scoped_ptr<uint8_t[]> read_buffer_; + std::unique_ptr<uint8_t[]> read_buffer_; // The pattern that the LEDs on the device are currently displaying, or // LED_NUM_PATTERNS if unknown.
diff --git a/content/browser/geofencing/geofencing_manager.h b/content/browser/geofencing/geofencing_manager.h index afe3d2d..07461fb 100644 --- a/content/browser/geofencing/geofencing_manager.h +++ b/content/browser/geofencing/geofencing_manager.h
@@ -8,13 +8,13 @@ #include <stdint.h> #include <map> +#include <memory> #include <string> #include <vector> #include "base/callback_forward.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/geofencing/geofencing_registration_delegate.h" #include "content/browser/service_worker/service_worker_context_observer.h" #include "content/browser/service_worker/service_worker_storage.h" @@ -206,7 +206,7 @@ RegistrationIdRegistrationMap registrations_by_id_; GeofencingService* service_; - scoped_ptr<MockGeofencingService> mock_service_; + std::unique_ptr<MockGeofencingService> mock_service_; scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; DISALLOW_COPY_AND_ASSIGN(GeofencingManager);
diff --git a/content/browser/geofencing/geofencing_manager_unittest.cc b/content/browser/geofencing/geofencing_manager_unittest.cc index bd905d1c..f8573e5 100644 --- a/content/browser/geofencing/geofencing_manager_unittest.cc +++ b/content/browser/geofencing/geofencing_manager_unittest.cc
@@ -246,7 +246,7 @@ protected: TestBrowserThreadBundle threads_; - scoped_ptr<EmbeddedWorkerTestHelper> helper_; + std::unique_ptr<EmbeddedWorkerTestHelper> helper_; TestGeofencingService* service_; scoped_refptr<GeofencingManager> manager_;
diff --git a/content/browser/geofencing/geofencing_service.cc b/content/browser/geofencing/geofencing_service.cc index 9f429d5..a9f9dfe 100644 --- a/content/browser/geofencing/geofencing_service.cc +++ b/content/browser/geofencing/geofencing_service.cc
@@ -140,7 +140,7 @@ } void GeofencingServiceImpl::SetProviderForTesting( - scoped_ptr<GeofencingProvider> provider) { + std::unique_ptr<GeofencingProvider> provider) { DCHECK(!provider_.get()); provider_ = std::move(provider); }
diff --git a/content/browser/geofencing/geofencing_service.h b/content/browser/geofencing/geofencing_service.h index dddbcfb1..7685243 100644 --- a/content/browser/geofencing/geofencing_service.h +++ b/content/browser/geofencing/geofencing_service.h
@@ -8,10 +8,10 @@ #include <stdint.h> #include <map> +#include <memory> #include "base/compiler_specific.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "content/common/content_export.h" #include "content/common/geofencing_types.h" @@ -78,7 +78,7 @@ GeofencingServiceImpl(); ~GeofencingServiceImpl() override; - void SetProviderForTesting(scoped_ptr<GeofencingProvider> provider); + void SetProviderForTesting(std::unique_ptr<GeofencingProvider> provider); int RegistrationCountForTesting(); private: @@ -100,7 +100,7 @@ int64_t next_registration_id_; RegistrationsMap registrations_; - scoped_ptr<GeofencingProvider> provider_; + std::unique_ptr<GeofencingProvider> provider_; DISALLOW_COPY_AND_ASSIGN(GeofencingServiceImpl); };
diff --git a/content/browser/geofencing/geofencing_service_unittest.cc b/content/browser/geofencing/geofencing_service_unittest.cc index 8d512ac..437580ef 100644 --- a/content/browser/geofencing/geofencing_service_unittest.cc +++ b/content/browser/geofencing/geofencing_service_unittest.cc
@@ -2,11 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/browser/geofencing/geofencing_service.h" + #include <stdint.h> +#include "base/memory/ptr_util.h" #include "content/browser/geofencing/geofencing_provider.h" #include "content/browser/geofencing/geofencing_registration_delegate.h" -#include "content/browser/geofencing/geofencing_service.h" #include "content/public/test/test_browser_thread_bundle.h" #include "content/public/test/test_utils.h" #include "testing/gmock/include/gmock/gmock.h" @@ -77,7 +79,7 @@ void SetProviderForTests() { provider_ = new MockGeofencingProvider(); - service_->SetProviderForTesting(make_scoped_ptr(provider_)); + service_->SetProviderForTesting(base::WrapUnique(provider_)); } int RegistrationCount() { return service_->RegistrationCountForTesting(); }
diff --git a/content/browser/geolocation/geolocation_provider_impl.cc b/content/browser/geolocation/geolocation_provider_impl.cc index c490907..f3d6e37 100644 --- a/content/browser/geolocation/geolocation_provider_impl.cc +++ b/content/browser/geolocation/geolocation_provider_impl.cc
@@ -9,6 +9,7 @@ #include "base/callback.h" #include "base/location.h" #include "base/logging.h" +#include "base/memory/ptr_util.h" #include "base/memory/singleton.h" #include "base/single_thread_task_runner.h" #include "content/browser/geolocation/location_arbitrator_impl.h" @@ -20,12 +21,12 @@ return GeolocationProviderImpl::GetInstance(); } -scoped_ptr<GeolocationProvider::Subscription> +std::unique_ptr<GeolocationProvider::Subscription> GeolocationProviderImpl::AddLocationUpdateCallback( const LocationUpdateCallback& callback, bool enable_high_accuracy) { DCHECK_CURRENTLY_ON(BrowserThread::UI); - scoped_ptr<GeolocationProvider::Subscription> subscription; + std::unique_ptr<GeolocationProvider::Subscription> subscription; if (enable_high_accuracy) { subscription = high_accuracy_callbacks_.Add(callback); } else { @@ -169,10 +170,11 @@ arbitrator_.reset(); } -scoped_ptr<LocationArbitrator> GeolocationProviderImpl::CreateArbitrator() { +std::unique_ptr<LocationArbitrator> +GeolocationProviderImpl::CreateArbitrator() { LocationArbitratorImpl::LocationUpdateCallback callback = base::Bind( &GeolocationProviderImpl::OnLocationUpdate, base::Unretained(this)); - return make_scoped_ptr(new LocationArbitratorImpl(callback)); + return base::WrapUnique(new LocationArbitratorImpl(callback)); } } // namespace content
diff --git a/content/browser/geolocation/geolocation_provider_impl.h b/content/browser/geolocation/geolocation_provider_impl.h index 92129c5..b7c7e9d 100644 --- a/content/browser/geolocation/geolocation_provider_impl.h +++ b/content/browser/geolocation/geolocation_provider_impl.h
@@ -6,12 +6,12 @@ #define CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_PROVIDER_IMPL_H_ #include <list> +#include <memory> #include <vector> #include "base/callback_forward.h" #include "base/compiler_specific.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/threading/thread.h" #include "content/common/content_export.h" #include "content/public/browser/geolocation_provider.h" @@ -29,7 +29,7 @@ public base::Thread { public: // GeolocationProvider implementation: - scoped_ptr<GeolocationProvider::Subscription> AddLocationUpdateCallback( + std::unique_ptr<GeolocationProvider::Subscription> AddLocationUpdateCallback( const LocationUpdateCallback& callback, bool enable_high_accuracy) override; void UserDidOptIntoLocationServices() override; @@ -55,7 +55,7 @@ // Useful for injecting mock geolocation arbitrator in tests. // TODO(mvanouwerkerk): Use something like SetArbitratorForTesting instead. - virtual scoped_ptr<LocationArbitrator> CreateArbitrator(); + virtual std::unique_ptr<LocationArbitrator> CreateArbitrator(); private: bool OnGeolocationThread() const; @@ -92,7 +92,7 @@ bool ignore_location_updates_; // Only to be used on the geolocation thread. - scoped_ptr<LocationArbitrator> arbitrator_; + std::unique_ptr<LocationArbitrator> arbitrator_; DISALLOW_COPY_AND_ASSIGN(GeolocationProviderImpl); };
diff --git a/content/browser/geolocation/geolocation_provider_impl_unittest.cc b/content/browser/geolocation/geolocation_provider_impl_unittest.cc index f1c7323..a2ceaf63 100644 --- a/content/browser/geolocation/geolocation_provider_impl_unittest.cc +++ b/content/browser/geolocation/geolocation_provider_impl_unittest.cc
@@ -2,16 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/browser/geolocation/geolocation_provider_impl.h" + +#include <memory> + #include "base/bind.h" #include "base/bind_helpers.h" #include "base/location.h" #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/single_thread_task_runner.h" #include "base/strings/string16.h" #include "base/time/time.h" -#include "content/browser/geolocation/geolocation_provider_impl.h" #include "content/browser/geolocation/mock_location_arbitrator.h" #include "content/public/browser/access_token_store.h" #include "content/public/browser/browser_thread.h" @@ -38,18 +41,18 @@ protected: // GeolocationProviderImpl implementation: - scoped_ptr<LocationArbitrator> CreateArbitrator() override; + std::unique_ptr<LocationArbitrator> CreateArbitrator() override; private: // An alias to the arbitrator stored in the super class, where it is owned. MockLocationArbitrator* mock_arbitrator_; }; -scoped_ptr<LocationArbitrator> +std::unique_ptr<LocationArbitrator> LocationProviderForTestArbitrator::CreateArbitrator() { DCHECK(mock_arbitrator_ == NULL); mock_arbitrator_ = new MockLocationArbitrator; - return make_scoped_ptr(mock_arbitrator_); + return base::WrapUnique(mock_arbitrator_); } class GeolocationObserver { @@ -136,7 +139,7 @@ base::MessageLoop message_loop_; TestBrowserThread ui_thread_; - scoped_ptr<LocationProviderForTestArbitrator> provider_; + std::unique_ptr<LocationProviderForTestArbitrator> provider_; }; @@ -179,7 +182,7 @@ EXPECT_FALSE(provider()->IsRunning()); GeolocationProviderImpl::LocationUpdateCallback callback = base::Bind(&DummyFunction); - scoped_ptr<content::GeolocationProvider::Subscription> subscription = + std::unique_ptr<content::GeolocationProvider::Subscription> subscription = provider()->AddLocationUpdateCallback(callback, false); EXPECT_TRUE(provider()->IsRunning()); EXPECT_TRUE(ProvidersStarted()); @@ -202,7 +205,7 @@ &MockGeolocationObserver::OnLocationUpdate, base::Unretained(&first_observer)); EXPECT_CALL(first_observer, OnLocationUpdate(GeopositionEq(first_position))); - scoped_ptr<content::GeolocationProvider::Subscription> subscription = + std::unique_ptr<content::GeolocationProvider::Subscription> subscription = provider()->AddLocationUpdateCallback(first_callback, false); SendMockLocation(first_position); base::MessageLoop::current()->Run(); @@ -223,7 +226,7 @@ GeolocationProviderImpl::LocationUpdateCallback second_callback = base::Bind( &MockGeolocationObserver::OnLocationUpdate, base::Unretained(&second_observer)); - scoped_ptr<content::GeolocationProvider::Subscription> subscription2 = + std::unique_ptr<content::GeolocationProvider::Subscription> subscription2 = provider()->AddLocationUpdateCallback(second_callback, false); base::MessageLoop::current()->RunUntilIdle(); @@ -248,7 +251,7 @@ GeolocationProviderImpl::LocationUpdateCallback callback = base::Bind( &MockGeolocationObserver::OnLocationUpdate, base::Unretained(&mock_observer)); - scoped_ptr<content::GeolocationProvider::Subscription> subscription = + std::unique_ptr<content::GeolocationProvider::Subscription> subscription = provider()->AddLocationUpdateCallback(callback, false); subscription.reset(); // Wait for the providers to be stopped now that all clients are gone.
diff --git a/content/browser/geolocation/geolocation_service_context.cc b/content/browser/geolocation/geolocation_service_context.cc index aeb6e621..1b69b1e 100644 --- a/content/browser/geolocation/geolocation_service_context.cc +++ b/content/browser/geolocation/geolocation_service_context.cc
@@ -48,7 +48,7 @@ } void GeolocationServiceContext::SetOverride( - scoped_ptr<Geoposition> geoposition) { + std::unique_ptr<Geoposition> geoposition) { geoposition_override_.swap(geoposition); for (auto* service : services_) { service->SetOverride(*geoposition_override_.get());
diff --git a/content/browser/geolocation/geolocation_service_context.h b/content/browser/geolocation/geolocation_service_context.h index 2e494a1..c97bb53 100644 --- a/content/browser/geolocation/geolocation_service_context.h +++ b/content/browser/geolocation/geolocation_service_context.h
@@ -42,7 +42,7 @@ // Enables geolocation override. This method can be used to trigger possible // location-specific behavior in a particular context. - void SetOverride(scoped_ptr<Geoposition> geoposition); + void SetOverride(std::unique_ptr<Geoposition> geoposition); // Disables geolocation override. void ClearOverride(); @@ -51,7 +51,7 @@ ScopedVector<GeolocationServiceImpl> services_; bool paused_; - scoped_ptr<Geoposition> geoposition_override_; + std::unique_ptr<Geoposition> geoposition_override_; DISALLOW_COPY_AND_ASSIGN(GeolocationServiceContext); };
diff --git a/content/browser/geolocation/geolocation_service_impl.h b/content/browser/geolocation/geolocation_service_impl.h index e0565ee..df37f88 100644 --- a/content/browser/geolocation/geolocation_service_impl.h +++ b/content/browser/geolocation/geolocation_service_impl.h
@@ -2,8 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/geolocation/geolocation_provider_impl.h" #include "mojo/public/cpp/bindings/binding.h" #include "third_party/WebKit/public/platform/modules/geolocation/geolocation.mojom.h" @@ -56,7 +57,7 @@ // Owns this object. GeolocationServiceContext* context_; - scoped_ptr<GeolocationProvider::Subscription> geolocation_subscription_; + std::unique_ptr<GeolocationProvider::Subscription> geolocation_subscription_; // Callback that allows the instantiator of this class to be notified on // position updates.
diff --git a/content/browser/geolocation/location_arbitrator_impl_unittest.cc b/content/browser/geolocation/location_arbitrator_impl_unittest.cc index 0ca94b59..93b1645b 100644 --- a/content/browser/geolocation/location_arbitrator_impl_unittest.cc +++ b/content/browser/geolocation/location_arbitrator_impl_unittest.cc
@@ -2,10 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/bind.h" -#include "base/memory/scoped_ptr.h" -#include "content/browser/geolocation/fake_access_token_store.h" #include "content/browser/geolocation/location_arbitrator_impl.h" + +#include <memory> + +#include "base/bind.h" +#include "content/browser/geolocation/fake_access_token_store.h" #include "content/browser/geolocation/mock_location_provider.h" #include "content/public/common/geoposition.h" #include "testing/gmock/include/gmock/gmock.h" @@ -143,8 +145,8 @@ } scoped_refptr<FakeAccessTokenStore> access_token_store_; - scoped_ptr<MockLocationObserver> observer_; - scoped_ptr<TestingLocationArbitrator> arbitrator_; + std::unique_ptr<MockLocationObserver> observer_; + std::unique_ptr<TestingLocationArbitrator> arbitrator_; base::MessageLoop loop_; };
diff --git a/content/browser/geolocation/network_location_provider.h b/content/browser/geolocation/network_location_provider.h index 6c37a8c..3381e52 100644 --- a/content/browser/geolocation/network_location_provider.h +++ b/content/browser/geolocation/network_location_provider.h
@@ -9,10 +9,10 @@ #include <list> #include <map> +#include <memory> #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/strings/string16.h" #include "base/threading/non_thread_safe.h" @@ -124,10 +124,10 @@ bool is_new_data_available_; // The network location request object, and the url it uses. - scoped_ptr<NetworkLocationRequest> request_; + std::unique_ptr<NetworkLocationRequest> request_; // The cache of positions. - scoped_ptr<PositionCache> position_cache_; + std::unique_ptr<PositionCache> position_cache_; base::WeakPtrFactory<NetworkLocationProvider> weak_factory_;
diff --git a/content/browser/geolocation/network_location_provider_unittest.cc b/content/browser/geolocation/network_location_provider_unittest.cc index 0b09a39f..ebbf582 100644 --- a/content/browser/geolocation/network_location_provider_unittest.cc +++ b/content/browser/geolocation/network_location_provider_unittest.cc
@@ -2,12 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/browser/geolocation/network_location_provider.h" + #include <stddef.h> +#include <memory> + #include "base/json/json_reader.h" #include "base/json/json_writer.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" @@ -15,7 +18,6 @@ #include "base/values.h" #include "content/browser/geolocation/fake_access_token_store.h" #include "content/browser/geolocation/location_arbitrator_impl.h" -#include "content/browser/geolocation/network_location_provider.h" #include "content/browser/geolocation/wifi_data_provider.h" #include "net/base/net_errors.h" #include "net/url_request/test_url_fetcher_factory.h" @@ -262,8 +264,9 @@ const std::string& upload_data = request.upload_data(); ASSERT_FALSE(upload_data.empty()); std::string json_parse_error_msg; - scoped_ptr<base::Value> parsed_json = base::JSONReader::ReadAndReturnError( - upload_data, base::JSON_PARSE_RFC, NULL, &json_parse_error_msg); + std::unique_ptr<base::Value> parsed_json = + base::JSONReader::ReadAndReturnError(upload_data, base::JSON_PARSE_RFC, + NULL, &json_parse_error_msg); EXPECT_TRUE(json_parse_error_msg.empty()); ASSERT_TRUE(parsed_json.get() != NULL); @@ -320,14 +323,14 @@ TEST_F(GeolocationNetworkProviderTest, CreateDestroy) { // Test fixture members were SetUp correctly. EXPECT_EQ(&main_message_loop_, base::MessageLoop::current()); - scoped_ptr<LocationProvider> provider(CreateProvider(true)); + std::unique_ptr<LocationProvider> provider(CreateProvider(true)); EXPECT_TRUE(NULL != provider.get()); provider.reset(); SUCCEED(); } TEST_F(GeolocationNetworkProviderTest, StartProvider) { - scoped_ptr<LocationProvider> provider(CreateProvider(true)); + std::unique_ptr<LocationProvider> provider(CreateProvider(true)); EXPECT_TRUE(provider->StartProvider(false)); net::TestURLFetcher* fetcher = get_url_fetcher_and_advance_id(); ASSERT_TRUE(fetcher != NULL); @@ -336,7 +339,7 @@ TEST_F(GeolocationNetworkProviderTest, StartProviderDefaultUrl) { test_server_url_ = LocationArbitratorImpl::DefaultNetworkProviderURL(); - scoped_ptr<LocationProvider> provider(CreateProvider(true)); + std::unique_ptr<LocationProvider> provider(CreateProvider(true)); EXPECT_TRUE(provider->StartProvider(false)); net::TestURLFetcher* fetcher = get_url_fetcher_and_advance_id(); ASSERT_TRUE(fetcher != NULL); @@ -344,7 +347,7 @@ } TEST_F(GeolocationNetworkProviderTest, StartProviderLongRequest) { - scoped_ptr<LocationProvider> provider(CreateProvider(true)); + std::unique_ptr<LocationProvider> provider(CreateProvider(true)); EXPECT_TRUE(provider->StartProvider(false)); const int kFirstScanAps = 20; wifi_data_provider_->SetData(CreateReferenceWifiScanData(kFirstScanAps)); @@ -359,7 +362,7 @@ } TEST_F(GeolocationNetworkProviderTest, MultipleWifiScansComplete) { - scoped_ptr<LocationProvider> provider(CreateProvider(true)); + std::unique_ptr<LocationProvider> provider(CreateProvider(true)); EXPECT_TRUE(provider->StartProvider(false)); net::TestURLFetcher* fetcher = get_url_fetcher_and_advance_id(); @@ -463,7 +466,7 @@ TEST_F(GeolocationNetworkProviderTest, NoRequestOnStartupUntilWifiData) { MessageLoopQuitListener listener; wifi_data_provider_->set_got_data(false); - scoped_ptr<LocationProvider> provider(CreateProvider(true)); + std::unique_ptr<LocationProvider> provider(CreateProvider(true)); EXPECT_TRUE(provider->StartProvider(false)); provider->SetUpdateCallback(base::Bind( @@ -481,7 +484,7 @@ TEST_F(GeolocationNetworkProviderTest, NewDataReplacesExistingNetworkRequest) { // Send initial request with empty data - scoped_ptr<LocationProvider> provider(CreateProvider(true)); + std::unique_ptr<LocationProvider> provider(CreateProvider(true)); EXPECT_TRUE(provider->StartProvider(false)); net::TestURLFetcher* fetcher = get_url_fetcher_and_advance_id(); EXPECT_TRUE(fetcher); @@ -494,7 +497,7 @@ } TEST_F(GeolocationNetworkProviderTest, NetworkRequestDeferredForPermission) { - scoped_ptr<LocationProvider> provider(CreateProvider(false)); + std::unique_ptr<LocationProvider> provider(CreateProvider(false)); EXPECT_TRUE(provider->StartProvider(false)); net::TestURLFetcher* fetcher = get_url_fetcher_and_advance_id(); EXPECT_FALSE(fetcher); @@ -510,7 +513,7 @@ NetworkRequestWithWifiDataDeferredForPermission) { access_token_store_->access_token_map_[test_server_url_] = base::UTF8ToUTF16(REFERENCE_ACCESS_TOKEN); - scoped_ptr<LocationProvider> provider(CreateProvider(false)); + std::unique_ptr<LocationProvider> provider(CreateProvider(false)); EXPECT_TRUE(provider->StartProvider(false)); net::TestURLFetcher* fetcher = get_url_fetcher_and_advance_id(); EXPECT_FALSE(fetcher);
diff --git a/content/browser/geolocation/network_location_request.cc b/content/browser/geolocation/network_location_request.cc index 7471c1716..933ce5f 100644 --- a/content/browser/geolocation/network_location_request.cc +++ b/content/browser/geolocation/network_location_request.cc
@@ -360,8 +360,9 @@ // Parse the response, ignoring comments. std::string error_msg; - scoped_ptr<base::Value> response_value = base::JSONReader::ReadAndReturnError( - response_body, base::JSON_PARSE_RFC, NULL, &error_msg); + std::unique_ptr<base::Value> response_value = + base::JSONReader::ReadAndReturnError(response_body, base::JSON_PARSE_RFC, + NULL, &error_msg); if (response_value == NULL) { LOG(WARNING) << "ParseServerResponse() : JSONReader failed : " << error_msg;
diff --git a/content/browser/geolocation/network_location_request.h b/content/browser/geolocation/network_location_request.h index 6f7673a..e091320b 100644 --- a/content/browser/geolocation/network_location_request.h +++ b/content/browser/geolocation/network_location_request.h
@@ -5,10 +5,11 @@ #ifndef CONTENT_BROWSER_GEOLOCATION_NETWORK_LOCATION_REQUEST_H_ #define CONTENT_BROWSER_GEOLOCATION_NETWORK_LOCATION_REQUEST_H_ +#include <memory> + #include "base/callback.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/strings/string16.h" #include "content/browser/geolocation/wifi_data_provider.h" #include "content/common/content_export.h" @@ -61,7 +62,7 @@ scoped_refptr<net::URLRequestContextGetter> url_context_; LocationResponseCallback location_response_callback_; const GURL url_; - scoped_ptr<net::URLFetcher> url_fetcher_; + std::unique_ptr<net::URLFetcher> url_fetcher_; // Keep a copy of the data sent in the request, so we can refer back to it // when the response arrives.
diff --git a/content/browser/geolocation/wifi_data_provider_chromeos.h b/content/browser/geolocation/wifi_data_provider_chromeos.h index c5055dc..df74768 100644 --- a/content/browser/geolocation/wifi_data_provider_chromeos.h +++ b/content/browser/geolocation/wifi_data_provider_chromeos.h
@@ -5,9 +5,10 @@ #ifndef CONTENT_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_CHROMEOS_H_ #define CONTENT_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_CHROMEOS_H_ +#include <memory> + #include "base/compiler_specific.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/geolocation/wifi_data_provider.h" #include "content/browser/geolocation/wifi_polling_policy.h" @@ -47,7 +48,7 @@ bool GetAccessPointData(WifiData::AccessPointDataSet* data); // Controls the polling update interval. (client thread) - scoped_ptr<WifiPollingPolicy> polling_policy_; + std::unique_ptr<WifiPollingPolicy> polling_policy_; // The latest wifi data. (client thread) WifiData wifi_data_;
diff --git a/content/browser/geolocation/wifi_data_provider_common.h b/content/browser/geolocation/wifi_data_provider_common.h index d7cf195..b7439633 100644 --- a/content/browser/geolocation/wifi_data_provider_common.h +++ b/content/browser/geolocation/wifi_data_provider_common.h
@@ -8,9 +8,10 @@ #include <assert.h> #include <stdint.h> +#include <memory> + #include "base/logging.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/strings/string16.h" #include "content/browser/geolocation/wifi_data_provider.h" @@ -67,10 +68,10 @@ bool is_first_scan_complete_; // Underlying OS wifi API. - scoped_ptr<WlanApiInterface> wlan_api_; + std::unique_ptr<WlanApiInterface> wlan_api_; // Controls the polling update interval. - scoped_ptr<WifiPollingPolicy> polling_policy_; + std::unique_ptr<WifiPollingPolicy> polling_policy_; // Holder for delayed tasks; takes care of cleanup. base::WeakPtrFactory<WifiDataProviderCommon> weak_factory_;
diff --git a/content/browser/geolocation/wifi_data_provider_common_unittest.cc b/content/browser/geolocation/wifi_data_provider_common_unittest.cc index 8acf93a..b327c14 100644 --- a/content/browser/geolocation/wifi_data_provider_common_unittest.cc +++ b/content/browser/geolocation/wifi_data_provider_common_unittest.cc
@@ -2,14 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/browser/geolocation/wifi_data_provider_common.h" + +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/strings/utf_string_conversions.h" #include "base/third_party/dynamic_annotations/dynamic_annotations.h" #include "base/thread_task_runner_handle.h" -#include "content/browser/geolocation/wifi_data_provider_common.h" #include "content/browser/geolocation/wifi_data_provider_manager.h" #include "content/public/test/test_browser_thread_bundle.h" #include "testing/gmock/include/gmock/gmock.h" @@ -76,8 +78,8 @@ return new_polling_policy_.release(); } - scoped_ptr<MockWlanApi> new_wlan_api_; - scoped_ptr<MockPollingPolicy> new_polling_policy_; + std::unique_ptr<MockWlanApi> new_wlan_api_; + std::unique_ptr<MockPollingPolicy> new_polling_policy_; private: ~WifiDataProviderCommonWithMock() override {} @@ -125,7 +127,7 @@ protected: TestBrowserThreadBundle thread_bundle_; scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; - scoped_ptr<base::RunLoop> run_loop_; + std::unique_ptr<base::RunLoop> run_loop_; WifiDataProviderManager::WifiDataUpdateCallback wifi_data_callback_; scoped_refptr<WifiDataProviderCommonWithMock> provider_; MockWlanApi* wlan_api_;
diff --git a/content/browser/geolocation/wifi_data_provider_corewlan_mac.mm b/content/browser/geolocation/wifi_data_provider_corewlan_mac.mm index bbe099f..89485d55 100644 --- a/content/browser/geolocation/wifi_data_provider_corewlan_mac.mm +++ b/content/browser/geolocation/wifi_data_provider_corewlan_mac.mm
@@ -182,7 +182,7 @@ } WifiDataProviderCommon::WlanApiInterface* NewCoreWlanApi() { - scoped_ptr<CoreWlanApi> self(new CoreWlanApi); + std::unique_ptr<CoreWlanApi> self(new CoreWlanApi); if (self->Init()) return self.release();
diff --git a/content/browser/geolocation/wifi_data_provider_linux.cc b/content/browser/geolocation/wifi_data_provider_linux.cc index 7ec01b67f..f0afc66d 100644 --- a/content/browser/geolocation/wifi_data_provider_linux.cc +++ b/content/browser/geolocation/wifi_data_provider_linux.cc
@@ -11,8 +11,9 @@ #include <stddef.h> #include <stdint.h> +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/strings/string_number_conversions.h" #include "base/strings/utf_string_conversions.h" #include "content/browser/geolocation/wifi_data_provider_manager.h" @@ -74,7 +75,7 @@ // Internal method used by |GetAccessPointsForAdapter|, given a wifi access // point proxy retrieves the named property and returns it. Returns NULL in // a scoped_ptr if the property could not be read. - scoped_ptr<dbus::Response> GetAccessPointProperty( + std::unique_ptr<dbus::Response> GetAccessPointProperty( dbus::ObjectProxy* proxy, const std::string& property_name); @@ -149,10 +150,8 @@ dbus::MessageWriter builder(&method_call); builder.AppendString("org.freedesktop.NetworkManager.Device"); builder.AppendString("DeviceType"); - scoped_ptr<dbus::Response> response( - device_proxy->CallMethodAndBlock( - &method_call, - dbus::ObjectProxy::TIMEOUT_USE_DEFAULT)); + std::unique_ptr<dbus::Response> response(device_proxy->CallMethodAndBlock( + &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT)); if (!response) { LOG(WARNING) << "Failed to get the device type for " << device_path.value(); @@ -181,10 +180,9 @@ bool NetworkManagerWlanApi::GetAdapterDeviceList( std::vector<dbus::ObjectPath>* device_paths) { dbus::MethodCall method_call(kNetworkManagerInterface, "GetDevices"); - scoped_ptr<dbus::Response> response( + std::unique_ptr<dbus::Response> response( network_manager_proxy_->CallMethodAndBlock( - &method_call, - dbus::ObjectProxy::TIMEOUT_USE_DEFAULT)); + &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT)); if (!response) { LOG(WARNING) << "Failed to get the device list"; return false; @@ -209,10 +207,8 @@ dbus::MethodCall method_call( "org.freedesktop.NetworkManager.Device.Wireless", "GetAccessPoints"); - scoped_ptr<dbus::Response> response( - device_proxy->CallMethodAndBlock( - &method_call, - dbus::ObjectProxy::TIMEOUT_USE_DEFAULT)); + std::unique_ptr<dbus::Response> response(device_proxy->CallMethodAndBlock( + &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT)); if (!response) { LOG(WARNING) << "Failed to get access points data for " << adapter_path.value(); @@ -239,7 +235,7 @@ AccessPointData access_point_data; { - scoped_ptr<dbus::Response> response( + std::unique_ptr<dbus::Response> response( GetAccessPointProperty(access_point_proxy, "Ssid")); if (!response) continue; @@ -263,7 +259,7 @@ } { // Read the mac address - scoped_ptr<dbus::Response> response( + std::unique_ptr<dbus::Response> response( GetAccessPointProperty(access_point_proxy, "HwAddress")); if (!response) continue; @@ -287,7 +283,7 @@ } { // Read signal strength. - scoped_ptr<dbus::Response> response( + std::unique_ptr<dbus::Response> response( GetAccessPointProperty(access_point_proxy, "Strength")); if (!response) continue; @@ -303,7 +299,7 @@ } { // Read the channel - scoped_ptr<dbus::Response> response( + std::unique_ptr<dbus::Response> response( GetAccessPointProperty(access_point_proxy, "Frequency")); if (!response) continue; @@ -330,16 +326,16 @@ return true; } -scoped_ptr<dbus::Response> NetworkManagerWlanApi::GetAccessPointProperty( +std::unique_ptr<dbus::Response> NetworkManagerWlanApi::GetAccessPointProperty( dbus::ObjectProxy* access_point_proxy, const std::string& property_name) { dbus::MethodCall method_call(DBUS_INTERFACE_PROPERTIES, "Get"); dbus::MessageWriter builder(&method_call); builder.AppendString("org.freedesktop.NetworkManager.AccessPoint"); builder.AppendString(property_name); - scoped_ptr<dbus::Response> response = access_point_proxy->CallMethodAndBlock( - &method_call, - dbus::ObjectProxy::TIMEOUT_USE_DEFAULT); + std::unique_ptr<dbus::Response> response = + access_point_proxy->CallMethodAndBlock( + &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT); if (!response) { LOG(WARNING) << "Failed to get property for " << property_name; } @@ -361,7 +357,7 @@ WifiDataProviderCommon::WlanApiInterface* WifiDataProviderLinux::NewWlanApi() { - scoped_ptr<NetworkManagerWlanApi> wlan_api(new NetworkManagerWlanApi); + std::unique_ptr<NetworkManagerWlanApi> wlan_api(new NetworkManagerWlanApi); if (wlan_api->Init()) return wlan_api.release(); return NULL; @@ -376,7 +372,7 @@ WifiDataProviderCommon::WlanApiInterface* WifiDataProviderLinux::NewWlanApiForTesting(dbus::Bus* bus) { - scoped_ptr<NetworkManagerWlanApi> wlan_api(new NetworkManagerWlanApi); + std::unique_ptr<NetworkManagerWlanApi> wlan_api(new NetworkManagerWlanApi); if (wlan_api->InitWithBus(bus)) return wlan_api.release(); return NULL;
diff --git a/content/browser/geolocation/wifi_data_provider_linux_unittest.cc b/content/browser/geolocation/wifi_data_provider_linux_unittest.cc index 7f36a2c2..1b73ef6 100644 --- a/content/browser/geolocation/wifi_data_provider_linux_unittest.cc +++ b/content/browser/geolocation/wifi_data_provider_linux_unittest.cc
@@ -6,9 +6,10 @@ #include <stdint.h> +#include <memory> + #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/strings/utf_string_conversions.h" #include "content/public/test/test_browser_thread_bundle.h" #include "dbus/message.h" @@ -113,7 +114,7 @@ scoped_refptr<dbus::MockObjectProxy> mock_access_point_proxy_; scoped_refptr<dbus::MockObjectProxy> mock_device_proxy_; scoped_refptr<WifiDataProviderLinux> wifi_provider_linux_; - scoped_ptr<WifiDataProviderCommon::WlanApiInterface> wlan_api_; + std::unique_ptr<WifiDataProviderCommon::WlanApiInterface> wlan_api_; private: // Creates a response for |mock_network_manager_proxy_|. @@ -127,7 +128,7 @@ object_paths.push_back( dbus::ObjectPath("/org/freedesktop/NetworkManager/Devices/0")); - scoped_ptr<dbus::Response> response = dbus::Response::CreateEmpty(); + std::unique_ptr<dbus::Response> response = dbus::Response::CreateEmpty(); dbus::MessageWriter writer(response.get()); writer.AppendArrayOfObjectPaths(object_paths); return response.release(); @@ -148,7 +149,8 @@ if (reader.PopString(&interface_name) && reader.PopString(&property_name)) { // The device type is asked. Respond that the device type is wifi. - scoped_ptr<dbus::Response> response = dbus::Response::CreateEmpty(); + std::unique_ptr<dbus::Response> response = + dbus::Response::CreateEmpty(); dbus::MessageWriter writer(response.get()); // This matches NM_DEVICE_TYPE_WIFI in wifi_data_provider_linux.cc. const int kDeviceTypeWifi = 2; @@ -159,7 +161,7 @@ "org.freedesktop.NetworkManager.Device.Wireless" && method_call->GetMember() == "GetAccessPoints") { // The list of access points is asked. Return the object path. - scoped_ptr<dbus::Response> response = dbus::Response::CreateEmpty(); + std::unique_ptr<dbus::Response> response = dbus::Response::CreateEmpty(); dbus::MessageWriter writer(response.get()); std::vector<dbus::ObjectPath> object_paths; object_paths.push_back( @@ -184,7 +186,8 @@ std::string property_name; if (reader.PopString(&interface_name) && reader.PopString(&property_name)) { - scoped_ptr<dbus::Response> response = dbus::Response::CreateEmpty(); + std::unique_ptr<dbus::Response> response = + dbus::Response::CreateEmpty(); dbus::MessageWriter writer(response.get()); if (property_name == "Ssid") {
diff --git a/content/browser/geolocation/wifi_data_provider_win.cc b/content/browser/geolocation/wifi_data_provider_win.cc index 7d9db58..c5eca3d 100644 --- a/content/browser/geolocation/wifi_data_provider_win.cc +++ b/content/browser/geolocation/wifi_data_provider_win.cc
@@ -155,7 +155,7 @@ DWORD buffer_size, DWORD* bytes_out); bool ResizeBuffer(int requested_size, - scoped_ptr<BYTE, base::FreeDeleter>* buffer); + std::unique_ptr<BYTE, base::FreeDeleter>* buffer); // Gets the system directory and appends a trailing slash if not already // present. bool GetSystemDirectory(base::string16* path); @@ -471,7 +471,7 @@ WifiData::AccessPointDataSet* data) { DCHECK(data); - scoped_ptr<BYTE, base::FreeDeleter> buffer( + std::unique_ptr<BYTE, base::FreeDeleter> buffer( static_cast<BYTE*>(malloc(oid_buffer_size_))); if (buffer == NULL) { return false; @@ -601,7 +601,7 @@ } bool ResizeBuffer(int requested_size, - scoped_ptr<BYTE, base::FreeDeleter>* buffer) { + std::unique_ptr<BYTE, base::FreeDeleter>* buffer) { DCHECK_GT(requested_size, 0); DCHECK(buffer); if (requested_size > kMaximumBufferSize) { @@ -621,7 +621,7 @@ if (buffer_size == 0) { return false; } - scoped_ptr<base::char16[]> buffer(new base::char16[buffer_size]); + std::unique_ptr<base::char16[]> buffer(new base::char16[buffer_size]); // Return value excludes terminating NULL. int characters_written = ::GetSystemDirectory(buffer.get(), buffer_size);
diff --git a/content/browser/gpu/browser_gpu_channel_host_factory.cc b/content/browser/gpu/browser_gpu_channel_host_factory.cc index 6108216..bc0a4c77 100644 --- a/content/browser/gpu/browser_gpu_channel_host_factory.cc +++ b/content/browser/gpu/browser_gpu_channel_host_factory.cc
@@ -268,11 +268,11 @@ return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); } -scoped_ptr<base::SharedMemory> +std::unique_ptr<base::SharedMemory> BrowserGpuChannelHostFactory::AllocateSharedMemory(size_t size) { - scoped_ptr<base::SharedMemory> shm(new base::SharedMemory()); + std::unique_ptr<base::SharedMemory> shm(new base::SharedMemory()); if (!shm->CreateAnonymous(size)) - return scoped_ptr<base::SharedMemory>(); + return std::unique_ptr<base::SharedMemory>(); return shm; }
diff --git a/content/browser/gpu/browser_gpu_channel_host_factory.h b/content/browser/gpu/browser_gpu_channel_host_factory.h index 618e1c2..1dae42d 100644 --- a/content/browser/gpu/browser_gpu_channel_host_factory.h +++ b/content/browser/gpu/browser_gpu_channel_host_factory.h
@@ -9,11 +9,11 @@ #include <stdint.h> #include <map> +#include <memory> #include <vector> #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "build/build_config.h" #include "content/common/content_export.h" #include "content/common/gpu_process_launch_causes.h" @@ -33,7 +33,8 @@ // Overridden from gpu::GpuChannelHostFactory: bool IsMainThread() override; scoped_refptr<base::SingleThreadTaskRunner> GetIOThreadTaskRunner() override; - scoped_ptr<base::SharedMemory> AllocateSharedMemory(size_t size) override; + std::unique_ptr<base::SharedMemory> AllocateSharedMemory( + size_t size) override; int GpuProcessHostId() { return gpu_host_id_; } #if !defined(OS_ANDROID) @@ -64,9 +65,9 @@ const int gpu_client_id_; const uint64_t gpu_client_tracing_id_; - scoped_ptr<base::WaitableEvent> shutdown_event_; + std::unique_ptr<base::WaitableEvent> shutdown_event_; scoped_refptr<gpu::GpuChannelHost> gpu_channel_; - scoped_ptr<BrowserGpuMemoryBufferManager> gpu_memory_buffer_manager_; + std::unique_ptr<BrowserGpuMemoryBufferManager> gpu_memory_buffer_manager_; int gpu_host_id_; scoped_refptr<EstablishRequest> pending_request_; std::vector<base::Closure> established_callbacks_;
diff --git a/content/browser/gpu/browser_gpu_memory_buffer_manager.cc b/content/browser/gpu/browser_gpu_memory_buffer_manager.cc index 7eba55f..c8e49cb 100644 --- a/content/browser/gpu/browser_gpu_memory_buffer_manager.cc +++ b/content/browser/gpu/browser_gpu_memory_buffer_manager.cc
@@ -148,7 +148,7 @@ gfx::BufferUsage usage; int client_id; int surface_id; - scoped_ptr<gfx::GpuMemoryBuffer> result; + std::unique_ptr<gfx::GpuMemoryBuffer> result; }; struct BrowserGpuMemoryBufferManager::CreateGpuMemoryBufferFromHandleRequest @@ -236,7 +236,7 @@ return GL_TEXTURE_2D; } -scoped_ptr<gfx::GpuMemoryBuffer> +std::unique_ptr<gfx::GpuMemoryBuffer> BrowserGpuMemoryBufferManager::AllocateGpuMemoryBuffer(const gfx::Size& size, gfx::BufferFormat format, gfx::BufferUsage usage, @@ -244,7 +244,7 @@ return AllocateGpuMemoryBufferForSurface(size, format, usage, surface_id); } -scoped_ptr<gfx::GpuMemoryBuffer> +std::unique_ptr<gfx::GpuMemoryBuffer> BrowserGpuMemoryBufferManager::CreateGpuMemoryBufferFromHandle( const gfx::GpuMemoryBufferHandle& handle, const gfx::Size& size, @@ -408,7 +408,7 @@ native_configurations_.end(); } -scoped_ptr<gfx::GpuMemoryBuffer> +std::unique_ptr<gfx::GpuMemoryBuffer> BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferForSurface( const gfx::Size& size, gfx::BufferFormat format,
diff --git a/content/browser/gpu/browser_gpu_memory_buffer_manager.h b/content/browser/gpu/browser_gpu_memory_buffer_manager.h index 946ccf0e..e41b3e50 100644 --- a/content/browser/gpu/browser_gpu_memory_buffer_manager.h +++ b/content/browser/gpu/browser_gpu_memory_buffer_manager.h
@@ -62,12 +62,12 @@ gfx::BufferUsage usage); // Overridden from gpu::GpuMemoryBufferManager: - scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBuffer( + std::unique_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBuffer( const gfx::Size& size, gfx::BufferFormat format, gfx::BufferUsage usage, int32_t surface_id) override; - scoped_ptr<gfx::GpuMemoryBuffer> CreateGpuMemoryBufferFromHandle( + std::unique_ptr<gfx::GpuMemoryBuffer> CreateGpuMemoryBufferFromHandle( const gfx::GpuMemoryBufferHandle& handle, const gfx::Size& size, gfx::BufferFormat format) override; @@ -134,7 +134,7 @@ int client_id, const CreateCallback& callback)>; - scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBufferForSurface( + std::unique_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBufferForSurface( const gfx::Size& size, gfx::BufferFormat format, gfx::BufferUsage usage,
diff --git a/content/browser/gpu/gpu_data_manager_impl.h b/content/browser/gpu/gpu_data_manager_impl.h index 2bb437a..a6a8fcf 100644 --- a/content/browser/gpu/gpu_data_manager_impl.h +++ b/content/browser/gpu/gpu_data_manager_impl.h
@@ -8,13 +8,13 @@ #include <stddef.h> #include <stdint.h> +#include <memory> #include <string> #include "base/compiler_specific.h" #include "base/files/file_path.h" #include "base/logging.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/singleton.h" #include "base/process/kill.h" #include "base/synchronization/lock.h" @@ -213,7 +213,7 @@ ~GpuDataManagerImpl() override; mutable base::Lock lock_; - scoped_ptr<GpuDataManagerImplPrivate> private_; + std::unique_ptr<GpuDataManagerImplPrivate> private_; DISALLOW_COPY_AND_ASSIGN(GpuDataManagerImpl); };
diff --git a/content/browser/gpu/gpu_data_manager_impl_private.h b/content/browser/gpu/gpu_data_manager_impl_private.h index 420fc7c..2bf6269 100644 --- a/content/browser/gpu/gpu_data_manager_impl_private.h +++ b/content/browser/gpu/gpu_data_manager_impl_private.h
@@ -234,8 +234,8 @@ gpu::GPUInfo gpu_info_; - scoped_ptr<gpu::GpuBlacklist> gpu_blacklist_; - scoped_ptr<gpu::GpuDriverBugList> gpu_driver_bug_list_; + std::unique_ptr<gpu::GpuBlacklist> gpu_blacklist_; + std::unique_ptr<gpu::GpuDriverBugList> gpu_driver_bug_list_; const scoped_refptr<GpuDataManagerObserverList> observer_list_;
diff --git a/content/browser/gpu/gpu_internals_ui.cc b/content/browser/gpu/gpu_internals_ui.cc index 34ba18d..6bc08b7 100644 --- a/content/browser/gpu/gpu_internals_ui.cc +++ b/content/browser/gpu/gpu_internals_ui.cc
@@ -203,7 +203,7 @@ basic_info->Append(NewDescriptionValuePair("Window manager", ui::GuessWindowManagerName())); { - scoped_ptr<base::Environment> env(base::Environment::Create()); + std::unique_ptr<base::Environment> env(base::Environment::Create()); std::string value; const char kXDGCurrentDesktop[] = "XDG_CURRENT_DESKTOP"; if (env->GetVar(kXDGCurrentDesktop, &value)) @@ -240,7 +240,7 @@ info->Set("basic_info", basic_info); #if defined(OS_WIN) - scoped_ptr<base::Value> dx_info = base::Value::CreateNullValue(); + std::unique_ptr<base::Value> dx_info = base::Value::CreateNullValue(); if (gpu_info.dx_diagnostics.children.size()) dx_info.reset(DxDiagNodeToList(gpu_info.dx_diagnostics)); info->Set("diagnostics", std::move(dx_info)); @@ -501,8 +501,8 @@ void GpuMessageHandler::OnGpuInfoUpdate() { // Get GPU Info. - scoped_ptr<base::DictionaryValue> gpu_info_val(GpuInfoAsDictionaryValue()); - + std::unique_ptr<base::DictionaryValue> gpu_info_val( + GpuInfoAsDictionaryValue()); // Add in blacklisting features base::DictionaryValue* feature_status = new base::DictionaryValue;
diff --git a/content/browser/gpu/gpu_ipc_browsertests.cc b/content/browser/gpu/gpu_ipc_browsertests.cc index fd0ba69..d218114 100644 --- a/content/browser/gpu/gpu_ipc_browsertests.cc +++ b/content/browser/gpu/gpu_ipc_browsertests.cc
@@ -3,6 +3,7 @@ // found in the LICENSE file. #include "base/command_line.h" +#include "base/memory/ptr_util.h" #include "base/run_loop.h" #include "build/build_config.h" #include "content/browser/gpu/browser_gpu_channel_host_factory.h" @@ -28,7 +29,7 @@ content:: CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; -scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateContext( +std::unique_ptr<WebGraphicsContext3DCommandBufferImpl> CreateContext( gpu::GpuChannelHost* gpu_channel_host) { // This is for an offscreen context, so the default framebuffer doesn't need // any alpha, depth, stencil, antialiasing. @@ -41,7 +42,7 @@ attributes.bind_generates_resource = false; bool share_resources = false; bool automatic_flushes = false; - return make_scoped_ptr( + return base::WrapUnique( WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( gpu_channel_host, attributes, gfx::PreferIntegratedGpu, share_resources, automatic_flushes, GURL(),
diff --git a/content/browser/gpu/gpu_process_host.h b/content/browser/gpu/gpu_process_host.h index 1d8053b..1bbdb19 100644 --- a/content/browser/gpu/gpu_process_host.h +++ b/content/browser/gpu/gpu_process_host.h
@@ -8,6 +8,7 @@ #include <stdint.h> #include <map> +#include <memory> #include <queue> #include <set> #include <string> @@ -15,7 +16,6 @@ #include "base/callback.h" #include "base/containers/hash_tables.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/threading/non_thread_safe.h" #include "base/time/time.h" @@ -249,7 +249,7 @@ // true. gpu::GPUInfo gpu_info_; - scoped_ptr<base::Thread> in_process_gpu_thread_; + std::unique_ptr<base::Thread> in_process_gpu_thread_; // Whether we actually launched a GPU process. bool process_launched_; @@ -272,7 +272,7 @@ static bool crashed_before_; static int swiftshader_crash_count_; - scoped_ptr<BrowserChildProcessHostImpl> process_; + std::unique_ptr<BrowserChildProcessHostImpl> process_; // Track the URLs of the pages which have live offscreen contexts, // assumed to be associated with untrusted content such as WebGL. @@ -293,7 +293,7 @@ // Browser-side Mojo endpoint which sets up a Mojo channel with the child // process and contains the browser's ServiceRegistry. - scoped_ptr<MojoApplicationHost> mojo_application_host_; + std::unique_ptr<MojoApplicationHost> mojo_application_host_; DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); };
diff --git a/content/browser/gpu/shader_disk_cache.cc b/content/browser/gpu/shader_disk_cache.cc index c582829..e31af92 100644 --- a/content/browser/gpu/shader_disk_cache.cc +++ b/content/browser/gpu/shader_disk_cache.cc
@@ -24,8 +24,8 @@ entry->Close(); } -void FreeDiskCacheIterator(scoped_ptr<disk_cache::Backend::Iterator> iterator) { -} +void FreeDiskCacheIterator( + std::unique_ptr<disk_cache::Backend::Iterator> iterator) {} } // namespace @@ -99,7 +99,7 @@ base::WeakPtr<ShaderDiskCache> cache_; OpType op_type_; - scoped_ptr<disk_cache::Backend::Iterator> iter_; + std::unique_ptr<disk_cache::Backend::Iterator> iter_; scoped_refptr<net::IOBufferWithSize> buf_; int host_id_; disk_cache::Entry* entry_;
diff --git a/content/browser/gpu/shader_disk_cache.h b/content/browser/gpu/shader_disk_cache.h index e53cb50..e86b4e6 100644 --- a/content/browser/gpu/shader_disk_cache.h +++ b/content/browser/gpu/shader_disk_cache.h
@@ -90,7 +90,7 @@ net::CompletionCallback available_callback_; net::CompletionCallback cache_complete_callback_; - scoped_ptr<disk_cache::Backend> backend_; + std::unique_ptr<disk_cache::Backend> backend_; scoped_refptr<ShaderDiskReadHelper> helper_; std::map<void*, scoped_refptr<ShaderDiskCacheEntry> > entry_map_;
diff --git a/content/browser/host_zoom_level_context.cc b/content/browser/host_zoom_level_context.cc index 56f848db..ee758b8 100644 --- a/content/browser/host_zoom_level_context.cc +++ b/content/browser/host_zoom_level_context.cc
@@ -13,7 +13,7 @@ namespace content { HostZoomLevelContext::HostZoomLevelContext( - scoped_ptr<ZoomLevelDelegate> zoom_level_delegate) + std::unique_ptr<ZoomLevelDelegate> zoom_level_delegate) : host_zoom_map_impl_(new HostZoomMapImpl()), zoom_level_delegate_(std::move(zoom_level_delegate)) { if (zoom_level_delegate_)
diff --git a/content/browser/host_zoom_level_context.h b/content/browser/host_zoom_level_context.h index e45222f..3120c032 100644 --- a/content/browser/host_zoom_level_context.h +++ b/content/browser/host_zoom_level_context.h
@@ -5,9 +5,10 @@ #ifndef CONTENT_BROWSER_HOST_ZOOM_LEVEL_CONTEXT_H_ #define CONTENT_BROWSER_HOST_ZOOM_LEVEL_CONTEXT_H_ +#include <memory> + #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/host_zoom_map_impl.h" #include "content/public/browser/zoom_level_delegate.h" @@ -24,7 +25,7 @@ HostZoomLevelContextDeleter> { public: explicit HostZoomLevelContext( - scoped_ptr<ZoomLevelDelegate> zoom_level_delegate); + std::unique_ptr<ZoomLevelDelegate> zoom_level_delegate); HostZoomMap* GetHostZoomMap() const { return host_zoom_map_impl_.get(); } ZoomLevelDelegate* GetZoomLevelDelegate() const { @@ -42,10 +43,10 @@ void DeleteOnCorrectThread() const; - scoped_ptr<HostZoomMapImpl> host_zoom_map_impl_; + std::unique_ptr<HostZoomMapImpl> host_zoom_map_impl_; // Release the delegate before the HostZoomMap, in case it is carrying // any HostZoomMap::Subscription pointers. - scoped_ptr<ZoomLevelDelegate> zoom_level_delegate_; + std::unique_ptr<ZoomLevelDelegate> zoom_level_delegate_; DISALLOW_COPY_AND_ASSIGN(HostZoomLevelContext); };
diff --git a/content/browser/host_zoom_map_impl.cc b/content/browser/host_zoom_map_impl.cc index 298a66a..cda61f9 100644 --- a/content/browser/host_zoom_map_impl.cc +++ b/content/browser/host_zoom_map_impl.cc
@@ -281,7 +281,7 @@ default_zoom_level_ = level; } -scoped_ptr<HostZoomMap::Subscription> +std::unique_ptr<HostZoomMap::Subscription> HostZoomMapImpl::AddZoomLevelChangedCallback( const ZoomLevelChangedCallback& callback) { return zoom_level_changed_callbacks_.Add(callback);
diff --git a/content/browser/host_zoom_map_impl.h b/content/browser/host_zoom_map_impl.h index e27402d5..ea323f3 100644 --- a/content/browser/host_zoom_map_impl.h +++ b/content/browser/host_zoom_map_impl.h
@@ -56,7 +56,7 @@ int render_view_id) override; double GetDefaultZoomLevel() const override; void SetDefaultZoomLevel(double level) override; - scoped_ptr<Subscription> AddZoomLevelChangedCallback( + std::unique_ptr<Subscription> AddZoomLevelChangedCallback( const ZoomLevelChangedCallback& callback) override; // Returns the current zoom level for the specified WebContents. This may
diff --git a/content/browser/indexed_db/indexed_db_active_blob_registry_unittest.cc b/content/browser/indexed_db/indexed_db_active_blob_registry_unittest.cc index 3d6023fc..7537736 100644 --- a/content/browser/indexed_db/indexed_db_active_blob_registry_unittest.cc +++ b/content/browser/indexed_db/indexed_db_active_blob_registry_unittest.cc
@@ -117,7 +117,7 @@ scoped_refptr<base::TestSimpleTaskRunner> task_runner_; scoped_refptr<RegistryTestMockFactory> factory_; scoped_refptr<MockIDBBackingStore> backing_store_; - scoped_ptr<IndexedDBActiveBlobRegistry> registry_; + std::unique_ptr<IndexedDBActiveBlobRegistry> registry_; DISALLOW_COPY_AND_ASSIGN(IndexedDBActiveBlobRegistryTest); };
diff --git a/content/browser/indexed_db/indexed_db_backing_store.cc b/content/browser/indexed_db/indexed_db_backing_store.cc index 71ad4e1c..b0399d9 100644 --- a/content/browser/indexed_db/indexed_db_backing_store.cc +++ b/content/browser/indexed_db/indexed_db_backing_store.cc
@@ -388,7 +388,7 @@ DatabaseNameKey::EncodeMinKeyForOrigin(origin_identifier_); const std::string stop_key = DatabaseNameKey::EncodeStopKeyForOrigin(origin_identifier_); - scoped_ptr<LevelDBIterator> it = db_->CreateIterator(); + std::unique_ptr<LevelDBIterator> it = db_->CreateIterator(); for (s = it->Seek(start_key); s.ok() && it->IsValid() && CompareKeys(it->Key(), stop_key) < 0; s = it->Next()) { @@ -487,7 +487,7 @@ DefaultLevelDBFactory() {} leveldb::Status OpenLevelDB(const base::FilePath& file_name, const LevelDBComparator* comparator, - scoped_ptr<LevelDBDatabase>* db, + std::unique_ptr<LevelDBDatabase>* db, bool* is_disk_full) override { return LevelDBDatabase::Open(file_name, comparator, db, is_disk_full); } @@ -748,8 +748,8 @@ const GURL& origin_url, const base::FilePath& blob_path, net::URLRequestContext* request_context, - scoped_ptr<LevelDBDatabase> db, - scoped_ptr<LevelDBComparator> comparator, + std::unique_ptr<LevelDBDatabase> db, + std::unique_ptr<LevelDBComparator> comparator, base::SequencedTaskRunner* task_runner) : indexed_db_factory_(indexed_db_factory), origin_url_(origin_url), @@ -929,7 +929,7 @@ if (file_size == file.Read(0, &bytes[0], file_size)) { std::string input_js(&bytes[0], file_size); base::JSONReader reader; - scoped_ptr<base::Value> val(reader.ReadToValue(input_js)); + std::unique_ptr<base::Value> val(reader.ReadToValue(input_js)); if (val && val->GetType() == base::Value::TYPE_DICTIONARY) { base::DictionaryValue* dict_val = static_cast<base::DictionaryValue*>(val.get()); @@ -987,7 +987,7 @@ *status = leveldb::Status::OK(); - scoped_ptr<LevelDBComparator> comparator(new Comparator()); + std::unique_ptr<LevelDBComparator> comparator(new Comparator()); if (!base::IsStringASCII(path_base.AsUTF8Unsafe())) { HistogramOpenStatus(INDEXED_DB_BACKING_STORE_OPEN_ATTEMPT_NON_ASCII, @@ -1015,7 +1015,7 @@ return scoped_refptr<IndexedDBBackingStore>(); } - scoped_ptr<LevelDBDatabase> db; + std::unique_ptr<LevelDBDatabase> db; *status = leveldb_factory->OpenLevelDB( file_path, comparator.get(), &db, is_disk_full); @@ -1135,8 +1135,8 @@ leveldb::Status* status) { IDB_TRACE("IndexedDBBackingStore::OpenInMemory"); - scoped_ptr<LevelDBComparator> comparator(new Comparator()); - scoped_ptr<LevelDBDatabase> db = + std::unique_ptr<LevelDBComparator> comparator(new Comparator()); + std::unique_ptr<LevelDBDatabase> db = LevelDBDatabase::OpenInMemory(comparator.get()); if (!db) { LOG(ERROR) << "LevelDBDatabase::OpenInMemory failed."; @@ -1161,8 +1161,8 @@ const GURL& origin_url, const base::FilePath& blob_path, net::URLRequestContext* request_context, - scoped_ptr<LevelDBDatabase> db, - scoped_ptr<LevelDBComparator> comparator, + std::unique_ptr<LevelDBDatabase> db, + std::unique_ptr<LevelDBComparator> comparator, base::SequencedTaskRunner* task_runner, leveldb::Status* status) { // TODO(jsbell): Handle comparator name changes. @@ -1195,7 +1195,7 @@ DCHECK(found_names.empty()); - scoped_ptr<LevelDBIterator> it = db_->CreateIterator(); + std::unique_ptr<LevelDBIterator> it = db_->CreateIterator(); for (*s = it->Seek(start_key); s->ok() && it->IsValid() && CompareKeys(it->Key(), stop_key) < 0; *s = it->Next()) { @@ -1378,7 +1378,7 @@ const std::string& begin, const std::string& end, bool upper_open) { - scoped_ptr<LevelDBIterator> it = transaction->CreateIterator(); + std::unique_ptr<LevelDBIterator> it = transaction->CreateIterator(); leveldb::Status s; for (s = it->Seek(begin); s.ok() && it->IsValid() && (upper_open ? CompareKeys(it->Key(), end) < 0 @@ -1395,7 +1395,8 @@ const std::string& start_key, const std::string& end_key, bool upper_open) { - scoped_ptr<LevelDBIterator> it = transaction->transaction()->CreateIterator(); + std::unique_ptr<LevelDBIterator> it = + transaction->transaction()->CreateIterator(); leveldb::Status s = it->Seek(start_key); for (; s.ok() && it->IsValid() && (upper_open ? CompareKeys(it->Key(), end_key) < 0 @@ -1430,7 +1431,7 @@ leveldb::Status IndexedDBBackingStore::DeleteDatabase( const base::string16& name) { IDB_TRACE("IndexedDBBackingStore::DeleteDatabase"); - scoped_ptr<LevelDBDirectTransaction> transaction = + std::unique_ptr<LevelDBDirectTransaction> transaction = LevelDBDirectTransaction::Create(db_.get()); leveldb::Status s; @@ -1449,7 +1450,7 @@ metadata.id + 1, DatabaseMetaDataKey::ORIGIN_NAME); { IDB_TRACE("IndexedDBBackingStore::DeleteDatabase.DeleteEntries"); - scoped_ptr<LevelDBIterator> it = db_->CreateIterator(); + std::unique_ptr<LevelDBIterator> it = db_->CreateIterator(); for (s = it->Seek(start_key); s.ok() && it->IsValid() && CompareKeys(it->Key(), stop_key) < 0; s = it->Next()) @@ -1525,7 +1526,7 @@ DCHECK(object_stores->empty()); - scoped_ptr<LevelDBIterator> it = db_->CreateIterator(); + std::unique_ptr<LevelDBIterator> it = db_->CreateIterator(); leveldb::Status s = it->Seek(start_key); while (s.ok() && it->IsValid() && CompareKeys(it->Key(), stop_key) < 0) { StringPiece slice(it->Key()); @@ -2008,25 +2009,17 @@ int64_t object_store_id, const IndexedDBKeyRange& key_range) { leveldb::Status s; - scoped_ptr<IndexedDBBackingStore::Cursor> start_cursor = - OpenObjectStoreCursor(transaction, - database_id, - object_store_id, - key_range, - blink::WebIDBCursorDirectionNext, - &s); + std::unique_ptr<IndexedDBBackingStore::Cursor> start_cursor = + OpenObjectStoreCursor(transaction, database_id, object_store_id, + key_range, blink::WebIDBCursorDirectionNext, &s); if (!s.ok()) return s; if (!start_cursor) return leveldb::Status::OK(); // Empty range == delete success. - scoped_ptr<IndexedDBBackingStore::Cursor> end_cursor = - OpenObjectStoreCursor(transaction, - database_id, - object_store_id, - key_range, - blink::WebIDBCursorDirectionPrev, - &s); + std::unique_ptr<IndexedDBBackingStore::Cursor> end_cursor = + OpenObjectStoreCursor(transaction, database_id, object_store_id, + key_range, blink::WebIDBCursorDirectionPrev, &s); if (!s.ok()) return s; @@ -2109,7 +2102,7 @@ const std::string stop_key = ObjectStoreDataKey::Encode(database_id, object_store_id, MaxIDBKey()); - scoped_ptr<LevelDBIterator> it = leveldb_transaction->CreateIterator(); + std::unique_ptr<LevelDBIterator> it = leveldb_transaction->CreateIterator(); int64_t max_numeric_key = 0; for (s = it->Seek(start_key); @@ -2121,7 +2114,7 @@ INTERNAL_READ_ERROR_UNTESTED(GET_KEY_GENERATOR_CURRENT_NUMBER); return InternalInconsistencyStatus(); } - scoped_ptr<IndexedDBKey> user_key = data_key.user_key(); + std::unique_ptr<IndexedDBKey> user_key = data_key.user_key(); if (user_key->type() == blink::WebIDBKeyTypeNumber) { int64_t n = static_cast<int64_t>(user_key->number()); if (n > max_numeric_key) @@ -2226,7 +2219,7 @@ FROM_HERE, base::Bind(&ChainedBlobWriterImpl::WriteNextFile, this)); } - void set_delegate(scoped_ptr<FileWriterDelegate> delegate) override { + void set_delegate(std::unique_ptr<FileWriterDelegate> delegate) override { delegate_.reset(delegate.release()); } @@ -2287,7 +2280,7 @@ int64_t database_id_; IndexedDBBackingStore* backing_store_; scoped_refptr<IndexedDBBackingStore::BlobWriteCallback> callback_; - scoped_ptr<FileWriterDelegate> delegate_; + std::unique_ptr<FileWriterDelegate> delegate_; bool aborted_; DISALLOW_COPY_AND_ASSIGN(ChainedBlobWriterImpl); @@ -2342,18 +2335,17 @@ const base::Time& last_modified, net::URLRequestContext* request_context) { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); - scoped_ptr<storage::FileStreamWriter> writer( + std::unique_ptr<storage::FileStreamWriter> writer( storage::FileStreamWriter::CreateForLocalFile( - task_runner_.get(), - file_path, - 0, + task_runner_.get(), file_path, 0, storage::FileStreamWriter::CREATE_NEW_FILE)); - scoped_ptr<FileWriterDelegate> delegate(new FileWriterDelegate( + std::unique_ptr<FileWriterDelegate> delegate(new FileWriterDelegate( std::move(writer), storage::FlushPolicy::FLUSH_ON_COMPLETION)); DCHECK(blob_url.is_valid()); - scoped_ptr<net::URLRequest> blob_request(request_context->CreateRequest( - blob_url, net::DEFAULT_PRIORITY, delegate.get())); + std::unique_ptr<net::URLRequest> blob_request( + request_context->CreateRequest(blob_url, net::DEFAULT_PRIORITY, + delegate.get())); this->file_path_ = file_path; this->last_modified_ = last_modified; @@ -2579,7 +2571,7 @@ DCHECK(indexes->empty()); - scoped_ptr<LevelDBIterator> it = db_->CreateIterator(); + std::unique_ptr<LevelDBIterator> it = db_->CreateIterator(); leveldb::Status s = it->Seek(start_key); while (s.ok() && it->IsValid() && CompareKeys(it->Key(), stop_key) < 0) { StringPiece slice(it->Key()); @@ -2914,7 +2906,7 @@ const std::string& target, std::string* found_key, leveldb::Status* s) { - scoped_ptr<LevelDBIterator> it = transaction->CreateIterator(); + std::unique_ptr<LevelDBIterator> it = transaction->CreateIterator(); *s = it->Seek(target); if (!s->ok()) return false; @@ -2984,7 +2976,7 @@ LevelDBTransaction* leveldb_transaction = transaction->transaction(); const std::string leveldb_key = IndexDataKey::Encode(database_id, object_store_id, index_id, key); - scoped_ptr<LevelDBIterator> it = leveldb_transaction->CreateIterator(); + std::unique_ptr<LevelDBIterator> it = leveldb_transaction->CreateIterator(); leveldb::Status s = it->Seek(leveldb_key); if (!s.ok()) { INTERNAL_READ_ERROR_UNTESTED(FIND_KEY_IN_INDEX); @@ -3032,7 +3024,7 @@ int64_t object_store_id, int64_t index_id, const IndexedDBKey& key, - scoped_ptr<IndexedDBKey>* primary_key) { + std::unique_ptr<IndexedDBKey>* primary_key) { IDB_TRACE("IndexedDBBackingStore::GetPrimaryKeyViaIndex"); if (!KeyPrefix::ValidIds(database_id, object_store_id, index_id)) return InvalidDBKeyStatus(); @@ -3070,7 +3062,7 @@ int64_t object_store_id, int64_t index_id, const IndexedDBKey& index_key, - scoped_ptr<IndexedDBKey>* found_primary_key, + std::unique_ptr<IndexedDBKey>* found_primary_key, bool* exists) { IDB_TRACE("IndexedDBBackingStore::KeyExistsInIndex"); if (!KeyPrefix::ValidIds(database_id, object_store_id, index_id)) @@ -3567,7 +3559,7 @@ : IndexedDBBackingStore::Cursor(other), primary_key_(new IndexedDBKey(*other->primary_key_)) {} - scoped_ptr<IndexedDBKey> primary_key_; + std::unique_ptr<IndexedDBKey> primary_key_; DISALLOW_COPY_AND_ASSIGN(IndexKeyCursorImpl); }; @@ -3682,7 +3674,7 @@ current_value_(other->current_value_), primary_leveldb_key_(other->primary_leveldb_key_) {} - scoped_ptr<IndexedDBKey> primary_key_; + std::unique_ptr<IndexedDBKey> primary_key_; IndexedDBValue current_value_; std::string primary_leveldb_key_; @@ -3902,7 +3894,7 @@ return true; } -scoped_ptr<IndexedDBBackingStore::Cursor> +std::unique_ptr<IndexedDBBackingStore::Cursor> IndexedDBBackingStore::OpenObjectStoreCursor( IndexedDBBackingStore::Transaction* transaction, int64_t database_id, @@ -3920,16 +3912,16 @@ range, direction, &cursor_options)) - return scoped_ptr<IndexedDBBackingStore::Cursor>(); - scoped_ptr<ObjectStoreCursorImpl> cursor(new ObjectStoreCursorImpl( + return std::unique_ptr<IndexedDBBackingStore::Cursor>(); + std::unique_ptr<ObjectStoreCursorImpl> cursor(new ObjectStoreCursorImpl( this, transaction, database_id, cursor_options)); if (!cursor->FirstSeek(s)) - return scoped_ptr<IndexedDBBackingStore::Cursor>(); + return std::unique_ptr<IndexedDBBackingStore::Cursor>(); return std::move(cursor); } -scoped_ptr<IndexedDBBackingStore::Cursor> +std::unique_ptr<IndexedDBBackingStore::Cursor> IndexedDBBackingStore::OpenObjectStoreKeyCursor( IndexedDBBackingStore::Transaction* transaction, int64_t database_id, @@ -3947,16 +3939,16 @@ range, direction, &cursor_options)) - return scoped_ptr<IndexedDBBackingStore::Cursor>(); - scoped_ptr<ObjectStoreKeyCursorImpl> cursor(new ObjectStoreKeyCursorImpl( + return std::unique_ptr<IndexedDBBackingStore::Cursor>(); + std::unique_ptr<ObjectStoreKeyCursorImpl> cursor(new ObjectStoreKeyCursorImpl( this, transaction, database_id, cursor_options)); if (!cursor->FirstSeek(s)) - return scoped_ptr<IndexedDBBackingStore::Cursor>(); + return std::unique_ptr<IndexedDBBackingStore::Cursor>(); return std::move(cursor); } -scoped_ptr<IndexedDBBackingStore::Cursor> +std::unique_ptr<IndexedDBBackingStore::Cursor> IndexedDBBackingStore::OpenIndexKeyCursor( IndexedDBBackingStore::Transaction* transaction, int64_t database_id, @@ -3976,16 +3968,16 @@ range, direction, &cursor_options)) - return scoped_ptr<IndexedDBBackingStore::Cursor>(); - scoped_ptr<IndexKeyCursorImpl> cursor( + return std::unique_ptr<IndexedDBBackingStore::Cursor>(); + std::unique_ptr<IndexKeyCursorImpl> cursor( new IndexKeyCursorImpl(this, transaction, database_id, cursor_options)); if (!cursor->FirstSeek(s)) - return scoped_ptr<IndexedDBBackingStore::Cursor>(); + return std::unique_ptr<IndexedDBBackingStore::Cursor>(); return std::move(cursor); } -scoped_ptr<IndexedDBBackingStore::Cursor> +std::unique_ptr<IndexedDBBackingStore::Cursor> IndexedDBBackingStore::OpenIndexCursor( IndexedDBBackingStore::Transaction* transaction, int64_t database_id, @@ -4004,11 +3996,11 @@ range, direction, &cursor_options)) - return scoped_ptr<IndexedDBBackingStore::Cursor>(); - scoped_ptr<IndexCursorImpl> cursor( + return std::unique_ptr<IndexedDBBackingStore::Cursor>(); + std::unique_ptr<IndexCursorImpl> cursor( new IndexCursorImpl(this, transaction, database_id, cursor_options)); if (!cursor->FirstSeek(s)) - return scoped_ptr<IndexedDBBackingStore::Cursor>(); + return std::unique_ptr<IndexedDBBackingStore::Cursor>(); return std::move(cursor); } @@ -4384,9 +4376,9 @@ handles_.swap(*handles); } -scoped_ptr<IndexedDBBackingStore::BlobChangeRecord> +std::unique_ptr<IndexedDBBackingStore::BlobChangeRecord> IndexedDBBackingStore::BlobChangeRecord::Clone() const { - scoped_ptr<IndexedDBBackingStore::BlobChangeRecord> record( + std::unique_ptr<IndexedDBBackingStore::BlobChangeRecord> record( new BlobChangeRecord(key_, object_store_id_)); record->blob_info_ = blob_info_;
diff --git a/content/browser/indexed_db/indexed_db_backing_store.h b/content/browser/indexed_db/indexed_db_backing_store.h index f1fecbd..43e4595c 100644 --- a/content/browser/indexed_db/indexed_db_backing_store.h +++ b/content/browser/indexed_db/indexed_db_backing_store.h
@@ -9,6 +9,7 @@ #include <stdint.h> #include <map> +#include <memory> #include <set> #include <string> #include <utility> @@ -17,7 +18,6 @@ #include "base/files/file_path.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_vector.h" #include "base/strings/string_piece.h" #include "base/time/time.h" @@ -110,7 +110,7 @@ return blob_info_; } void SetHandles(ScopedVector<storage::BlobDataHandle>* handles); - scoped_ptr<BlobChangeRecord> Clone() const; + std::unique_ptr<BlobChangeRecord> Clone() const; private: std::string key_; @@ -211,7 +211,7 @@ : public base::RefCountedThreadSafe<ChainedBlobWriter> { public: virtual void set_delegate( - scoped_ptr<storage::FileWriterDelegate> delegate) = 0; + std::unique_ptr<storage::FileWriterDelegate> delegate) = 0; // TODO(ericu): Add a reason in the event of failure. virtual void ReportWriteCompletion(bool succeeded, @@ -338,8 +338,8 @@ Transaction* transaction_; int64_t database_id_; const CursorOptions cursor_options_; - scoped_ptr<LevelDBIterator> iterator_; - scoped_ptr<IndexedDBKey> current_key_; + std::unique_ptr<LevelDBIterator> iterator_; + std::unique_ptr<IndexedDBKey> current_key_; IndexedDBBackingStore::RecordIdentifier record_identifier_; private: @@ -513,14 +513,14 @@ int64_t object_store_id, int64_t index_id, const IndexedDBKey& key, - scoped_ptr<IndexedDBKey>* primary_key) WARN_UNUSED_RESULT; + std::unique_ptr<IndexedDBKey>* primary_key) WARN_UNUSED_RESULT; virtual leveldb::Status KeyExistsInIndex( IndexedDBBackingStore::Transaction* transaction, int64_t database_id, int64_t object_store_id, int64_t index_id, const IndexedDBKey& key, - scoped_ptr<IndexedDBKey>* found_primary_key, + std::unique_ptr<IndexedDBKey>* found_primary_key, bool* exists) WARN_UNUSED_RESULT; // Public for IndexedDBActiveBlobRegistry::ReleaseBlobRef. @@ -528,21 +528,21 @@ base::FilePath GetBlobFileName(int64_t database_id, int64_t key) const; - virtual scoped_ptr<Cursor> OpenObjectStoreKeyCursor( + virtual std::unique_ptr<Cursor> OpenObjectStoreKeyCursor( IndexedDBBackingStore::Transaction* transaction, int64_t database_id, int64_t object_store_id, const IndexedDBKeyRange& key_range, blink::WebIDBCursorDirection, leveldb::Status*); - virtual scoped_ptr<Cursor> OpenObjectStoreCursor( + virtual std::unique_ptr<Cursor> OpenObjectStoreCursor( IndexedDBBackingStore::Transaction* transaction, int64_t database_id, int64_t object_store_id, const IndexedDBKeyRange& key_range, blink::WebIDBCursorDirection, leveldb::Status*); - virtual scoped_ptr<Cursor> OpenIndexKeyCursor( + virtual std::unique_ptr<Cursor> OpenIndexKeyCursor( IndexedDBBackingStore::Transaction* transaction, int64_t database_id, int64_t object_store_id, @@ -550,7 +550,7 @@ const IndexedDBKeyRange& key_range, blink::WebIDBCursorDirection, leveldb::Status*); - virtual scoped_ptr<Cursor> OpenIndexCursor( + virtual std::unique_ptr<Cursor> OpenIndexCursor( IndexedDBBackingStore::Transaction* transaction, int64_t database_id, int64_t object_store_id, @@ -566,8 +566,8 @@ const GURL& origin_url, const base::FilePath& blob_path, net::URLRequestContext* request_context, - scoped_ptr<LevelDBDatabase> db, - scoped_ptr<LevelDBComparator> comparator, + std::unique_ptr<LevelDBDatabase> db, + std::unique_ptr<LevelDBComparator> comparator, base::SequencedTaskRunner* task_runner); virtual ~IndexedDBBackingStore(); @@ -600,8 +600,8 @@ const GURL& origin_url, const base::FilePath& blob_path, net::URLRequestContext* request_context, - scoped_ptr<LevelDBDatabase> db, - scoped_ptr<LevelDBComparator> comparator, + std::unique_ptr<LevelDBDatabase> db, + std::unique_ptr<LevelDBComparator> comparator, base::SequencedTaskRunner* task_runner, leveldb::Status* status); @@ -655,8 +655,8 @@ BlobChangeMap incognito_blob_map_; base::OneShotTimer journal_cleaning_timer_; - scoped_ptr<LevelDBDatabase> db_; - scoped_ptr<LevelDBComparator> comparator_; + std::unique_ptr<LevelDBDatabase> db_; + std::unique_ptr<LevelDBComparator> comparator_; // Whenever blobs are registered in active_blob_registry_, indexed_db_factory_ // will hold a reference to this backing store. IndexedDBActiveBlobRegistry active_blob_registry_;
diff --git a/content/browser/indexed_db/indexed_db_backing_store_unittest.cc b/content/browser/indexed_db/indexed_db_backing_store_unittest.cc index 55acfa0..b4904917 100644 --- a/content/browser/indexed_db/indexed_db_backing_store_unittest.cc +++ b/content/browser/indexed_db/indexed_db_backing_store_unittest.cc
@@ -51,7 +51,7 @@ DefaultLevelDBFactory() {} leveldb::Status OpenLevelDB(const base::FilePath& file_name, const LevelDBComparator* comparator, - scoped_ptr<LevelDBDatabase>* db, + std::unique_ptr<LevelDBDatabase>* db, bool* is_disk_full) override { return LevelDBDatabase::Open(file_name, comparator, db, is_disk_full); } @@ -75,7 +75,7 @@ leveldb::Status* status) { DCHECK(!path_base.empty()); - scoped_ptr<LevelDBComparator> comparator(new Comparator()); + std::unique_ptr<LevelDBComparator> comparator(new Comparator()); if (!base::CreateDirectory(path_base)) { *status = leveldb::Status::IOError("Unable to create base dir"); @@ -85,7 +85,7 @@ const base::FilePath file_path = path_base.AppendASCII("test_db_path"); const base::FilePath blob_path = path_base.AppendASCII("test_blob_path"); - scoped_ptr<LevelDBDatabase> db; + std::unique_ptr<LevelDBDatabase> db; bool is_disk_full = false; *status = leveldb_factory->OpenLevelDB( file_path, comparator.get(), &db, &is_disk_full); @@ -156,8 +156,8 @@ const GURL& origin_url, const base::FilePath& blob_path, net::URLRequestContext* request_context, - scoped_ptr<LevelDBDatabase> db, - scoped_ptr<LevelDBComparator> comparator, + std::unique_ptr<LevelDBDatabase> db, + std::unique_ptr<LevelDBComparator> comparator, base::SequencedTaskRunner* task_runner) : IndexedDBBackingStore(indexed_db_factory, origin_url, @@ -820,7 +820,7 @@ EXPECT_TRUE(s.ok()); EXPECT_EQ(m_value1.bits, result_value.bits); - scoped_ptr<IndexedDBKey> new_primary_key; + std::unique_ptr<IndexedDBKey> new_primary_key; s = backing_store_->GetPrimaryKeyViaIndex(&transaction2, high_database_id, high_object_store_id, @@ -903,7 +903,7 @@ &transaction1, 0, object_store_id, m_key1, &result_value); EXPECT_FALSE(s.ok()); - scoped_ptr<IndexedDBKey> new_primary_key; + std::unique_ptr<IndexedDBKey> new_primary_key; s = backing_store_->GetPrimaryKeyViaIndex(&transaction1, database_id, object_store_id,
diff --git a/content/browser/indexed_db/indexed_db_browsertest.cc b/content/browser/indexed_db/indexed_db_browsertest.cc index 9a53bc6..1505e57 100644 --- a/content/browser/indexed_db/indexed_db_browsertest.cc +++ b/content/browser/indexed_db/indexed_db_browsertest.cc
@@ -581,7 +581,7 @@ const std::string s_corrupt_db_test_prefix = "/corrupt/test/"; -static scoped_ptr<net::test_server::HttpResponse> CorruptDBRequestHandler( +static std::unique_ptr<net::test_server::HttpResponse> CorruptDBRequestHandler( IndexedDBContextImpl* context, const GURL& origin_url, const std::string& path, @@ -591,7 +591,7 @@ if (path.find(s_corrupt_db_test_prefix) != std::string::npos) request_path = request.relative_url.substr(s_corrupt_db_test_prefix.size()); else - return scoped_ptr<net::test_server::HttpResponse>(); + return std::unique_ptr<net::test_server::HttpResponse>(); // Remove the query string if present. std::string request_query; @@ -611,7 +611,7 @@ &signal_when_finished)); signal_when_finished.Wait(); - scoped_ptr<net::test_server::BasicHttpResponse> http_response( + std::unique_ptr<net::test_server::BasicHttpResponse> http_response( new net::test_server::BasicHttpResponse); http_response->set_code(net::HTTP_OK); return std::move(http_response); @@ -677,7 +677,7 @@ test->FailOperation(failure_class, failure_method, instance_num, call_num); - scoped_ptr<net::test_server::BasicHttpResponse> http_response( + std::unique_ptr<net::test_server::BasicHttpResponse> http_response( new net::test_server::BasicHttpResponse); http_response->set_code(net::HTTP_OK); return std::move(http_response); @@ -686,12 +686,12 @@ // A request for a test resource base::FilePath resource_path = content::GetTestFilePath("indexeddb", request_path.c_str()); - scoped_ptr<net::test_server::BasicHttpResponse> http_response( + std::unique_ptr<net::test_server::BasicHttpResponse> http_response( new net::test_server::BasicHttpResponse); http_response->set_code(net::HTTP_OK); std::string file_contents; if (!base::ReadFileToString(resource_path, &file_contents)) - return scoped_ptr<net::test_server::HttpResponse>(); + return std::unique_ptr<net::test_server::HttpResponse>(); http_response->set_content(file_contents); return std::move(http_response); }
diff --git a/content/browser/indexed_db/indexed_db_callbacks.cc b/content/browser/indexed_db/indexed_db_callbacks.cc index a695c4b..092bb30c 100644 --- a/content/browser/indexed_db/indexed_db_callbacks.cc +++ b/content/browser/indexed_db/indexed_db_callbacks.cc
@@ -151,7 +151,7 @@ void IndexedDBCallbacks::OnUpgradeNeeded( int64_t old_version, - scoped_ptr<IndexedDBConnection> connection, + std::unique_ptr<IndexedDBConnection> connection, const IndexedDBDatabaseMetadata& metadata) { DCHECK(dispatcher_host_.get()); @@ -185,8 +185,9 @@ } } -void IndexedDBCallbacks::OnSuccess(scoped_ptr<IndexedDBConnection> connection, - const IndexedDBDatabaseMetadata& metadata) { +void IndexedDBCallbacks::OnSuccess( + std::unique_ptr<IndexedDBConnection> connection, + const IndexedDBDatabaseMetadata& metadata) { DCHECK(dispatcher_host_.get()); DCHECK_EQ(kNoCursor, ipc_cursor_id_); @@ -347,7 +348,7 @@ DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_); int32_t ipc_object_id = dispatcher_host_->Add(cursor.get()); - scoped_ptr<IndexedDBMsg_CallbacksSuccessIDBCursor_Params> params( + std::unique_ptr<IndexedDBMsg_CallbacksSuccessIDBCursor_Params> params( new IndexedDBMsg_CallbacksSuccessIDBCursor_Params()); params->ipc_thread_id = ipc_thread_id_; params->ipc_callbacks_id = ipc_callbacks_id_; @@ -392,7 +393,7 @@ if (!idb_cursor) return; - scoped_ptr<IndexedDBMsg_CallbacksSuccessCursorContinue_Params> params( + std::unique_ptr<IndexedDBMsg_CallbacksSuccessCursorContinue_Params> params( new IndexedDBMsg_CallbacksSuccessCursorContinue_Params()); params->ipc_thread_id = ipc_thread_id_; params->ipc_callbacks_id = ipc_callbacks_id_; @@ -444,7 +445,7 @@ msg_primary_keys.push_back(primary_keys[i]); } - scoped_ptr<IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params> params( + std::unique_ptr<IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params> params( new IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params()); params->ipc_thread_id = ipc_thread_id_; params->ipc_callbacks_id = ipc_callbacks_id_; @@ -494,7 +495,7 @@ DCHECK_EQ(kNoDatabaseCallbacks, ipc_database_callbacks_id_); DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_); - scoped_ptr<IndexedDBMsg_CallbacksSuccessValue_Params> params( + std::unique_ptr<IndexedDBMsg_CallbacksSuccessValue_Params> params( new IndexedDBMsg_CallbacksSuccessValue_Params()); params->ipc_thread_id = ipc_thread_id_; params->ipc_callbacks_id = ipc_callbacks_id_; @@ -530,7 +531,7 @@ DCHECK_EQ(kNoDatabaseCallbacks, ipc_database_callbacks_id_); DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_); - scoped_ptr<IndexedDBMsg_CallbacksSuccessArray_Params> params( + std::unique_ptr<IndexedDBMsg_CallbacksSuccessArray_Params> params( new IndexedDBMsg_CallbacksSuccessArray_Params()); params->ipc_thread_id = ipc_thread_id_; params->ipc_callbacks_id = ipc_callbacks_id_;
diff --git a/content/browser/indexed_db/indexed_db_callbacks.h b/content/browser/indexed_db/indexed_db_callbacks.h index df102389..24df03a 100644 --- a/content/browser/indexed_db/indexed_db_callbacks.h +++ b/content/browser/indexed_db/indexed_db_callbacks.h
@@ -7,13 +7,13 @@ #include <stdint.h> +#include <memory> #include <string> #include <vector> #include "base/logging.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/strings/string16.h" #include "content/browser/indexed_db/indexed_db_database_error.h" #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" @@ -66,9 +66,9 @@ std::string data_loss_message); virtual void OnUpgradeNeeded( int64_t old_version, - scoped_ptr<IndexedDBConnection> connection, + std::unique_ptr<IndexedDBConnection> connection, const content::IndexedDBDatabaseMetadata& metadata); - virtual void OnSuccess(scoped_ptr<IndexedDBConnection> connection, + virtual void OnSuccess(std::unique_ptr<IndexedDBConnection> connection, const content::IndexedDBDatabaseMetadata& metadata); // IndexedDBDatabase::OpenCursor
diff --git a/content/browser/indexed_db/indexed_db_class_factory.cc b/content/browser/indexed_db/indexed_db_class_factory.cc index 6a31469..71c30fd 100644 --- a/content/browser/indexed_db/indexed_db_class_factory.cc +++ b/content/browser/indexed_db/indexed_db_class_factory.cc
@@ -52,7 +52,7 @@ } content::LevelDBIteratorImpl* IndexedDBClassFactory::CreateIteratorImpl( - scoped_ptr<leveldb::Iterator> iterator) { + std::unique_ptr<leveldb::Iterator> iterator) { return new LevelDBIteratorImpl(std::move(iterator)); }
diff --git a/content/browser/indexed_db/indexed_db_class_factory.h b/content/browser/indexed_db/indexed_db_class_factory.h index 31e52025..2f8521032 100644 --- a/content/browser/indexed_db/indexed_db_class_factory.h +++ b/content/browser/indexed_db/indexed_db_class_factory.h
@@ -7,10 +7,10 @@ #include <stdint.h> +#include <memory> #include <set> #include "base/lazy_instance.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/indexed_db/indexed_db_backing_store.h" #include "content/browser/indexed_db/indexed_db_database.h" #include "content/common/content_export.h" @@ -55,7 +55,7 @@ IndexedDBBackingStore::Transaction* backing_store_transaction); virtual LevelDBIteratorImpl* CreateIteratorImpl( - scoped_ptr<leveldb::Iterator> iterator); + std::unique_ptr<leveldb::Iterator> iterator); virtual LevelDBTransaction* CreateLevelDBTransaction(LevelDBDatabase* db); protected:
diff --git a/content/browser/indexed_db/indexed_db_cleanup_on_io_error_unittest.cc b/content/browser/indexed_db/indexed_db_cleanup_on_io_error_unittest.cc index 02636f8..609ebfad 100644 --- a/content/browser/indexed_db/indexed_db_cleanup_on_io_error_unittest.cc +++ b/content/browser/indexed_db/indexed_db_cleanup_on_io_error_unittest.cc
@@ -44,10 +44,10 @@ class BustedLevelDBDatabase : public LevelDBDatabase { public: BustedLevelDBDatabase() {} - static scoped_ptr<LevelDBDatabase> Open( + static std::unique_ptr<LevelDBDatabase> Open( const base::FilePath& file_name, const LevelDBComparator* /*comparator*/) { - return scoped_ptr<LevelDBDatabase>(new BustedLevelDBDatabase); + return std::unique_ptr<LevelDBDatabase>(new BustedLevelDBDatabase); } leveldb::Status Get(const base::StringPiece& key, std::string* value, @@ -64,7 +64,7 @@ public: leveldb::Status OpenLevelDB(const base::FilePath& file_name, const LevelDBComparator* comparator, - scoped_ptr<LevelDBDatabase>* db, + std::unique_ptr<LevelDBDatabase>* db, bool* is_disk_full = 0) override { if (open_error_.ok()) *db = BustedLevelDBDatabase::Open(file_name, comparator);
diff --git a/content/browser/indexed_db/indexed_db_context_impl.cc b/content/browser/indexed_db/indexed_db_context_impl.cc index cbe6016c0..71a4ed8 100644 --- a/content/browser/indexed_db/indexed_db_context_impl.cc +++ b/content/browser/indexed_db/indexed_db_context_impl.cc
@@ -166,15 +166,15 @@ std::sort(origins.begin(), origins.end(), HostNameComparator); - scoped_ptr<base::ListValue> list(new base::ListValue()); + std::unique_ptr<base::ListValue> list(new base::ListValue()); for (const auto& origin_url : origins) { - scoped_ptr<base::DictionaryValue> info(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> info(new base::DictionaryValue()); info->SetString("url", origin_url.spec()); info->SetString("size", ui::FormatBytes(GetOriginDiskUsage(origin_url))); info->SetDouble("last_modified", GetOriginLastModified(origin_url).ToJsTime()); if (!is_incognito()) { - scoped_ptr<base::ListValue> paths(new base::ListValue()); + std::unique_ptr<base::ListValue> paths(new base::ListValue()); for (const base::FilePath& path : GetStoragePaths(origin_url)) paths->AppendString(path.value()); info->Set("paths", paths.release()); @@ -190,13 +190,14 @@ IndexedDBFactory::OriginDBMapIterator> range = factory_->GetOpenDatabasesForOrigin(origin_url); // TODO(jsbell): Sort by name? - scoped_ptr<base::ListValue> database_list(new base::ListValue()); + std::unique_ptr<base::ListValue> database_list(new base::ListValue()); for (IndexedDBFactory::OriginDBMapIterator it = range.first; it != range.second; ++it) { const IndexedDBDatabase* db = it->second; - scoped_ptr<base::DictionaryValue> db_info(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> db_info( + new base::DictionaryValue()); db_info->SetString("name", db->name()); db_info->SetDouble("pending_opens", db->PendingOpenCount()); @@ -207,11 +208,12 @@ db->ConnectionCount() - db->PendingUpgradeCount() - db->RunningUpgradeCount()); - scoped_ptr<base::ListValue> transaction_list(new base::ListValue()); + std::unique_ptr<base::ListValue> transaction_list( + new base::ListValue()); std::vector<const IndexedDBTransaction*> transactions = db->transaction_coordinator().GetTransactions(); for (const auto* transaction : transactions) { - scoped_ptr<base::DictionaryValue> transaction_info( + std::unique_ptr<base::DictionaryValue> transaction_info( new base::DictionaryValue()); const char* kModes[] = { "readonly", "readwrite", "versionchange" }; @@ -255,7 +257,7 @@ transaction_info->SetDouble( "tasks_completed", transaction->diagnostics().tasks_completed); - scoped_ptr<base::ListValue> scope(new base::ListValue()); + std::unique_ptr<base::ListValue> scope(new base::ListValue()); for (const auto& id : transaction->scope()) { IndexedDBDatabaseMetadata::ObjectStoreMap::const_iterator it = db->metadata().object_stores.find(id);
diff --git a/content/browser/indexed_db/indexed_db_context_impl.h b/content/browser/indexed_db/indexed_db_context_impl.h index 608e0f2..e9723f1 100644 --- a/content/browser/indexed_db/indexed_db_context_impl.h +++ b/content/browser/indexed_db/indexed_db_context_impl.h
@@ -9,6 +9,7 @@ #include <stdint.h> #include <map> +#include <memory> #include <set> #include <string> #include <vector> @@ -17,7 +18,6 @@ #include "base/files/file_path.h" #include "base/gtest_prod_util.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/browser_main_loop.h" #include "content/browser/indexed_db/indexed_db_factory.h" #include "content/public/browser/indexed_db_context.h" @@ -155,7 +155,7 @@ scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy_; scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy_; scoped_refptr<base::SequencedTaskRunner> task_runner_; - scoped_ptr<std::set<GURL> > origin_set_; + std::unique_ptr<std::set<GURL>> origin_set_; OriginToSizeMap origin_size_map_; DISALLOW_COPY_AND_ASSIGN(IndexedDBContextImpl);
diff --git a/content/browser/indexed_db/indexed_db_cursor.cc b/content/browser/indexed_db/indexed_db_cursor.cc index 05e788c..6d01e2a 100644 --- a/content/browser/indexed_db/indexed_db_cursor.cc +++ b/content/browser/indexed_db/indexed_db_cursor.cc
@@ -19,7 +19,7 @@ namespace content { IndexedDBCursor::IndexedDBCursor( - scoped_ptr<IndexedDBBackingStore::Cursor> cursor, + std::unique_ptr<IndexedDBBackingStore::Cursor> cursor, indexed_db::CursorType cursor_type, blink::WebIDBTaskType task_type, IndexedDBTransaction* transaction) @@ -35,8 +35,8 @@ transaction_->UnregisterOpenCursor(this); } -void IndexedDBCursor::Continue(scoped_ptr<IndexedDBKey> key, - scoped_ptr<IndexedDBKey> primary_key, +void IndexedDBCursor::Continue(std::unique_ptr<IndexedDBKey> key, + std::unique_ptr<IndexedDBKey> primary_key, scoped_refptr<IndexedDBCallbacks> callbacks) { IDB_TRACE("IndexedDBCursor::Continue"); @@ -78,8 +78,8 @@ } void IndexedDBCursor::CursorIterationOperation( - scoped_ptr<IndexedDBKey> key, - scoped_ptr<IndexedDBKey> primary_key, + std::unique_ptr<IndexedDBKey> key, + std::unique_ptr<IndexedDBKey> primary_key, scoped_refptr<IndexedDBCallbacks> callbacks, IndexedDBTransaction* /*transaction*/) { IDB_TRACE("IndexedDBCursor::CursorIterationOperation");
diff --git a/content/browser/indexed_db/indexed_db_cursor.h b/content/browser/indexed_db/indexed_db_cursor.h index 5d1c3184..63cb796 100644 --- a/content/browser/indexed_db/indexed_db_cursor.h +++ b/content/browser/indexed_db/indexed_db_cursor.h
@@ -7,11 +7,11 @@ #include <stdint.h> +#include <memory> #include <string> #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/indexed_db/indexed_db_backing_store.h" #include "content/browser/indexed_db/indexed_db_database.h" #include "content/common/indexed_db/indexed_db_key_range.h" @@ -24,14 +24,14 @@ class CONTENT_EXPORT IndexedDBCursor : NON_EXPORTED_BASE(public base::RefCounted<IndexedDBCursor>) { public: - IndexedDBCursor(scoped_ptr<IndexedDBBackingStore::Cursor> cursor, + IndexedDBCursor(std::unique_ptr<IndexedDBBackingStore::Cursor> cursor, indexed_db::CursorType cursor_type, blink::WebIDBTaskType task_type, IndexedDBTransaction* transaction); void Advance(uint32_t count, scoped_refptr<IndexedDBCallbacks> callbacks); - void Continue(scoped_ptr<IndexedDBKey> key, - scoped_ptr<IndexedDBKey> primary_key, + void Continue(std::unique_ptr<IndexedDBKey> key, + std::unique_ptr<IndexedDBKey> primary_key, scoped_refptr<IndexedDBCallbacks> callbacks); void PrefetchContinue(int number_to_fetch, scoped_refptr<IndexedDBCallbacks> callbacks); @@ -45,8 +45,8 @@ } void Close(); - void CursorIterationOperation(scoped_ptr<IndexedDBKey> key, - scoped_ptr<IndexedDBKey> primary_key, + void CursorIterationOperation(std::unique_ptr<IndexedDBKey> key, + std::unique_ptr<IndexedDBKey> primary_key, scoped_refptr<IndexedDBCallbacks> callbacks, IndexedDBTransaction* transaction); void CursorAdvanceOperation(uint32_t count, @@ -67,9 +67,9 @@ const scoped_refptr<IndexedDBTransaction> transaction_; // Must be destroyed before transaction_. - scoped_ptr<IndexedDBBackingStore::Cursor> cursor_; + std::unique_ptr<IndexedDBBackingStore::Cursor> cursor_; // Must be destroyed before transaction_. - scoped_ptr<IndexedDBBackingStore::Cursor> saved_cursor_; + std::unique_ptr<IndexedDBBackingStore::Cursor> saved_cursor_; bool closed_;
diff --git a/content/browser/indexed_db/indexed_db_database.cc b/content/browser/indexed_db/indexed_db_database.cc index a877a7b..32b0ef86 100644 --- a/content/browser/indexed_db/indexed_db_database.cc +++ b/content/browser/indexed_db/indexed_db_database.cc
@@ -5,14 +5,16 @@ #include "content/browser/indexed_db/indexed_db_database.h" #include <math.h> + #include <limits> +#include <memory> #include <set> #include <utility> #include "base/auto_reset.h" #include "base/logging.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" +#include "base/memory/ptr_util.h" #include "base/memory/scoped_vector.h" #include "base/metrics/histogram_macros.h" #include "base/stl_util.h" @@ -71,12 +73,13 @@ } // namespace -// PendingUpgradeCall has a scoped_ptr<IndexedDBConnection> because it owns the +// PendingUpgradeCall has a std::unique_ptr<IndexedDBConnection> because it owns +// the // in-progress connection. class IndexedDBDatabase::PendingUpgradeCall { public: PendingUpgradeCall(scoped_refptr<IndexedDBCallbacks> callbacks, - scoped_ptr<IndexedDBConnection> connection, + std::unique_ptr<IndexedDBConnection> connection, int64_t transaction_id, int64_t version) : callbacks_(callbacks), @@ -85,7 +88,7 @@ transaction_id_(transaction_id) {} scoped_refptr<IndexedDBCallbacks> callbacks() const { return callbacks_; } // Takes ownership of the connection object. - scoped_ptr<IndexedDBConnection> ReleaseConnection() WARN_UNUSED_RESULT { + std::unique_ptr<IndexedDBConnection> ReleaseConnection() WARN_UNUSED_RESULT { return std::move(connection_); } int64_t version() const { return version_; } @@ -93,7 +96,7 @@ private: scoped_refptr<IndexedDBCallbacks> callbacks_; - scoped_ptr<IndexedDBConnection> connection_; + std::unique_ptr<IndexedDBConnection> connection_; int64_t version_; const int64_t transaction_id_; }; @@ -229,10 +232,10 @@ return kMaxIDBMessageSizeInBytes; } -scoped_ptr<IndexedDBConnection> IndexedDBDatabase::CreateConnection( +std::unique_ptr<IndexedDBConnection> IndexedDBDatabase::CreateConnection( scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, int child_process_id) { - scoped_ptr<IndexedDBConnection> connection( + std::unique_ptr<IndexedDBConnection> connection( new IndexedDBConnection(this, database_callbacks)); connections_.insert(connection.get()); backing_store_->GrantChildProcessPermissions(child_process_id); @@ -536,7 +539,7 @@ void IndexedDBDatabase::GetAll(int64_t transaction_id, int64_t object_store_id, int64_t index_id, - scoped_ptr<IndexedDBKeyRange> key_range, + std::unique_ptr<IndexedDBKeyRange> key_range, bool key_only, int64_t max_count, scoped_refptr<IndexedDBCallbacks> callbacks) { @@ -558,7 +561,7 @@ void IndexedDBDatabase::Get(int64_t transaction_id, int64_t object_store_id, int64_t index_id, - scoped_ptr<IndexedDBKeyRange> key_range, + std::unique_ptr<IndexedDBKeyRange> key_range, bool key_only, scoped_refptr<IndexedDBCallbacks> callbacks) { IDB_TRACE1("IndexedDBDatabase::Get", "txn.id", transaction_id); @@ -579,7 +582,7 @@ void IndexedDBDatabase::GetOperation( int64_t object_store_id, int64_t index_id, - scoped_ptr<IndexedDBKeyRange> key_range, + std::unique_ptr<IndexedDBKeyRange> key_range, indexed_db::CursorType cursor_type, scoped_refptr<IndexedDBCallbacks> callbacks, IndexedDBTransaction* transaction) { @@ -593,7 +596,7 @@ const IndexedDBKey* key; leveldb::Status s; - scoped_ptr<IndexedDBBackingStore::Cursor> backing_store_cursor; + std::unique_ptr<IndexedDBBackingStore::Cursor> backing_store_cursor; if (key_range->IsOnlyKey()) { key = &key_range->lower(); } else { @@ -647,7 +650,7 @@ key = &backing_store_cursor->key(); } - scoped_ptr<IndexedDBKey> primary_key; + std::unique_ptr<IndexedDBKey> primary_key; if (index_id == IndexedDBIndexMetadata::kInvalidId) { // Object Store Retrieval Operation IndexedDBReturnValue value; @@ -741,7 +744,7 @@ void IndexedDBDatabase::GetAllOperation( int64_t object_store_id, int64_t index_id, - scoped_ptr<IndexedDBKeyRange> key_range, + std::unique_ptr<IndexedDBKeyRange> key_range, indexed_db::CursorType cursor_type, int64_t max_count, scoped_refptr<IndexedDBCallbacks> callbacks, @@ -757,7 +760,7 @@ leveldb::Status s; - scoped_ptr<IndexedDBBackingStore::Cursor> cursor; + std::unique_ptr<IndexedDBBackingStore::Cursor> cursor; if (cursor_type == indexed_db::CURSOR_KEY_ONLY) { // Retrieving keys @@ -875,7 +878,7 @@ } } -static scoped_ptr<IndexedDBKey> GenerateKey( +static std::unique_ptr<IndexedDBKey> GenerateKey( IndexedDBBackingStore* backing_store, IndexedDBTransaction* transaction, int64_t database_id, @@ -890,12 +893,13 @@ ¤t_number); if (!s.ok()) { LOG(ERROR) << "Failed to GetKeyGeneratorCurrentNumber"; - return make_scoped_ptr(new IndexedDBKey()); + return base::WrapUnique(new IndexedDBKey()); } if (current_number < 0 || current_number > max_generator_value) - return make_scoped_ptr(new IndexedDBKey()); + return base::WrapUnique(new IndexedDBKey()); - return make_scoped_ptr(new IndexedDBKey(current_number, WebIDBKeyTypeNumber)); + return base::WrapUnique( + new IndexedDBKey(current_number, WebIDBKeyTypeNumber)); } static leveldb::Status UpdateKeyGenerator(IndexedDBBackingStore* backing_store, @@ -915,7 +919,7 @@ int64_t object_store_id; IndexedDBValue value; ScopedVector<storage::BlobDataHandle> handles; - scoped_ptr<IndexedDBKey> key; + std::unique_ptr<IndexedDBKey> key; blink::WebIDBPutMode put_mode; scoped_refptr<IndexedDBCallbacks> callbacks; std::vector<IndexKeys> index_keys; @@ -928,7 +932,7 @@ int64_t object_store_id, IndexedDBValue* value, ScopedVector<storage::BlobDataHandle>* handles, - scoped_ptr<IndexedDBKey> key, + std::unique_ptr<IndexedDBKey> key, blink::WebIDBPutMode put_mode, scoped_refptr<IndexedDBCallbacks> callbacks, const std::vector<IndexKeys>& index_keys) { @@ -943,7 +947,7 @@ DCHECK(key); DCHECK(value); - scoped_ptr<PutOperationParams> params(new PutOperationParams()); + std::unique_ptr<PutOperationParams> params(new PutOperationParams()); params->object_store_id = object_store_id; params->value.swap(*value); params->handles.swap(*handles); @@ -955,7 +959,7 @@ &IndexedDBDatabase::PutOperation, this, base::Passed(¶ms))); } -void IndexedDBDatabase::PutOperation(scoped_ptr<PutOperationParams> params, +void IndexedDBDatabase::PutOperation(std::unique_ptr<PutOperationParams> params, IndexedDBTransaction* transaction) { IDB_TRACE1("IndexedDBDatabase::PutOperation", "txn.id", transaction->id()); DCHECK_NE(transaction->mode(), blink::WebIDBTransactionModeReadOnly); @@ -967,10 +971,10 @@ metadata_.object_stores[params->object_store_id]; DCHECK(object_store.auto_increment || params->key->IsValid()); - scoped_ptr<IndexedDBKey> key; + std::unique_ptr<IndexedDBKey> key; if (params->put_mode != blink::WebIDBPutModeCursorUpdate && object_store.auto_increment && !params->key->IsValid()) { - scoped_ptr<IndexedDBKey> auto_inc_key = GenerateKey( + std::unique_ptr<IndexedDBKey> auto_inc_key = GenerateKey( backing_store_.get(), transaction, id(), params->object_store_id); key_was_generated = true; if (!auto_inc_key->IsValid()) { @@ -1099,7 +1103,7 @@ void IndexedDBDatabase::SetIndexKeys(int64_t transaction_id, int64_t object_store_id, - scoped_ptr<IndexedDBKey> primary_key, + std::unique_ptr<IndexedDBKey> primary_key, const std::vector<IndexKeys>& index_keys) { IDB_TRACE1("IndexedDBDatabase::SetIndexKeys", "txn.id", transaction_id); IndexedDBTransaction* transaction = GetTransaction(transaction_id); @@ -1199,7 +1203,7 @@ OpenCursorOperationParams() {} int64_t object_store_id; int64_t index_id; - scoped_ptr<IndexedDBKeyRange> key_range; + std::unique_ptr<IndexedDBKeyRange> key_range; blink::WebIDBCursorDirection direction; indexed_db::CursorType cursor_type; blink::WebIDBTaskType task_type; @@ -1213,7 +1217,7 @@ int64_t transaction_id, int64_t object_store_id, int64_t index_id, - scoped_ptr<IndexedDBKeyRange> key_range, + std::unique_ptr<IndexedDBKeyRange> key_range, blink::WebIDBCursorDirection direction, bool key_only, blink::WebIDBTaskType task_type, @@ -1226,7 +1230,8 @@ if (!ValidateObjectStoreIdAndOptionalIndexId(object_store_id, index_id)) return; - scoped_ptr<OpenCursorOperationParams> params(new OpenCursorOperationParams()); + std::unique_ptr<OpenCursorOperationParams> params( + new OpenCursorOperationParams()); params->object_store_id = object_store_id; params->index_id = index_id; params->key_range = std::move(key_range); @@ -1240,7 +1245,7 @@ } void IndexedDBDatabase::OpenCursorOperation( - scoped_ptr<OpenCursorOperationParams> params, + std::unique_ptr<OpenCursorOperationParams> params, IndexedDBTransaction* transaction) { IDB_TRACE1( "IndexedDBDatabase::OpenCursorOperation", "txn.id", transaction->id()); @@ -1253,7 +1258,7 @@ transaction->AddPreemptiveEvent(); leveldb::Status s; - scoped_ptr<IndexedDBBackingStore::Cursor> backing_store_cursor; + std::unique_ptr<IndexedDBBackingStore::Cursor> backing_store_cursor; if (params->index_id == IndexedDBIndexMetadata::kInvalidId) { if (params->cursor_type == indexed_db::CURSOR_KEY_ONLY) { DCHECK_EQ(params->task_type, blink::WebIDBTaskTypeNormal); @@ -1322,7 +1327,7 @@ void IndexedDBDatabase::Count(int64_t transaction_id, int64_t object_store_id, int64_t index_id, - scoped_ptr<IndexedDBKeyRange> key_range, + std::unique_ptr<IndexedDBKeyRange> key_range, scoped_refptr<IndexedDBCallbacks> callbacks) { IDB_TRACE1("IndexedDBDatabase::Count", "txn.id", transaction_id); IndexedDBTransaction* transaction = GetTransaction(transaction_id); @@ -1343,12 +1348,12 @@ void IndexedDBDatabase::CountOperation( int64_t object_store_id, int64_t index_id, - scoped_ptr<IndexedDBKeyRange> key_range, + std::unique_ptr<IndexedDBKeyRange> key_range, scoped_refptr<IndexedDBCallbacks> callbacks, IndexedDBTransaction* transaction) { IDB_TRACE1("IndexedDBDatabase::CountOperation", "txn.id", transaction->id()); uint32_t count = 0; - scoped_ptr<IndexedDBBackingStore::Cursor> backing_store_cursor; + std::unique_ptr<IndexedDBBackingStore::Cursor> backing_store_cursor; leveldb::Status s; if (index_id == IndexedDBIndexMetadata::kInvalidId) { @@ -1395,7 +1400,7 @@ void IndexedDBDatabase::DeleteRange( int64_t transaction_id, int64_t object_store_id, - scoped_ptr<IndexedDBKeyRange> key_range, + std::unique_ptr<IndexedDBKeyRange> key_range, scoped_refptr<IndexedDBCallbacks> callbacks) { IDB_TRACE1("IndexedDBDatabase::DeleteRange", "txn.id", transaction_id); IndexedDBTransaction* transaction = GetTransaction(transaction_id); @@ -1415,7 +1420,7 @@ void IndexedDBDatabase::DeleteRangeOperation( int64_t object_store_id, - scoped_ptr<IndexedDBKeyRange> key_range, + std::unique_ptr<IndexedDBKeyRange> key_range, scoped_refptr<IndexedDBCallbacks> callbacks, IndexedDBTransaction* transaction) { IDB_TRACE1( @@ -1512,7 +1517,7 @@ void IndexedDBDatabase::VersionChangeOperation( int64_t version, scoped_refptr<IndexedDBCallbacks> callbacks, - scoped_ptr<IndexedDBConnection> connection, + std::unique_ptr<IndexedDBConnection> connection, IndexedDBTransaction* transaction) { IDB_TRACE1( "IndexedDBDatabase::VersionChangeOperation", "txn.id", transaction->id()); @@ -1556,7 +1561,7 @@ DCHECK(metadata_.id != kInvalidId); // Connection was already minted for OnUpgradeNeeded callback. - scoped_ptr<IndexedDBConnection> connection; + std::unique_ptr<IndexedDBConnection> connection; pending_second_half_open_->callbacks()->OnSuccess(std::move(connection), this->metadata()); } else { @@ -1609,7 +1614,7 @@ if (pending_run_version_change_transaction_call_ && ConnectionCount() == 1) { DCHECK(pending_run_version_change_transaction_call_->version() > metadata_.version); - scoped_ptr<PendingUpgradeCall> pending_call = + std::unique_ptr<PendingUpgradeCall> pending_call = std::move(pending_run_version_change_transaction_call_); RunVersionChangeTransactionFinal(pending_call->callbacks(), pending_call->ReleaseConnection(), @@ -1629,7 +1634,7 @@ while (!pending_delete_calls.empty()) { // Only the first delete call will delete the database, but each must fire // callbacks. - scoped_ptr<PendingDeleteCall> pending_delete_call( + std::unique_ptr<PendingDeleteCall> pending_delete_call( pending_delete_calls.front()); pending_delete_calls.pop_front(); DeleteDatabaseFinal(pending_delete_call->callbacks()); @@ -1776,7 +1781,7 @@ void IndexedDBDatabase::RunVersionChangeTransaction( scoped_refptr<IndexedDBCallbacks> callbacks, - scoped_ptr<IndexedDBConnection> connection, + std::unique_ptr<IndexedDBConnection> connection, int64_t transaction_id, int64_t requested_version) { DCHECK(callbacks.get()); @@ -1805,7 +1810,7 @@ void IndexedDBDatabase::RunVersionChangeTransactionFinal( scoped_refptr<IndexedDBCallbacks> callbacks, - scoped_ptr<IndexedDBConnection> connection, + std::unique_ptr<IndexedDBConnection> connection, int64_t transaction_id, int64_t requested_version) { std::vector<int64_t> object_store_ids;
diff --git a/content/browser/indexed_db/indexed_db_database.h b/content/browser/indexed_db/indexed_db_database.h index 207c1f9..0540a6f 100644 --- a/content/browser/indexed_db/indexed_db_database.h +++ b/content/browser/indexed_db/indexed_db_database.h
@@ -124,13 +124,13 @@ void Get(int64_t transaction_id, int64_t object_store_id, int64_t index_id, - scoped_ptr<IndexedDBKeyRange> key_range, + std::unique_ptr<IndexedDBKeyRange> key_range, bool key_only, scoped_refptr<IndexedDBCallbacks> callbacks); void GetAll(int64_t transaction_id, int64_t object_store_id, int64_t index_id, - scoped_ptr<IndexedDBKeyRange> key_range, + std::unique_ptr<IndexedDBKeyRange> key_range, bool key_only, int64_t max_count, scoped_refptr<IndexedDBCallbacks> callbacks); @@ -138,13 +138,13 @@ int64_t object_store_id, IndexedDBValue* value, ScopedVector<storage::BlobDataHandle>* handles, - scoped_ptr<IndexedDBKey> key, + std::unique_ptr<IndexedDBKey> key, blink::WebIDBPutMode mode, scoped_refptr<IndexedDBCallbacks> callbacks, const std::vector<IndexKeys>& index_keys); void SetIndexKeys(int64_t transaction_id, int64_t object_store_id, - scoped_ptr<IndexedDBKey> primary_key, + std::unique_ptr<IndexedDBKey> primary_key, const std::vector<IndexKeys>& index_keys); void SetIndexesReady(int64_t transaction_id, int64_t object_store_id, @@ -152,7 +152,7 @@ void OpenCursor(int64_t transaction_id, int64_t object_store_id, int64_t index_id, - scoped_ptr<IndexedDBKeyRange> key_range, + std::unique_ptr<IndexedDBKeyRange> key_range, blink::WebIDBCursorDirection, bool key_only, blink::WebIDBTaskType task_type, @@ -160,11 +160,11 @@ void Count(int64_t transaction_id, int64_t object_store_id, int64_t index_id, - scoped_ptr<IndexedDBKeyRange> key_range, + std::unique_ptr<IndexedDBKeyRange> key_range, scoped_refptr<IndexedDBCallbacks> callbacks); void DeleteRange(int64_t transaction_id, int64_t object_store_id, - scoped_ptr<IndexedDBKeyRange> key_range, + std::unique_ptr<IndexedDBKeyRange> key_range, scoped_refptr<IndexedDBCallbacks> callbacks); void Clear(int64_t transaction_id, int64_t object_store_id, @@ -191,7 +191,7 @@ IndexedDBTransaction* transaction); void VersionChangeOperation(int64_t version, scoped_refptr<IndexedDBCallbacks> callbacks, - scoped_ptr<IndexedDBConnection> connection, + std::unique_ptr<IndexedDBConnection> connection, IndexedDBTransaction* transaction); void VersionChangeAbortOperation(int64_t previous_version, IndexedDBTransaction* transaction); @@ -206,32 +206,32 @@ IndexedDBTransaction* transaction); void GetOperation(int64_t object_store_id, int64_t index_id, - scoped_ptr<IndexedDBKeyRange> key_range, + std::unique_ptr<IndexedDBKeyRange> key_range, indexed_db::CursorType cursor_type, scoped_refptr<IndexedDBCallbacks> callbacks, IndexedDBTransaction* transaction); void GetAllOperation(int64_t object_store_id, int64_t index_id, - scoped_ptr<IndexedDBKeyRange> key_range, + std::unique_ptr<IndexedDBKeyRange> key_range, indexed_db::CursorType cursor_type, int64_t max_count, scoped_refptr<IndexedDBCallbacks> callbacks, IndexedDBTransaction* transaction); struct PutOperationParams; - void PutOperation(scoped_ptr<PutOperationParams> params, + void PutOperation(std::unique_ptr<PutOperationParams> params, IndexedDBTransaction* transaction); void SetIndexesReadyOperation(size_t index_count, IndexedDBTransaction* transaction); struct OpenCursorOperationParams; - void OpenCursorOperation(scoped_ptr<OpenCursorOperationParams> params, + void OpenCursorOperation(std::unique_ptr<OpenCursorOperationParams> params, IndexedDBTransaction* transaction); void CountOperation(int64_t object_store_id, int64_t index_id, - scoped_ptr<IndexedDBKeyRange> key_range, + std::unique_ptr<IndexedDBKeyRange> key_range, scoped_refptr<IndexedDBCallbacks> callbacks, IndexedDBTransaction* transaction); void DeleteRangeOperation(int64_t object_store_id, - scoped_ptr<IndexedDBKeyRange> key_range, + std::unique_ptr<IndexedDBKeyRange> key_range, scoped_refptr<IndexedDBCallbacks> callbacks, IndexedDBTransaction* transaction); void ClearOperation(int64_t object_store_id, @@ -263,13 +263,14 @@ bool IsOpenConnectionBlocked() const; leveldb::Status OpenInternal(); - void RunVersionChangeTransaction(scoped_refptr<IndexedDBCallbacks> callbacks, - scoped_ptr<IndexedDBConnection> connection, - int64_t transaction_id, - int64_t requested_version); + void RunVersionChangeTransaction( + scoped_refptr<IndexedDBCallbacks> callbacks, + std::unique_ptr<IndexedDBConnection> connection, + int64_t transaction_id, + int64_t requested_version); void RunVersionChangeTransactionFinal( scoped_refptr<IndexedDBCallbacks> callbacks, - scoped_ptr<IndexedDBConnection> connection, + std::unique_ptr<IndexedDBConnection> connection, int64_t transaction_id, int64_t requested_version); void ProcessPendingCalls(); @@ -277,7 +278,7 @@ bool IsDeleteDatabaseBlocked() const; void DeleteDatabaseFinal(scoped_refptr<IndexedDBCallbacks> callbacks); - scoped_ptr<IndexedDBConnection> CreateConnection( + std::unique_ptr<IndexedDBConnection> CreateConnection( scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, int child_process_id); @@ -301,8 +302,9 @@ TransactionMap transactions_; PendingOpenCallList pending_open_calls_; - scoped_ptr<PendingUpgradeCall> pending_run_version_change_transaction_call_; - scoped_ptr<PendingSuccessCall> pending_second_half_open_; + std::unique_ptr<PendingUpgradeCall> + pending_run_version_change_transaction_call_; + std::unique_ptr<PendingSuccessCall> pending_second_half_open_; PendingDeleteCallList pending_delete_calls_; ConnectionSet connections_;
diff --git a/content/browser/indexed_db/indexed_db_database_unittest.cc b/content/browser/indexed_db/indexed_db_database_unittest.cc index efc1bdd..f01c413e1 100644 --- a/content/browser/indexed_db/indexed_db_database_unittest.cc +++ b/content/browser/indexed_db/indexed_db_database_unittest.cc
@@ -376,7 +376,7 @@ // Put is asynchronous IndexedDBValue value("value1", std::vector<IndexedDBBlobInfo>()); ScopedVector<storage::BlobDataHandle> handles; - scoped_ptr<IndexedDBKey> key(new IndexedDBKey("key")); + std::unique_ptr<IndexedDBKey> key(new IndexedDBKey("key")); std::vector<IndexedDBDatabase::IndexKeys> index_keys; scoped_refptr<MockIndexedDBCallbacks> request( new MockIndexedDBCallbacks(false));
diff --git a/content/browser/indexed_db/indexed_db_dispatcher_host.cc b/content/browser/indexed_db/indexed_db_dispatcher_host.cc index 969ce78..9613809 100644 --- a/content/browser/indexed_db/indexed_db_dispatcher_host.cc +++ b/content/browser/indexed_db/indexed_db_dispatcher_host.cc
@@ -10,6 +10,7 @@ #include "base/command_line.h" #include "base/files/file_path.h" #include "base/guid.h" +#include "base/memory/ptr_util.h" #include "base/memory/scoped_vector.h" #include "base/process/process.h" #include "base/stl_util.h" @@ -229,7 +230,7 @@ DCHECK_CURRENTLY_ON(BrowserThread::IO); std::string uuid = blob_info.uuid(); storage::BlobStorageContext* context = blob_storage_context_->context(); - scoped_ptr<storage::BlobDataHandle> blob_data_handle; + std::unique_ptr<storage::BlobDataHandle> blob_data_handle; if (uuid.empty()) { uuid = base::GenerateGUID(); storage::BlobDataBuilder blob_data_builder(uuid); @@ -613,12 +614,10 @@ scoped_refptr<IndexedDBCallbacks> callbacks(new IndexedDBCallbacks( parent_, params.ipc_thread_id, params.ipc_callbacks_id)); connection->database()->Get( - parent_->HostTransactionId(params.transaction_id), - params.object_store_id, + parent_->HostTransactionId(params.transaction_id), params.object_store_id, params.index_id, - make_scoped_ptr(new IndexedDBKeyRange(params.key_range)), - params.key_only, - callbacks); + base::WrapUnique(new IndexedDBKeyRange(params.key_range)), + params.key_only, callbacks); } void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnGetAll( @@ -633,7 +632,8 @@ parent_, params.ipc_thread_id, params.ipc_callbacks_id)); connection->database()->GetAll( parent_->HostTransactionId(params.transaction_id), params.object_store_id, - params.index_id, make_scoped_ptr(new IndexedDBKeyRange(params.key_range)), + params.index_id, + base::WrapUnique(new IndexedDBKeyRange(params.key_range)), params.key_only, params.max_count, callbacks); } @@ -703,14 +703,10 @@ IndexedDBValue value; value.bits = params.value.bits; value.blob_info.swap(blob_info); - connection->database()->Put(host_transaction_id, - params.object_store_id, - &value, - &scoped_handles, - make_scoped_ptr(new IndexedDBKey(params.key)), - params.put_mode, - callbacks, - params.index_keys); + connection->database()->Put(host_transaction_id, params.object_store_id, + &value, &scoped_handles, + base::WrapUnique(new IndexedDBKey(params.key)), + params.put_mode, callbacks, params.index_keys); // Size can't be big enough to overflow because it represents the // actual bytes passed through IPC. transaction_size_map_[host_transaction_id] += params.value.bits.size(); @@ -727,9 +723,8 @@ int64_t host_transaction_id = parent_->HostTransactionId(params.transaction_id); connection->database()->SetIndexKeys( - host_transaction_id, - params.object_store_id, - make_scoped_ptr(new IndexedDBKey(params.primary_key)), + host_transaction_id, params.object_store_id, + base::WrapUnique(new IndexedDBKey(params.primary_key)), params.index_keys); } @@ -759,14 +754,10 @@ scoped_refptr<IndexedDBCallbacks> callbacks(new IndexedDBCallbacks( parent_, params.ipc_thread_id, params.ipc_callbacks_id, -1)); connection->database()->OpenCursor( - parent_->HostTransactionId(params.transaction_id), - params.object_store_id, + parent_->HostTransactionId(params.transaction_id), params.object_store_id, params.index_id, - make_scoped_ptr(new IndexedDBKeyRange(params.key_range)), - params.direction, - params.key_only, - params.task_type, - callbacks); + base::WrapUnique(new IndexedDBKeyRange(params.key_range)), + params.direction, params.key_only, params.task_type, callbacks); } void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCount( @@ -780,11 +771,9 @@ scoped_refptr<IndexedDBCallbacks> callbacks(new IndexedDBCallbacks( parent_, params.ipc_thread_id, params.ipc_callbacks_id)); connection->database()->Count( - parent_->HostTransactionId(params.transaction_id), - params.object_store_id, + parent_->HostTransactionId(params.transaction_id), params.object_store_id, params.index_id, - make_scoped_ptr(new IndexedDBKeyRange(params.key_range)), - callbacks); + base::WrapUnique(new IndexedDBKeyRange(params.key_range)), callbacks); } void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteRange( @@ -798,10 +787,8 @@ scoped_refptr<IndexedDBCallbacks> callbacks(new IndexedDBCallbacks( parent_, params.ipc_thread_id, params.ipc_callbacks_id)); connection->database()->DeleteRange( - parent_->HostTransactionId(params.transaction_id), - params.object_store_id, - make_scoped_ptr(new IndexedDBKeyRange(params.key_range)), - callbacks); + parent_->HostTransactionId(params.transaction_id), params.object_store_id, + base::WrapUnique(new IndexedDBKeyRange(params.key_range)), callbacks); } void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClear( @@ -985,13 +972,13 @@ if (!idb_cursor) return; - idb_cursor->Continue( - key.IsValid() ? make_scoped_ptr(new IndexedDBKey(key)) - : scoped_ptr<IndexedDBKey>(), - primary_key.IsValid() ? make_scoped_ptr(new IndexedDBKey(primary_key)) - : scoped_ptr<IndexedDBKey>(), - new IndexedDBCallbacks( - parent_, ipc_thread_id, ipc_callbacks_id, ipc_cursor_id)); + idb_cursor->Continue(key.IsValid() ? base::WrapUnique(new IndexedDBKey(key)) + : std::unique_ptr<IndexedDBKey>(), + primary_key.IsValid() + ? base::WrapUnique(new IndexedDBKey(primary_key)) + : std::unique_ptr<IndexedDBKey>(), + new IndexedDBCallbacks(parent_, ipc_thread_id, + ipc_callbacks_id, ipc_cursor_id)); } void IndexedDBDispatcherHost::CursorDispatcherHost::OnPrefetch(
diff --git a/content/browser/indexed_db/indexed_db_dispatcher_host.h b/content/browser/indexed_db/indexed_db_dispatcher_host.h index bba6b81..a362734 100644 --- a/content/browser/indexed_db/indexed_db_dispatcher_host.h +++ b/content/browser/indexed_db/indexed_db_dispatcher_host.h
@@ -293,8 +293,8 @@ BlobDataHandleMap blob_data_handle_map_; // Only access on IndexedDB thread. - scoped_ptr<DatabaseDispatcherHost> database_dispatcher_host_; - scoped_ptr<CursorDispatcherHost> cursor_dispatcher_host_; + std::unique_ptr<DatabaseDispatcherHost> database_dispatcher_host_; + std::unique_ptr<CursorDispatcherHost> cursor_dispatcher_host_; // Used to set file permissions for blob storage. int ipc_process_id_;
diff --git a/content/browser/indexed_db/indexed_db_factory_unittest.cc b/content/browser/indexed_db/indexed_db_factory_unittest.cc index b61e66c..c483fb4 100644 --- a/content/browser/indexed_db/indexed_db_factory_unittest.cc +++ b/content/browser/indexed_db/indexed_db_factory_unittest.cc
@@ -434,7 +434,7 @@ public: UpgradeNeededCallbacks() {} - void OnSuccess(scoped_ptr<IndexedDBConnection> connection, + void OnSuccess(std::unique_ptr<IndexedDBConnection> connection, const IndexedDBDatabaseMetadata& metadata) override { EXPECT_TRUE(connection_.get()); EXPECT_FALSE(connection.get()); @@ -442,7 +442,7 @@ void OnUpgradeNeeded( int64_t old_version, - scoped_ptr<IndexedDBConnection> connection, + std::unique_ptr<IndexedDBConnection> connection, const content::IndexedDBDatabaseMetadata& metadata) override { connection_ = std::move(connection); }
diff --git a/content/browser/indexed_db/indexed_db_fake_backing_store.cc b/content/browser/indexed_db/indexed_db_fake_backing_store.cc index b2aeb4c9..bed9d94d 100644 --- a/content/browser/indexed_db/indexed_db_fake_backing_store.cc +++ b/content/browser/indexed_db/indexed_db_fake_backing_store.cc
@@ -4,8 +4,9 @@ #include "content/browser/indexed_db/indexed_db_fake_backing_store.h" +#include <memory> + #include "base/files/file_path.h" -#include "base/memory/scoped_ptr.h" namespace content { @@ -14,10 +15,9 @@ GURL("http://localhost:81"), base::FilePath(), NULL /* request_context */, - scoped_ptr<LevelDBDatabase>(), - scoped_ptr<LevelDBComparator>(), - NULL /* task_runner */) { -} + std::unique_ptr<LevelDBDatabase>(), + std::unique_ptr<LevelDBComparator>(), + NULL /* task_runner */) {} IndexedDBFakeBackingStore::IndexedDBFakeBackingStore( IndexedDBFactory* factory, base::SequencedTaskRunner* task_runner) @@ -25,10 +25,9 @@ GURL("http://localhost:81"), base::FilePath(), NULL /* request_context */, - scoped_ptr<LevelDBDatabase>(), - scoped_ptr<LevelDBComparator>(), - task_runner) { -} + std::unique_ptr<LevelDBDatabase>(), + std::unique_ptr<LevelDBComparator>(), + task_runner) {} IndexedDBFakeBackingStore::~IndexedDBFakeBackingStore() {} std::vector<base::string16> IndexedDBFakeBackingStore::GetDatabaseNames( @@ -156,7 +155,7 @@ void IndexedDBFakeBackingStore::ReportBlobUnused(int64_t database_id, int64_t blob_key) {} -scoped_ptr<IndexedDBBackingStore::Cursor> +std::unique_ptr<IndexedDBBackingStore::Cursor> IndexedDBFakeBackingStore::OpenObjectStoreKeyCursor( IndexedDBBackingStore::Transaction* transaction, int64_t database_id, @@ -164,9 +163,9 @@ const IndexedDBKeyRange& key_range, blink::WebIDBCursorDirection, leveldb::Status* s) { - return scoped_ptr<IndexedDBBackingStore::Cursor>(); + return std::unique_ptr<IndexedDBBackingStore::Cursor>(); } -scoped_ptr<IndexedDBBackingStore::Cursor> +std::unique_ptr<IndexedDBBackingStore::Cursor> IndexedDBFakeBackingStore::OpenObjectStoreCursor( IndexedDBBackingStore::Transaction* transaction, int64_t database_id, @@ -174,9 +173,9 @@ const IndexedDBKeyRange& key_range, blink::WebIDBCursorDirection, leveldb::Status* s) { - return scoped_ptr<IndexedDBBackingStore::Cursor>(); + return std::unique_ptr<IndexedDBBackingStore::Cursor>(); } -scoped_ptr<IndexedDBBackingStore::Cursor> +std::unique_ptr<IndexedDBBackingStore::Cursor> IndexedDBFakeBackingStore::OpenIndexKeyCursor( IndexedDBBackingStore::Transaction* transaction, int64_t database_id, @@ -185,9 +184,9 @@ const IndexedDBKeyRange& key_range, blink::WebIDBCursorDirection, leveldb::Status* s) { - return scoped_ptr<IndexedDBBackingStore::Cursor>(); + return std::unique_ptr<IndexedDBBackingStore::Cursor>(); } -scoped_ptr<IndexedDBBackingStore::Cursor> +std::unique_ptr<IndexedDBBackingStore::Cursor> IndexedDBFakeBackingStore::OpenIndexCursor( IndexedDBBackingStore::Transaction* transaction, int64_t database_id, @@ -196,7 +195,7 @@ const IndexedDBKeyRange& key_range, blink::WebIDBCursorDirection, leveldb::Status* s) { - return scoped_ptr<IndexedDBBackingStore::Cursor>(); + return std::unique_ptr<IndexedDBBackingStore::Cursor>(); } IndexedDBFakeBackingStore::FakeTransaction::FakeTransaction(
diff --git a/content/browser/indexed_db/indexed_db_fake_backing_store.h b/content/browser/indexed_db/indexed_db_fake_backing_store.h index 3e16869..5ace0fe 100644 --- a/content/browser/indexed_db/indexed_db_fake_backing_store.h +++ b/content/browser/indexed_db/indexed_db_fake_backing_store.h
@@ -101,33 +101,34 @@ const IndexedDBKey&, const RecordIdentifier&) override; void ReportBlobUnused(int64_t database_id, int64_t blob_key) override; - scoped_ptr<Cursor> OpenObjectStoreKeyCursor( + std::unique_ptr<Cursor> OpenObjectStoreKeyCursor( Transaction* transaction, int64_t database_id, int64_t object_store_id, const IndexedDBKeyRange& key_range, blink::WebIDBCursorDirection, leveldb::Status*) override; - scoped_ptr<Cursor> OpenObjectStoreCursor(Transaction* transaction, - int64_t database_id, - int64_t object_store_id, - const IndexedDBKeyRange& key_range, - blink::WebIDBCursorDirection, - leveldb::Status*) override; - scoped_ptr<Cursor> OpenIndexKeyCursor(Transaction* transaction, - int64_t database_id, - int64_t object_store_id, - int64_t index_id, - const IndexedDBKeyRange& key_range, - blink::WebIDBCursorDirection, - leveldb::Status*) override; - scoped_ptr<Cursor> OpenIndexCursor(Transaction* transaction, - int64_t database_id, - int64_t object_store_id, - int64_t index_id, - const IndexedDBKeyRange& key_range, - blink::WebIDBCursorDirection, - leveldb::Status*) override; + std::unique_ptr<Cursor> OpenObjectStoreCursor( + Transaction* transaction, + int64_t database_id, + int64_t object_store_id, + const IndexedDBKeyRange& key_range, + blink::WebIDBCursorDirection, + leveldb::Status*) override; + std::unique_ptr<Cursor> OpenIndexKeyCursor(Transaction* transaction, + int64_t database_id, + int64_t object_store_id, + int64_t index_id, + const IndexedDBKeyRange& key_range, + blink::WebIDBCursorDirection, + leveldb::Status*) override; + std::unique_ptr<Cursor> OpenIndexCursor(Transaction* transaction, + int64_t database_id, + int64_t object_store_id, + int64_t index_id, + const IndexedDBKeyRange& key_range, + blink::WebIDBCursorDirection, + leveldb::Status*) override; class FakeTransaction : public IndexedDBBackingStore::Transaction { public:
diff --git a/content/browser/indexed_db/indexed_db_index_writer.cc b/content/browser/indexed_db/indexed_db_index_writer.cc index 79e0252..bc7a53b 100644 --- a/content/browser/indexed_db/indexed_db_index_writer.cc +++ b/content/browser/indexed_db/indexed_db_index_writer.cc
@@ -104,7 +104,7 @@ return true; } - scoped_ptr<IndexedDBKey> found_primary_key; + std::unique_ptr<IndexedDBKey> found_primary_key; bool found = false; leveldb::Status s = backing_store->KeyExistsInIndex(transaction, database_id, @@ -147,7 +147,7 @@ if (key_was_generated && (index.key_path == object_store.key_path)) keys.second.push_back(primary_key); - scoped_ptr<IndexWriter> index_writer(new IndexWriter(index, keys)); + std::unique_ptr<IndexWriter> index_writer(new IndexWriter(index, keys)); bool can_add_keys = false; bool backing_store_success = index_writer->VerifyIndexKeys(backing_store,
diff --git a/content/browser/indexed_db/indexed_db_internals_ui.cc b/content/browser/indexed_db/indexed_db_internals_ui.cc index bec8dd8..215b015 100644 --- a/content/browser/indexed_db/indexed_db_internals_ui.cc +++ b/content/browser/indexed_db/indexed_db_internals_ui.cc
@@ -104,7 +104,8 @@ IndexedDBContextImpl* context_impl = static_cast<IndexedDBContextImpl*>(context.get()); - scoped_ptr<base::ListValue> info_list(context_impl->GetAllOriginsDetails()); + std::unique_ptr<base::ListValue> info_list( + context_impl->GetAllOriginsDetails()); bool is_incognito = context_impl->is_incognito(); BrowserThread::PostTask( @@ -116,8 +117,9 @@ is_incognito ? base::FilePath() : context_path)); } -void IndexedDBInternalsUI::OnOriginsReady(scoped_ptr<base::ListValue> origins, - const base::FilePath& path) { +void IndexedDBInternalsUI::OnOriginsReady( + std::unique_ptr<base::ListValue> origins, + const base::FilePath& path) { DCHECK_CURRENTLY_ON(BrowserThread::UI); web_ui()->CallJavascriptFunction( "indexeddb.onOriginsReady", *origins, base::StringValue(path.value())); @@ -295,7 +297,7 @@ const GURL url = GURL(FILE_PATH_LITERAL("file://") + zip_path.value()); BrowserContext* browser_context = web_ui()->GetWebContents()->GetBrowserContext(); - scoped_ptr<DownloadUrlParameters> dl_params( + std::unique_ptr<DownloadUrlParameters> dl_params( DownloadUrlParameters::FromWebContents(web_ui()->GetWebContents(), url)); DownloadManager* dlm = BrowserContext::GetDownloadManager(browser_context);
diff --git a/content/browser/indexed_db/indexed_db_internals_ui.h b/content/browser/indexed_db/indexed_db_internals_ui.h index 90467de..bcf7e2d 100644 --- a/content/browser/indexed_db/indexed_db_internals_ui.h +++ b/content/browser/indexed_db/indexed_db_internals_ui.h
@@ -7,11 +7,11 @@ #include <stddef.h> +#include <memory> #include <vector> #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "content/public/browser/download_interrupt_reasons.h" #include "content/public/browser/indexed_db_context.h" #include "content/public/browser/web_ui_controller.h" @@ -36,7 +36,7 @@ void GetAllOrigins(const base::ListValue* args); void GetAllOriginsOnIndexedDBThread(scoped_refptr<IndexedDBContext> context, const base::FilePath& context_path); - void OnOriginsReady(scoped_ptr<base::ListValue> origins, + void OnOriginsReady(std::unique_ptr<base::ListValue> origins, const base::FilePath& path); void AddContextFromStoragePartition(StoragePartition* partition);
diff --git a/content/browser/indexed_db/indexed_db_leveldb_coding.cc b/content/browser/indexed_db/indexed_db_leveldb_coding.cc index 8d5185b8..42188a9 100644 --- a/content/browser/indexed_db/indexed_db_leveldb_coding.cc +++ b/content/browser/indexed_db/indexed_db_leveldb_coding.cc
@@ -8,6 +8,7 @@ #include <limits> #include "base/logging.h" +#include "base/memory/ptr_util.h" #include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" #include "base/sys_byteorder.h" @@ -366,7 +367,7 @@ return true; } -bool DecodeIDBKey(StringPiece* slice, scoped_ptr<IndexedDBKey>* value) { +bool DecodeIDBKey(StringPiece* slice, std::unique_ptr<IndexedDBKey>* value) { if (slice->empty()) return false; @@ -375,7 +376,7 @@ switch (type) { case kIndexedDBKeyNullTypeByte: - *value = make_scoped_ptr(new IndexedDBKey()); + *value = base::WrapUnique(new IndexedDBKey()); return true; case kIndexedDBKeyArrayTypeByte: { @@ -384,40 +385,40 @@ return false; IndexedDBKey::KeyArray array; while (length--) { - scoped_ptr<IndexedDBKey> key; + std::unique_ptr<IndexedDBKey> key; if (!DecodeIDBKey(slice, &key)) return false; array.push_back(*key); } - *value = make_scoped_ptr(new IndexedDBKey(array)); + *value = base::WrapUnique(new IndexedDBKey(array)); return true; } case kIndexedDBKeyBinaryTypeByte: { std::string binary; if (!DecodeBinary(slice, &binary)) return false; - *value = make_scoped_ptr(new IndexedDBKey(binary)); + *value = base::WrapUnique(new IndexedDBKey(binary)); return true; } case kIndexedDBKeyStringTypeByte: { base::string16 s; if (!DecodeStringWithLength(slice, &s)) return false; - *value = make_scoped_ptr(new IndexedDBKey(s)); + *value = base::WrapUnique(new IndexedDBKey(s)); return true; } case kIndexedDBKeyDateTypeByte: { double d; if (!DecodeDouble(slice, &d)) return false; - *value = make_scoped_ptr(new IndexedDBKey(d, WebIDBKeyTypeDate)); + *value = base::WrapUnique(new IndexedDBKey(d, WebIDBKeyTypeDate)); return true; } case kIndexedDBKeyNumberTypeByte: { double d; if (!DecodeDouble(slice, &d)) return false; - *value = make_scoped_ptr(new IndexedDBKey(d, WebIDBKeyTypeNumber)); + *value = base::WrapUnique(new IndexedDBKey(d, WebIDBKeyTypeNumber)); return true; } } @@ -1641,8 +1642,8 @@ return Encode(database_id, object_store_id, encoded_key); } -scoped_ptr<IndexedDBKey> ObjectStoreDataKey::user_key() const { - scoped_ptr<IndexedDBKey> key; +std::unique_ptr<IndexedDBKey> ObjectStoreDataKey::user_key() const { + std::unique_ptr<IndexedDBKey> key; StringPiece slice(encoded_user_key_); if (!DecodeIDBKey(&slice, &key)) { // TODO(jsbell): Return error. @@ -1685,8 +1686,8 @@ return Encode(database_id, object_store_id, encoded_key); } -scoped_ptr<IndexedDBKey> ExistsEntryKey::user_key() const { - scoped_ptr<IndexedDBKey> key; +std::unique_ptr<IndexedDBKey> ExistsEntryKey::user_key() const { + std::unique_ptr<IndexedDBKey> key; StringPiece slice(encoded_user_key_); if (!DecodeIDBKey(&slice, &key)) { // TODO(jsbell): Return error. @@ -1884,8 +1885,8 @@ return index_id_; } -scoped_ptr<IndexedDBKey> IndexDataKey::user_key() const { - scoped_ptr<IndexedDBKey> key; +std::unique_ptr<IndexedDBKey> IndexDataKey::user_key() const { + std::unique_ptr<IndexedDBKey> key; StringPiece slice(encoded_user_key_); if (!DecodeIDBKey(&slice, &key)) { // TODO(jsbell): Return error. @@ -1893,8 +1894,8 @@ return key; } -scoped_ptr<IndexedDBKey> IndexDataKey::primary_key() const { - scoped_ptr<IndexedDBKey> key; +std::unique_ptr<IndexedDBKey> IndexDataKey::primary_key() const { + std::unique_ptr<IndexedDBKey> key; StringPiece slice(encoded_primary_key_); if (!DecodeIDBKey(&slice, &key)) { // TODO(jsbell): Return error.
diff --git a/content/browser/indexed_db/indexed_db_leveldb_coding.h b/content/browser/indexed_db/indexed_db_leveldb_coding.h index 5be0eec..62ab14ef 100644 --- a/content/browser/indexed_db/indexed_db_leveldb_coding.h +++ b/content/browser/indexed_db/indexed_db_leveldb_coding.h
@@ -8,6 +8,7 @@ #include <stddef.h> #include <stdint.h> +#include <memory> #include <string> #include <utility> #include <vector> @@ -15,7 +16,6 @@ #include "base/logging.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/strings/string16.h" #include "base/strings/string_piece.h" #include "content/common/indexed_db/indexed_db_key.h" @@ -67,7 +67,7 @@ double* value); CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeIDBKey( base::StringPiece* slice, - scoped_ptr<IndexedDBKey>* value); + std::unique_ptr<IndexedDBKey>* value); CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeIDBKeyPath( base::StringPiece* slice, IndexedDBKeyPath* value); @@ -394,7 +394,8 @@ static std::string Encode(int64_t database_id, int64_t object_store_id, const IndexedDBKey& user_key); - scoped_ptr<IndexedDBKey> user_key() const; + std::unique_ptr<IndexedDBKey> user_key() const; + private: std::string encoded_user_key_; }; @@ -411,7 +412,7 @@ static std::string Encode(int64_t database_id, int64_t object_store_id, const IndexedDBKey& user_key); - scoped_ptr<IndexedDBKey> user_key() const; + std::unique_ptr<IndexedDBKey> user_key() const; private: static const int64_t kSpecialIndexNumber; @@ -480,8 +481,8 @@ int64_t DatabaseId() const; int64_t ObjectStoreId() const; int64_t IndexId() const; - scoped_ptr<IndexedDBKey> user_key() const; - scoped_ptr<IndexedDBKey> primary_key() const; + std::unique_ptr<IndexedDBKey> user_key() const; + std::unique_ptr<IndexedDBKey> primary_key() const; private: int64_t database_id_;
diff --git a/content/browser/indexed_db/indexed_db_leveldb_coding_unittest.cc b/content/browser/indexed_db/indexed_db_leveldb_coding_unittest.cc index 0c30084..ba18510 100644 --- a/content/browser/indexed_db/indexed_db_leveldb_coding_unittest.cc +++ b/content/browser/indexed_db/indexed_db_leveldb_coding_unittest.cc
@@ -574,7 +574,7 @@ TEST(IndexedDBLevelDBCodingTest, EncodeDecodeIDBKey) { IndexedDBKey expected_key; - scoped_ptr<IndexedDBKey> decoded_key; + std::unique_ptr<IndexedDBKey> decoded_key; std::string v; StringPiece slice;
diff --git a/content/browser/indexed_db/indexed_db_quota_client_unittest.cc b/content/browser/indexed_db/indexed_db_quota_client_unittest.cc index a626dc0..f56346b4 100644 --- a/content/browser/indexed_db/indexed_db_quota_client_unittest.cc +++ b/content/browser/indexed_db/indexed_db_quota_client_unittest.cc
@@ -166,7 +166,7 @@ scoped_refptr<base::TestSimpleTaskRunner> task_runner_; scoped_refptr<IndexedDBContextImpl> idb_context_; content::TestBrowserThreadBundle thread_bundle_; - scoped_ptr<TestBrowserContext> browser_context_; + std::unique_ptr<TestBrowserContext> browser_context_; storage::QuotaStatusCode delete_status_; base::WeakPtrFactory<IndexedDBQuotaClientTest> weak_factory_;
diff --git a/content/browser/indexed_db/indexed_db_transaction.h b/content/browser/indexed_db/indexed_db_transaction.h index 18dfb47..ae1863b 100644 --- a/content/browser/indexed_db/indexed_db_transaction.h +++ b/content/browser/indexed_db/indexed_db_transaction.h
@@ -7,6 +7,7 @@ #include <stdint.h> +#include <memory> #include <queue> #include <set> #include <stack> @@ -14,7 +15,6 @@ #include "base/gtest_prod_util.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/time/time.h" #include "base/timer/timer.h" #include "content/browser/indexed_db/indexed_db_backing_store.h" @@ -167,7 +167,7 @@ TaskQueue preemptive_task_queue_; TaskStack abort_task_stack_; - scoped_ptr<IndexedDBBackingStore::Transaction> transaction_; + std::unique_ptr<IndexedDBBackingStore::Transaction> transaction_; bool backing_store_transaction_begun_; bool should_process_queue_;
diff --git a/content/browser/indexed_db/indexed_db_transaction_coordinator.h b/content/browser/indexed_db/indexed_db_transaction_coordinator.h index e32883a..fe74fd3 100644 --- a/content/browser/indexed_db/indexed_db_transaction_coordinator.h +++ b/content/browser/indexed_db/indexed_db_transaction_coordinator.h
@@ -8,12 +8,12 @@ #include <stdint.h> #include <map> +#include <memory> #include <set> #include <vector> #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/indexed_db/list_set.h" namespace content {
diff --git a/content/browser/indexed_db/indexed_db_unittest.cc b/content/browser/indexed_db/indexed_db_unittest.cc index 7b057d5..68891d9e2 100644 --- a/content/browser/indexed_db/indexed_db_unittest.cc +++ b/content/browser/indexed_db/indexed_db_unittest.cc
@@ -138,7 +138,7 @@ void OnSuccess() override {} void OnSuccess(const std::vector<base::string16>&) override {} - void OnSuccess(scoped_ptr<IndexedDBConnection> connection, + void OnSuccess(std::unique_ptr<IndexedDBConnection> connection, const IndexedDBDatabaseMetadata& metadata) override { connection_ = std::move(connection); idb_context_->ConnectionOpened(origin_url_, connection_.get()); @@ -152,7 +152,7 @@ private: scoped_refptr<IndexedDBContextImpl> idb_context_; GURL origin_url_; - scoped_ptr<IndexedDBConnection> connection_; + std::unique_ptr<IndexedDBConnection> connection_; DISALLOW_COPY_AND_ASSIGN(ForceCloseDBCallbacks); }; @@ -240,7 +240,7 @@ base::FilePath test_path = idb_context->GetFilePathForTesting(kTestOrigin); ASSERT_TRUE(base::CreateDirectory(test_path)); - scoped_ptr<LevelDBLock> lock = + std::unique_ptr<LevelDBLock> lock = LevelDBDatabase::LockForTesting(test_path); ASSERT_TRUE(lock);
diff --git a/content/browser/indexed_db/leveldb/leveldb_database.cc b/content/browser/indexed_db/leveldb/leveldb_database.cc index 4cb277cc..87186ee6 100644 --- a/content/browser/indexed_db/leveldb/leveldb_database.cc +++ b/content/browser/indexed_db/leveldb/leveldb_database.cc
@@ -5,13 +5,15 @@ #include "content/browser/indexed_db/leveldb/leveldb_database.h" #include <stdint.h> + #include <cerrno> +#include <memory> #include <utility> #include "base/files/file.h" #include "base/logging.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" +#include "base/memory/ptr_util.h" #include "base/metrics/histogram.h" #include "base/strings/string16.h" #include "base/strings/string_number_conversions.h" @@ -114,7 +116,7 @@ leveldb::Env* env, const base::FilePath& path, leveldb::DB** db, - scoped_ptr<const leveldb::FilterPolicy>* filter_policy) { + std::unique_ptr<const leveldb::FilterPolicy>* filter_policy) { filter_policy->reset(leveldb::NewBloomFilterPolicy(10)); leveldb::Options options; options.comparator = comparator; @@ -157,16 +159,16 @@ }; } // namespace -scoped_ptr<LevelDBLock> LevelDBDatabase::LockForTesting( +std::unique_ptr<LevelDBLock> LevelDBDatabase::LockForTesting( const base::FilePath& file_name) { leveldb::Env* env = LevelDBEnv::Get(); base::FilePath lock_path = file_name.AppendASCII("LOCK"); leveldb::FileLock* lock = NULL; leveldb::Status status = env->LockFile(lock_path.AsUTF8Unsafe(), &lock); if (!status.ok()) - return scoped_ptr<LevelDBLock>(); + return std::unique_ptr<LevelDBLock>(); DCHECK(lock); - return scoped_ptr<LevelDBLock>(new LockImpl(env, lock)); + return std::unique_ptr<LevelDBLock>(new LockImpl(env, lock)); } static int CheckFreeSpace(const char* const type, @@ -280,16 +282,16 @@ leveldb::Status LevelDBDatabase::Open(const base::FilePath& file_name, const LevelDBComparator* comparator, - scoped_ptr<LevelDBDatabase>* result, + std::unique_ptr<LevelDBDatabase>* result, bool* is_disk_full) { IDB_TRACE("LevelDBDatabase::Open"); base::TimeTicks begin_time = base::TimeTicks::Now(); - scoped_ptr<ComparatorAdapter> comparator_adapter( + std::unique_ptr<ComparatorAdapter> comparator_adapter( new ComparatorAdapter(comparator)); leveldb::DB* db; - scoped_ptr<const leveldb::FilterPolicy> filter_policy; + std::unique_ptr<const leveldb::FilterPolicy> filter_policy; const leveldb::Status s = OpenDB(comparator_adapter.get(), LevelDBEnv::Get(), file_name, &db, &filter_policy); @@ -312,7 +314,7 @@ CheckFreeSpace("Success", file_name); (*result).reset(new LevelDBDatabase); - (*result)->db_ = make_scoped_ptr(db); + (*result)->db_ = base::WrapUnique(db); (*result)->comparator_adapter_ = std::move(comparator_adapter); (*result)->comparator_ = comparator; (*result)->filter_policy_ = std::move(filter_policy); @@ -321,14 +323,15 @@ return s; } -scoped_ptr<LevelDBDatabase> LevelDBDatabase::OpenInMemory( +std::unique_ptr<LevelDBDatabase> LevelDBDatabase::OpenInMemory( const LevelDBComparator* comparator) { - scoped_ptr<ComparatorAdapter> comparator_adapter( + std::unique_ptr<ComparatorAdapter> comparator_adapter( new ComparatorAdapter(comparator)); - scoped_ptr<leveldb::Env> in_memory_env(leveldb::NewMemEnv(LevelDBEnv::Get())); + std::unique_ptr<leveldb::Env> in_memory_env( + leveldb::NewMemEnv(LevelDBEnv::Get())); leveldb::DB* db; - scoped_ptr<const leveldb::FilterPolicy> filter_policy; + std::unique_ptr<const leveldb::FilterPolicy> filter_policy; const leveldb::Status s = OpenDB(comparator_adapter.get(), in_memory_env.get(), base::FilePath(), @@ -337,12 +340,12 @@ if (!s.ok()) { LOG(ERROR) << "Failed to open in-memory LevelDB database: " << s.ToString(); - return scoped_ptr<LevelDBDatabase>(); + return std::unique_ptr<LevelDBDatabase>(); } - scoped_ptr<LevelDBDatabase> result(new LevelDBDatabase); + std::unique_ptr<LevelDBDatabase> result(new LevelDBDatabase); result->env_ = std::move(in_memory_env); - result->db_ = make_scoped_ptr(db); + result->db_ = base::WrapUnique(db); result->comparator_adapter_ = std::move(comparator_adapter); result->comparator_ = comparator; result->filter_policy_ = std::move(filter_policy); @@ -417,15 +420,15 @@ return s; } -scoped_ptr<LevelDBIterator> LevelDBDatabase::CreateIterator( +std::unique_ptr<LevelDBIterator> LevelDBDatabase::CreateIterator( const LevelDBSnapshot* snapshot) { leveldb::ReadOptions read_options; read_options.verify_checksums = true; // TODO(jsbell): Disable this if the // performance impact is too great. read_options.snapshot = snapshot ? snapshot->snapshot_ : 0; - scoped_ptr<leveldb::Iterator> i(db_->NewIterator(read_options)); - return scoped_ptr<LevelDBIterator>( + std::unique_ptr<leveldb::Iterator> i(db_->NewIterator(read_options)); + return std::unique_ptr<LevelDBIterator>( IndexedDBClassFactory::Get()->CreateIteratorImpl(std::move(i))); }
diff --git a/content/browser/indexed_db/leveldb/leveldb_database.h b/content/browser/indexed_db/leveldb/leveldb_database.h index 1ddc0bc4..cdcabb5 100644 --- a/content/browser/indexed_db/leveldb/leveldb_database.h +++ b/content/browser/indexed_db/leveldb/leveldb_database.h
@@ -5,11 +5,11 @@ #ifndef CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_DATABASE_H_ #define CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_DATABASE_H_ +#include <memory> #include <string> #include "base/files/file_path.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/strings/string16.h" #include "base/strings/string_piece.h" #include "base/trace_event/memory_dump_provider.h" @@ -77,12 +77,12 @@ static leveldb::Status Open(const base::FilePath& file_name, const LevelDBComparator* comparator, - scoped_ptr<LevelDBDatabase>* db, + std::unique_ptr<LevelDBDatabase>* db, bool* is_disk_full = 0); - static scoped_ptr<LevelDBDatabase> OpenInMemory( + static std::unique_ptr<LevelDBDatabase> OpenInMemory( const LevelDBComparator* comparator); static leveldb::Status Destroy(const base::FilePath& file_name); - static scoped_ptr<LevelDBLock> LockForTesting( + static std::unique_ptr<LevelDBLock> LockForTesting( const base::FilePath& file_name); ~LevelDBDatabase() override; @@ -93,7 +93,7 @@ bool* found, const LevelDBSnapshot* = 0); leveldb::Status Write(const LevelDBWriteBatch& write_batch); - scoped_ptr<LevelDBIterator> CreateIterator(const LevelDBSnapshot* = 0); + std::unique_ptr<LevelDBIterator> CreateIterator(const LevelDBSnapshot* = 0); const LevelDBComparator* Comparator() const; void Compact(const base::StringPiece& start, const base::StringPiece& stop); void CompactAll(); @@ -110,10 +110,10 @@ void CloseDatabase(); - scoped_ptr<leveldb::Env> env_; - scoped_ptr<leveldb::Comparator> comparator_adapter_; - scoped_ptr<leveldb::DB> db_; - scoped_ptr<const leveldb::FilterPolicy> filter_policy_; + std::unique_ptr<leveldb::Env> env_; + std::unique_ptr<leveldb::Comparator> comparator_adapter_; + std::unique_ptr<leveldb::DB> db_; + std::unique_ptr<const leveldb::FilterPolicy> filter_policy_; const LevelDBComparator* comparator_; std::string file_name_for_tracing; };
diff --git a/content/browser/indexed_db/leveldb/leveldb_factory.h b/content/browser/indexed_db/leveldb/leveldb_factory.h index 31974ee..42fffad 100644 --- a/content/browser/indexed_db/leveldb/leveldb_factory.h +++ b/content/browser/indexed_db/leveldb/leveldb_factory.h
@@ -5,7 +5,8 @@ #ifndef CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_FACTORY_H_ #define CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_FACTORY_H_ -#include "base/memory/scoped_ptr.h" +#include <memory> + #include "content/common/content_export.h" #include "third_party/leveldatabase/src/include/leveldb/status.h" @@ -23,7 +24,7 @@ virtual ~LevelDBFactory() {} virtual leveldb::Status OpenLevelDB(const base::FilePath& file_name, const LevelDBComparator* comparator, - scoped_ptr<LevelDBDatabase>* db, + std::unique_ptr<LevelDBDatabase>* db, bool* is_disk_full) = 0; virtual leveldb::Status DestroyLevelDB(const base::FilePath& file_name) = 0; };
diff --git a/content/browser/indexed_db/leveldb/leveldb_iterator_impl.cc b/content/browser/indexed_db/leveldb/leveldb_iterator_impl.cc index 35d679e90..2052f43 100644 --- a/content/browser/indexed_db/leveldb/leveldb_iterator_impl.cc +++ b/content/browser/indexed_db/leveldb/leveldb_iterator_impl.cc
@@ -4,10 +4,10 @@ #include "content/browser/indexed_db/leveldb/leveldb_iterator_impl.h" +#include <memory> #include <utility> #include "base/logging.h" -#include "base/memory/scoped_ptr.h" static leveldb::Slice MakeSlice(const base::StringPiece& s) { return leveldb::Slice(s.begin(), s.size()); @@ -22,7 +22,7 @@ LevelDBIteratorImpl::~LevelDBIteratorImpl() { } -LevelDBIteratorImpl::LevelDBIteratorImpl(scoped_ptr<leveldb::Iterator> it) +LevelDBIteratorImpl::LevelDBIteratorImpl(std::unique_ptr<leveldb::Iterator> it) : iterator_(std::move(it)) {} void LevelDBIteratorImpl::CheckStatus() {
diff --git a/content/browser/indexed_db/leveldb/leveldb_iterator_impl.h b/content/browser/indexed_db/leveldb/leveldb_iterator_impl.h index 8128429..22ca5d1 100644 --- a/content/browser/indexed_db/leveldb/leveldb_iterator_impl.h +++ b/content/browser/indexed_db/leveldb/leveldb_iterator_impl.h
@@ -5,8 +5,9 @@ #ifndef CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_ITERATOR_IMPL_H_ #define CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_ITERATOR_IMPL_H_ +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/indexed_db/leveldb/leveldb_iterator.h" #include "content/common/content_export.h" #include "third_party/leveldatabase/src/include/leveldb/iterator.h" @@ -25,7 +26,7 @@ base::StringPiece Value() const override; protected: - explicit LevelDBIteratorImpl(scoped_ptr<leveldb::Iterator> iterator); + explicit LevelDBIteratorImpl(std::unique_ptr<leveldb::Iterator> iterator); private: void CheckStatus(); @@ -33,7 +34,7 @@ friend class IndexedDBClassFactory; friend class MockBrowserTestIndexedDBClassFactory; - scoped_ptr<leveldb::Iterator> iterator_; + std::unique_ptr<leveldb::Iterator> iterator_; DISALLOW_COPY_AND_ASSIGN(LevelDBIteratorImpl); };
diff --git a/content/browser/indexed_db/leveldb/leveldb_transaction.cc b/content/browser/indexed_db/leveldb/leveldb_transaction.cc index 11a77c6..2abd7e60 100644 --- a/content/browser/indexed_db/leveldb/leveldb_transaction.cc +++ b/content/browser/indexed_db/leveldb/leveldb_transaction.cc
@@ -5,6 +5,7 @@ #include "content/browser/indexed_db/leveldb/leveldb_transaction.h" #include "base/logging.h" +#include "base/memory/ptr_util.h" #include "base/metrics/histogram.h" #include "base/time/time.h" #include "content/browser/indexed_db/indexed_db_tracing.h" @@ -97,7 +98,7 @@ } base::TimeTicks begin_time = base::TimeTicks::Now(); - scoped_ptr<LevelDBWriteBatch> write_batch = LevelDBWriteBatch::Create(); + std::unique_ptr<LevelDBWriteBatch> write_batch = LevelDBWriteBatch::Create(); auto it = data_.begin(); while (it != data_.end()) { @@ -127,13 +128,13 @@ Clear(); } -scoped_ptr<LevelDBIterator> LevelDBTransaction::CreateIterator() { +std::unique_ptr<LevelDBIterator> LevelDBTransaction::CreateIterator() { return TransactionIterator::Create(this); } -scoped_ptr<LevelDBTransaction::DataIterator> +std::unique_ptr<LevelDBTransaction::DataIterator> LevelDBTransaction::DataIterator::Create(LevelDBTransaction* transaction) { - return make_scoped_ptr(new DataIterator(transaction)); + return base::WrapUnique(new DataIterator(transaction)); } bool LevelDBTransaction::DataIterator::IsValid() const { @@ -190,10 +191,10 @@ : data_(&transaction->data_), iterator_(data_->end()) {} -scoped_ptr<LevelDBTransaction::TransactionIterator> +std::unique_ptr<LevelDBTransaction::TransactionIterator> LevelDBTransaction::TransactionIterator::Create( scoped_refptr<LevelDBTransaction> transaction) { - return make_scoped_ptr(new TransactionIterator(transaction)); + return base::WrapUnique(new TransactionIterator(transaction)); } LevelDBTransaction::TransactionIterator::TransactionIterator( @@ -453,9 +454,9 @@ transaction_iterator->DataChanged(); } -scoped_ptr<LevelDBDirectTransaction> LevelDBDirectTransaction::Create( +std::unique_ptr<LevelDBDirectTransaction> LevelDBDirectTransaction::Create( LevelDBDatabase* db) { - return make_scoped_ptr(new LevelDBDirectTransaction(db)); + return base::WrapUnique(new LevelDBDirectTransaction(db)); } LevelDBDirectTransaction::LevelDBDirectTransaction(LevelDBDatabase* db)
diff --git a/content/browser/indexed_db/leveldb/leveldb_transaction.h b/content/browser/indexed_db/leveldb/leveldb_transaction.h index bc9afb1..988506fa 100644 --- a/content/browser/indexed_db/leveldb/leveldb_transaction.h +++ b/content/browser/indexed_db/leveldb/leveldb_transaction.h
@@ -6,13 +6,13 @@ #define CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_TRANSACTION_H_ #include <map> +#include <memory> #include <set> #include <string> #include "base/gtest_prod_util.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/strings/string_piece.h" #include "content/browser/indexed_db/leveldb/leveldb_comparator.h" #include "content/browser/indexed_db/leveldb/leveldb_database.h" @@ -33,7 +33,7 @@ virtual leveldb::Status Commit(); void Rollback(); - scoped_ptr<LevelDBIterator> CreateIterator(); + std::unique_ptr<LevelDBIterator> CreateIterator(); protected: virtual ~LevelDBTransaction(); @@ -71,7 +71,8 @@ class DataIterator : public LevelDBIterator { public: - static scoped_ptr<DataIterator> Create(LevelDBTransaction* transaction); + static std::unique_ptr<DataIterator> Create( + LevelDBTransaction* transaction); ~DataIterator() override; bool IsValid() const override; @@ -94,7 +95,7 @@ class TransactionIterator : public LevelDBIterator { public: ~TransactionIterator() override; - static scoped_ptr<TransactionIterator> Create( + static std::unique_ptr<TransactionIterator> Create( scoped_refptr<LevelDBTransaction> transaction); bool IsValid() const override; @@ -119,8 +120,8 @@ scoped_refptr<LevelDBTransaction> transaction_; const LevelDBComparator* comparator_; - mutable scoped_ptr<DataIterator> data_iterator_; - scoped_ptr<LevelDBIterator> db_iterator_; + mutable std::unique_ptr<DataIterator> data_iterator_; + std::unique_ptr<LevelDBIterator> db_iterator_; LevelDBIterator* current_; Direction direction_; @@ -150,7 +151,7 @@ // write_batch_, and writes are write-through, without consolidation. class LevelDBDirectTransaction { public: - static scoped_ptr<LevelDBDirectTransaction> Create(LevelDBDatabase* db); + static std::unique_ptr<LevelDBDirectTransaction> Create(LevelDBDatabase* db); ~LevelDBDirectTransaction(); void Put(const base::StringPiece& key, const std::string* value); @@ -164,7 +165,7 @@ explicit LevelDBDirectTransaction(LevelDBDatabase* db); LevelDBDatabase* db_; - scoped_ptr<LevelDBWriteBatch> write_batch_; + std::unique_ptr<LevelDBWriteBatch> write_batch_; bool finished_; DISALLOW_COPY_AND_ASSIGN(LevelDBDirectTransaction);
diff --git a/content/browser/indexed_db/leveldb/leveldb_unittest.cc b/content/browser/indexed_db/leveldb/leveldb_unittest.cc index e25d9de8..55e94be8 100644 --- a/content/browser/indexed_db/leveldb/leveldb_unittest.cc +++ b/content/browser/indexed_db/leveldb/leveldb_unittest.cc
@@ -47,7 +47,7 @@ std::string got_value; SimpleComparator comparator; - scoped_ptr<LevelDBDatabase> leveldb; + std::unique_ptr<LevelDBDatabase> leveldb; LevelDBDatabase::Open(temp_directory.path(), &comparator, &leveldb); EXPECT_TRUE(leveldb); put_value = value; @@ -96,7 +96,7 @@ std::string put_value; SimpleComparator comparator; - scoped_ptr<LevelDBDatabase> leveldb; + std::unique_ptr<LevelDBDatabase> leveldb; LevelDBDatabase::Open(temp_directory.path(), &comparator, &leveldb); EXPECT_TRUE(leveldb); @@ -162,7 +162,7 @@ std::string put_value; SimpleComparator comparator; - scoped_ptr<LevelDBDatabase> leveldb; + std::unique_ptr<LevelDBDatabase> leveldb; LevelDBDatabase::Open(temp_directory.path(), &comparator, &leveldb); EXPECT_TRUE(leveldb); @@ -179,7 +179,7 @@ s = leveldb->Remove(key2); EXPECT_TRUE(s.ok()); - scoped_ptr<LevelDBIterator> it = transaction->CreateIterator(); + std::unique_ptr<LevelDBIterator> it = transaction->CreateIterator(); it->Seek(std::string()); @@ -213,7 +213,7 @@ SimpleComparator comparator; bool found; - scoped_ptr<LevelDBDatabase> leveldb; + std::unique_ptr<LevelDBDatabase> leveldb; LevelDBDatabase::Open(temp_directory.path(), &comparator, &leveldb); EXPECT_TRUE(leveldb);
diff --git a/content/browser/indexed_db/leveldb/leveldb_write_batch.cc b/content/browser/indexed_db/leveldb/leveldb_write_batch.cc index d9a12cb7..80861c46 100644 --- a/content/browser/indexed_db/leveldb/leveldb_write_batch.cc +++ b/content/browser/indexed_db/leveldb/leveldb_write_batch.cc
@@ -4,14 +4,15 @@ #include "content/browser/indexed_db/leveldb/leveldb_write_batch.h" +#include "base/memory/ptr_util.h" #include "base/strings/string_piece.h" #include "third_party/leveldatabase/src/include/leveldb/slice.h" #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" namespace content { -scoped_ptr<LevelDBWriteBatch> LevelDBWriteBatch::Create() { - return make_scoped_ptr(new LevelDBWriteBatch); +std::unique_ptr<LevelDBWriteBatch> LevelDBWriteBatch::Create() { + return base::WrapUnique(new LevelDBWriteBatch); } LevelDBWriteBatch::LevelDBWriteBatch()
diff --git a/content/browser/indexed_db/leveldb/leveldb_write_batch.h b/content/browser/indexed_db/leveldb/leveldb_write_batch.h index 3fbd103..c1c6e65 100644 --- a/content/browser/indexed_db/leveldb/leveldb_write_batch.h +++ b/content/browser/indexed_db/leveldb/leveldb_write_batch.h
@@ -5,7 +5,8 @@ #ifndef CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_WRITE_BATCH_H_ #define CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_WRITE_BATCH_H_ -#include "base/memory/scoped_ptr.h" +#include <memory> + #include "base/strings/string_piece.h" namespace leveldb { @@ -18,7 +19,7 @@ // This class holds a collection of updates to apply atomically to a database. class LevelDBWriteBatch { public: - static scoped_ptr<LevelDBWriteBatch> Create(); + static std::unique_ptr<LevelDBWriteBatch> Create(); ~LevelDBWriteBatch(); void Put(const base::StringPiece& key, const base::StringPiece& value); @@ -30,7 +31,7 @@ friend class LevelDBDatabase; LevelDBWriteBatch(); - scoped_ptr<leveldb::WriteBatch> write_batch_; + std::unique_ptr<leveldb::WriteBatch> write_batch_; }; } // namespace content
diff --git a/content/browser/indexed_db/leveldb/mock_leveldb_factory.h b/content/browser/indexed_db/leveldb/mock_leveldb_factory.h index dacb8608..5da41919 100644 --- a/content/browser/indexed_db/leveldb/mock_leveldb_factory.h +++ b/content/browser/indexed_db/leveldb/mock_leveldb_factory.h
@@ -18,7 +18,7 @@ MOCK_METHOD4(OpenLevelDB, leveldb::Status(const base::FilePath& file_name, const LevelDBComparator* comparator, - scoped_ptr<LevelDBDatabase>* db, + std::unique_ptr<LevelDBDatabase>* db, bool* is_disk_full)); MOCK_METHOD1(DestroyLevelDB, leveldb::Status(const base::FilePath& file_name));
diff --git a/content/browser/indexed_db/list_set.h b/content/browser/indexed_db/list_set.h index 7ab40e51..86ef45bb 100644 --- a/content/browser/indexed_db/list_set.h +++ b/content/browser/indexed_db/list_set.h
@@ -10,9 +10,10 @@ #include <algorithm> #include <iterator> #include <list> +#include <memory> #include <set> + #include "base/logging.h" -#include "base/memory/scoped_ptr.h" // // A container class that provides fast containment test (like a set) @@ -156,10 +157,10 @@ std::set<T> set_; }; -// Prevent instantiation of list_set<scoped_ptr<T>> as the current +// Prevent instantiation of list_set<std::unique_ptr<T>> as the current // implementation would fail. // TODO(jsbell): Support scoped_ptr through specialization. template <typename T> -class list_set<scoped_ptr<T> >; +class list_set<std::unique_ptr<T>>; #endif // CONTENT_BROWSER_INDEXED_DB_LIST_SET_H_
diff --git a/content/browser/indexed_db/list_set_unittest.cc b/content/browser/indexed_db/list_set_unittest.cc index 658414c9..293330da 100644 --- a/content/browser/indexed_db/list_set_unittest.cc +++ b/content/browser/indexed_db/list_set_unittest.cc
@@ -2,9 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/indexed_db/list_set.h" + +#include <memory> + +#include "base/memory/ref_counted.h" #include "testing/gtest/include/gtest/gtest.h" namespace content { @@ -146,9 +148,9 @@ } TEST(ListSetTest, ListSetPointer) { - scoped_ptr<Wrapped<int> > w0(new Wrapped<int>(0)); - scoped_ptr<Wrapped<int> > w1(new Wrapped<int>(1)); - scoped_ptr<Wrapped<int> > w2(new Wrapped<int>(2)); + std::unique_ptr<Wrapped<int>> w0(new Wrapped<int>(0)); + std::unique_ptr<Wrapped<int>> w1(new Wrapped<int>(1)); + std::unique_ptr<Wrapped<int>> w2(new Wrapped<int>(2)); list_set<Wrapped<int>*> set; EXPECT_EQ(0u, set.size());
diff --git a/content/browser/indexed_db/mock_browsertest_indexed_db_class_factory.cc b/content/browser/indexed_db/mock_browsertest_indexed_db_class_factory.cc index 60202ae0..51edd56 100644 --- a/content/browser/indexed_db/mock_browsertest_indexed_db_class_factory.cc +++ b/content/browser/indexed_db/mock_browsertest_indexed_db_class_factory.cc
@@ -166,7 +166,8 @@ class LevelDBTraceIteratorImpl : public LevelDBIteratorImpl { public: - LevelDBTraceIteratorImpl(scoped_ptr<leveldb::Iterator> iterator, int inst_num) + LevelDBTraceIteratorImpl(std::unique_ptr<leveldb::Iterator> iterator, + int inst_num) : LevelDBIteratorImpl(std::move(iterator)), is_valid_tracer_(s_class_name, "IsValid", inst_num), seek_to_last_tracer_(s_class_name, "SeekToLast", inst_num), @@ -222,7 +223,7 @@ class LevelDBTestIteratorImpl : public content::LevelDBIteratorImpl { public: - LevelDBTestIteratorImpl(scoped_ptr<leveldb::Iterator> iterator, + LevelDBTestIteratorImpl(std::unique_ptr<leveldb::Iterator> iterator, FailMethod fail_method, int fail_on_call_num) : LevelDBIteratorImpl(std::move(iterator)), @@ -298,7 +299,7 @@ } LevelDBIteratorImpl* MockBrowserTestIndexedDBClassFactory::CreateIteratorImpl( - scoped_ptr<leveldb::Iterator> iterator) { + std::unique_ptr<leveldb::Iterator> iterator) { instance_count_[FAIL_CLASS_LEVELDB_ITERATOR] = instance_count_[FAIL_CLASS_LEVELDB_ITERATOR] + 1; if (only_trace_calls_) {
diff --git a/content/browser/indexed_db/mock_browsertest_indexed_db_class_factory.h b/content/browser/indexed_db/mock_browsertest_indexed_db_class_factory.h index acc050a..8011e72 100644 --- a/content/browser/indexed_db/mock_browsertest_indexed_db_class_factory.h +++ b/content/browser/indexed_db/mock_browsertest_indexed_db_class_factory.h
@@ -8,9 +8,9 @@ #include <stdint.h> #include <map> +#include <memory> #include <set> -#include "base/memory/scoped_ptr.h" #include "content/browser/indexed_db/indexed_db_backing_store.h" #include "content/browser/indexed_db/indexed_db_class_factory.h" #include "content/browser/indexed_db/indexed_db_database.h" @@ -54,7 +54,7 @@ IndexedDBBackingStore::Transaction* backing_store_transaction) override; LevelDBTransaction* CreateLevelDBTransaction(LevelDBDatabase* db) override; LevelDBIteratorImpl* CreateIteratorImpl( - scoped_ptr<leveldb::Iterator> iterator) override; + std::unique_ptr<leveldb::Iterator> iterator) override; void FailOperation(FailClass failure_class, FailMethod failure_method,
diff --git a/content/browser/indexed_db/mock_indexed_db_callbacks.cc b/content/browser/indexed_db/mock_indexed_db_callbacks.cc index 79c1340..0d5c2bd 100644 --- a/content/browser/indexed_db/mock_indexed_db_callbacks.cc +++ b/content/browser/indexed_db/mock_indexed_db_callbacks.cc
@@ -28,7 +28,7 @@ void MockIndexedDBCallbacks::OnSuccess(const IndexedDBKey& key) {} void MockIndexedDBCallbacks::OnSuccess( - scoped_ptr<IndexedDBConnection> connection, + std::unique_ptr<IndexedDBConnection> connection, const IndexedDBDatabaseMetadata& metadata) { connection_ = std::move(connection); }
diff --git a/content/browser/indexed_db/mock_indexed_db_callbacks.h b/content/browser/indexed_db/mock_indexed_db_callbacks.h index 44fa8d7..4ba45a8 100644 --- a/content/browser/indexed_db/mock_indexed_db_callbacks.h +++ b/content/browser/indexed_db/mock_indexed_db_callbacks.h
@@ -24,14 +24,14 @@ void OnSuccess(int64_t result) override; void OnSuccess(const std::vector<base::string16>& result) override; void OnSuccess(const IndexedDBKey& key) override; - void OnSuccess(scoped_ptr<IndexedDBConnection> connection, + void OnSuccess(std::unique_ptr<IndexedDBConnection> connection, const IndexedDBDatabaseMetadata& metadata) override; IndexedDBConnection* connection() { return connection_.get(); } protected: ~MockIndexedDBCallbacks() override; - scoped_ptr<IndexedDBConnection> connection_; + std::unique_ptr<IndexedDBConnection> connection_; private: bool expect_connection_;
diff --git a/content/browser/manifest/manifest_browsertest.cc b/content/browser/manifest/manifest_browsertest.cc index 8dab4696..880a0f40 100644 --- a/content/browser/manifest/manifest_browsertest.cc +++ b/content/browser/manifest/manifest_browsertest.cc
@@ -117,8 +117,8 @@ private: scoped_refptr<MessageLoopRunner> message_loop_runner_; - scoped_ptr<MockWebContentsDelegate> mock_web_contents_delegate_; - scoped_ptr<net::EmbeddedTestServer> cors_embedded_test_server_; + std::unique_ptr<MockWebContentsDelegate> mock_web_contents_delegate_; + std::unique_ptr<net::EmbeddedTestServer> cors_embedded_test_server_; Manifest manifest_; int console_error_count_; bool has_manifest_; @@ -344,7 +344,7 @@ // If a page's manifest is in an insecure origin while the page is in a secure // origin, requesting the manifest should return the empty manifest. IN_PROC_BROWSER_TEST_F(ManifestBrowserTest, MixedContentManifest) { - scoped_ptr<net::EmbeddedTestServer> https_server( + std::unique_ptr<net::EmbeddedTestServer> https_server( new net::EmbeddedTestServer(net::EmbeddedTestServer::TYPE_HTTPS)); https_server->ServeFilesFromSourceDirectory("content/test/data"); @@ -487,10 +487,10 @@ namespace { -scoped_ptr<net::test_server::HttpResponse> CustomHandleRequestForCookies( +std::unique_ptr<net::test_server::HttpResponse> CustomHandleRequestForCookies( const net::test_server::HttpRequest& request) { if (request.relative_url == "/index.html") { - scoped_ptr<net::test_server::BasicHttpResponse> http_response( + std::unique_ptr<net::test_server::BasicHttpResponse> http_response( new net::test_server::BasicHttpResponse()); http_response->set_code(net::HTTP_OK); http_response->set_content_type("text/html"); @@ -503,9 +503,9 @@ const auto& iter = request.headers.find("Cookie"); if (iter == request.headers.end() || request.relative_url != "/manifest.json") - return scoped_ptr<net::test_server::HttpResponse>(); + return std::unique_ptr<net::test_server::HttpResponse>(); - scoped_ptr<net::test_server::BasicHttpResponse> http_response( + std::unique_ptr<net::test_server::BasicHttpResponse> http_response( new net::test_server::BasicHttpResponse()); http_response->set_code(net::HTTP_OK); http_response->set_content_type("application/json"); @@ -520,7 +520,7 @@ // This tests that when fetching a Manifest with 'use-credentials' set, the // cookies associated with it are passed along the request. IN_PROC_BROWSER_TEST_F(ManifestBrowserTest, UseCredentialsSendCookies) { - scoped_ptr<net::EmbeddedTestServer> custom_embedded_test_server( + std::unique_ptr<net::EmbeddedTestServer> custom_embedded_test_server( new net::EmbeddedTestServer()); custom_embedded_test_server->RegisterRequestHandler( base::Bind(&CustomHandleRequestForCookies)); @@ -549,10 +549,10 @@ namespace { -scoped_ptr<net::test_server::HttpResponse> CustomHandleRequestForNoCookies( +std::unique_ptr<net::test_server::HttpResponse> CustomHandleRequestForNoCookies( const net::test_server::HttpRequest& request) { if (request.relative_url == "/index.html") { - scoped_ptr<net::test_server::BasicHttpResponse> http_response( + std::unique_ptr<net::test_server::BasicHttpResponse> http_response( new net::test_server::BasicHttpResponse()); http_response->set_code(net::HTTP_OK); http_response->set_content_type("text/html"); @@ -563,9 +563,9 @@ const auto& iter = request.headers.find("Cookie"); if (iter != request.headers.end() || request.relative_url != "/manifest.json") - return scoped_ptr<net::test_server::HttpResponse>(); + return std::unique_ptr<net::test_server::HttpResponse>(); - scoped_ptr<net::test_server::BasicHttpResponse> http_response( + std::unique_ptr<net::test_server::BasicHttpResponse> http_response( new net::test_server::BasicHttpResponse()); http_response->set_code(net::HTTP_OK); http_response->set_content_type("application/json"); @@ -579,7 +579,7 @@ // This tests that when fetching a Manifest without 'use-credentials' set, the // cookies associated with it are not passed along the request. IN_PROC_BROWSER_TEST_F(ManifestBrowserTest, NoUseCredentialsNoCookies) { - scoped_ptr<net::EmbeddedTestServer> custom_embedded_test_server( + std::unique_ptr<net::EmbeddedTestServer> custom_embedded_test_server( new net::EmbeddedTestServer()); custom_embedded_test_server->RegisterRequestHandler( base::Bind(&CustomHandleRequestForNoCookies));
diff --git a/content/browser/memory/memory_pressure_controller_impl_browsertest.cc b/content/browser/memory/memory_pressure_controller_impl_browsertest.cc index d688fd1..6673abe 100644 --- a/content/browser/memory/memory_pressure_controller_impl_browsertest.cc +++ b/content/browser/memory/memory_pressure_controller_impl_browsertest.cc
@@ -17,7 +17,7 @@ MATCHER_P(IsSetSuppressedMessage, suppressed, "") { // Ensure that the message is deleted upon return. - scoped_ptr<IPC::Message> message(arg); + std::unique_ptr<IPC::Message> message(arg); if (message == nullptr) return false; MemoryMsg_SetPressureNotificationsSuppressed::Param param; @@ -29,7 +29,7 @@ MATCHER_P(IsSimulateMessage, level, "") { // Ensure that the message is deleted upon return. - scoped_ptr<IPC::Message> message(arg); + std::unique_ptr<IPC::Message> message(arg); if (message == nullptr) return false; MemoryMsg_SimulatePressureNotification::Param param; @@ -40,7 +40,7 @@ MATCHER_P(IsPressureMessage, level, "") { // Ensure that the message is deleted upon return. - scoped_ptr<IPC::Message> message(arg); + std::unique_ptr<IPC::Message> message(arg); if (message == nullptr) return false; MemoryMsg_PressureNotification::Param param; @@ -216,7 +216,7 @@ SimulatePressureNotificationInAllProcesses) { scoped_refptr<MemoryMessageFilterForTesting> filter( new MemoryMessageFilterForTesting); - scoped_ptr<base::MemoryPressureListener> listener( + std::unique_ptr<base::MemoryPressureListener> listener( new base::MemoryPressureListener( base::Bind(&MemoryPressureControllerImplBrowserTest::OnMemoryPressure, base::Unretained(this))));
diff --git a/content/browser/mojo/mojo_app_connection_impl.cc b/content/browser/mojo/mojo_app_connection_impl.cc index b2941e2a..8e4cd8c5 100644 --- a/content/browser/mojo/mojo_app_connection_impl.cc +++ b/content/browser/mojo/mojo_app_connection_impl.cc
@@ -20,11 +20,11 @@ } // namespace // static -scoped_ptr<MojoAppConnection> MojoAppConnection::Create( +std::unique_ptr<MojoAppConnection> MojoAppConnection::Create( const std::string& user_id, const std::string& name, const std::string& requestor_name) { - return scoped_ptr<MojoAppConnection>( + return std::unique_ptr<MojoAppConnection>( new MojoAppConnectionImpl(user_id, name, requestor_name)); }
diff --git a/content/browser/mojo/mojo_application_host.h b/content/browser/mojo/mojo_application_host.h index 3f3387a..0d7916f 100644 --- a/content/browser/mojo/mojo_application_host.h +++ b/content/browser/mojo/mojo_application_host.h
@@ -5,8 +5,9 @@ #ifndef CONTENT_BROWSER_MOJO_MOJO_APPLICATION_HOST_H_ #define CONTENT_BROWSER_MOJO_MOJO_APPLICATION_HOST_H_ +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/process/process_handle.h" #include "build/build_config.h" #include "content/common/application_setup.mojom.h" @@ -58,13 +59,13 @@ bool did_activate_; - scoped_ptr<mojom::ApplicationSetup> application_setup_; + std::unique_ptr<mojom::ApplicationSetup> application_setup_; ServiceRegistryImpl service_registry_; scoped_refptr<base::TaskRunner> io_task_runner_override_; #if defined(OS_ANDROID) - scoped_ptr<ServiceRegistryAndroid> service_registry_android_; + std::unique_ptr<ServiceRegistryAndroid> service_registry_android_; #endif DISALLOW_COPY_AND_ASSIGN(MojoApplicationHost);
diff --git a/content/browser/mojo/mojo_child_connection.cc b/content/browser/mojo/mojo_child_connection.cc index 164ba0b..ffa7573f 100644 --- a/content/browser/mojo/mojo_child_connection.cc +++ b/content/browser/mojo/mojo_child_connection.cc
@@ -31,20 +31,21 @@ class RenderProcessHostConnection : public base::SupportsUserData::Data { public: - explicit RenderProcessHostConnection(scoped_ptr<mojo::Connection> connection) + explicit RenderProcessHostConnection( + std::unique_ptr<mojo::Connection> connection) : connection_(std::move(connection)) {} ~RenderProcessHostConnection() override {} mojo::Connection* get() const { return connection_.get(); } private: - scoped_ptr<mojo::Connection> connection_; + std::unique_ptr<mojo::Connection> connection_; DISALLOW_COPY_AND_ASSIGN(RenderProcessHostConnection); }; void SetMojoConnection(RenderProcessHost* render_process_host, - scoped_ptr<mojo::Connection> connection) { + std::unique_ptr<mojo::Connection> connection) { render_process_host->SetUserData( kMojoRenderProcessHostConnection, new RenderProcessHostConnection(std::move(connection))); @@ -117,7 +118,7 @@ mojo::Connector::ConnectParams params(target); params.set_client_process_connection(std::move(client), std::move(pid_receiver_request)); - scoped_ptr<mojo::Connection> connection = + std::unique_ptr<mojo::Connection> connection = MojoShellConnection::Get()->GetConnector()->Connect(¶ms); // Store the connection on the RPH so client code can access it later via
diff --git a/content/browser/mojo/mojo_shell_context.cc b/content/browser/mojo/mojo_shell_context.cc index 55ef2985..6e35bad 100644 --- a/content/browser/mojo/mojo_shell_context.cc +++ b/content/browser/mojo/mojo_shell_context.cc
@@ -10,6 +10,7 @@ #include "base/command_line.h" #include "base/lazy_instance.h" #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/path_service.h" #include "base/single_thread_task_runner.h" #include "base/thread_task_runner_handle.h" @@ -235,7 +236,7 @@ }; // static -base::LazyInstance<scoped_ptr<MojoShellContext::Proxy>> +base::LazyInstance<std::unique_ptr<MojoShellContext::Proxy>> MojoShellContext::proxy_ = LAZY_INSTANCE_INITIALIZER; void MojoShellContext::SetApplicationsForTest( @@ -250,7 +251,7 @@ scoped_refptr<base::SingleThreadTaskRunner> file_task_runner = BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE); - scoped_ptr<mojo::shell::NativeRunnerFactory> native_runner_factory( + std::unique_ptr<mojo::shell::NativeRunnerFactory> native_runner_factory( new mojo::shell::InProcessNativeRunnerFactory( BrowserThread::GetBlockingPool())); manifest_provider_.reset(new BuiltinManifestProvider); @@ -259,7 +260,7 @@ shell_.reset(new mojo::shell::Shell(std::move(native_runner_factory), catalog_->TakeShellClient())); shell_->set_default_loader( - scoped_ptr<mojo::shell::Loader>(new DefaultLoader)); + std::unique_ptr<mojo::shell::Loader>(new DefaultLoader)); StaticApplicationMap apps; GetContentClient()->browser()->RegisterInProcessMojoApplications(&apps); @@ -270,8 +271,8 @@ apps[entry.first] = entry.second; } for (const auto& entry : apps) { - shell_->SetLoaderForName( - make_scoped_ptr(new StaticLoader(entry.second)), entry.first); + shell_->SetLoaderForName(base::WrapUnique(new StaticLoader(entry.second)), + entry.first); } ContentBrowserClient::OutOfProcessMojoApplicationMap sandboxed_apps; @@ -279,10 +280,9 @@ ->browser() ->RegisterOutOfProcessMojoApplications(&sandboxed_apps); for (const auto& app : sandboxed_apps) { - shell_->SetLoaderForName( - make_scoped_ptr( - new UtilityProcessLoader(app.second, true /* use_sandbox */)), - app.first); + shell_->SetLoaderForName(base::WrapUnique(new UtilityProcessLoader( + app.second, true /* use_sandbox */)), + app.first); } ContentBrowserClient::OutOfProcessMojoApplicationMap unsandboxed_apps; @@ -290,22 +290,22 @@ ->browser() ->RegisterUnsandboxedOutOfProcessMojoApplications(&unsandboxed_apps); for (const auto& app : unsandboxed_apps) { - shell_->SetLoaderForName( - make_scoped_ptr( - new UtilityProcessLoader(app.second, false /* use_sandbox */)), - app.first); + shell_->SetLoaderForName(base::WrapUnique(new UtilityProcessLoader( + app.second, false /* use_sandbox */)), + app.first); } #if (ENABLE_MOJO_MEDIA_IN_GPU_PROCESS) - shell_->SetLoaderForName(make_scoped_ptr(new GpuProcessLoader), "mojo:media"); + shell_->SetLoaderForName(base::WrapUnique(new GpuProcessLoader), + "mojo:media"); #endif if (base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kMojoLocalStorage)) { - base::Callback<scoped_ptr<mojo::ShellClient>()> profile_callback = + base::Callback<std::unique_ptr<mojo::ShellClient>()> profile_callback = base::Bind(&profile::CreateProfileApp, file_thread, db_thread); shell_->SetLoaderForName( - make_scoped_ptr(new CurrentThreadLoader(profile_callback)), + base::WrapUnique(new CurrentThreadLoader(profile_callback)), "mojo:profile"); } @@ -341,7 +341,8 @@ mojo::shell::mojom::InterfaceProviderRequest request, mojo::shell::mojom::InterfaceProviderPtr exposed_services, const mojo::shell::mojom::Connector::ConnectCallback& callback) { - scoped_ptr<mojo::shell::ConnectParams> params(new mojo::shell::ConnectParams); + std::unique_ptr<mojo::shell::ConnectParams> params( + new mojo::shell::ConnectParams); mojo::Identity source_id(requestor_name, user_id); params->set_source(source_id); params->set_target(mojo::Identity(name, user_id));
diff --git a/content/browser/mojo/mojo_shell_context.h b/content/browser/mojo/mojo_shell_context.h index 959fd93..774bfec 100644 --- a/content/browser/mojo/mojo_shell_context.h +++ b/content/browser/mojo/mojo_shell_context.h
@@ -6,12 +6,12 @@ #define CONTENT_BROWSER_MOJO_MOJO_SHELL_CONTEXT_H_ #include <map> +#include <memory> #include "base/callback_forward.h" #include "base/compiler_specific.h" #include "base/lazy_instance.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/single_thread_task_runner.h" #include "content/common/content_export.h" #include "mojo/shell/public/interfaces/connector.mojom.h" @@ -32,7 +32,8 @@ class CONTENT_EXPORT MojoShellContext { public: using StaticApplicationMap = - std::map<std::string, base::Callback<scoped_ptr<mojo::ShellClient>()>>; + std::map<std::string, + base::Callback<std::unique_ptr<mojo::ShellClient>()>>; MojoShellContext(scoped_refptr<base::SingleThreadTaskRunner> file_thread, scoped_refptr<base::SingleThreadTaskRunner> db_thread); @@ -65,11 +66,11 @@ mojo::shell::mojom::InterfaceProviderPtr exposed_services, const mojo::shell::mojom::Connector::ConnectCallback& callback); - static base::LazyInstance<scoped_ptr<Proxy>> proxy_; + static base::LazyInstance<std::unique_ptr<Proxy>> proxy_; - scoped_ptr<BuiltinManifestProvider> manifest_provider_; - scoped_ptr<catalog::Factory> catalog_; - scoped_ptr<mojo::shell::Shell> shell_; + std::unique_ptr<BuiltinManifestProvider> manifest_provider_; + std::unique_ptr<catalog::Factory> catalog_; + std::unique_ptr<mojo::shell::Shell> shell_; DISALLOW_COPY_AND_ASSIGN(MojoShellContext); };
diff --git a/content/browser/mojo_shell_browsertest.cc b/content/browser/mojo_shell_browsertest.cc index 9777e624..f72cd98 100644 --- a/content/browser/mojo_shell_browsertest.cc +++ b/content/browser/mojo_shell_browsertest.cc
@@ -2,9 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <memory> + #include "base/bind.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/run_loop.h" #include "content/browser/mojo/mojo_shell_context.h" #include "content/public/browser/browser_context.h" @@ -34,8 +35,8 @@ } private: - static scoped_ptr<mojo::ShellClient> CreateTestApp() { - return scoped_ptr<mojo::ShellClient>(new TestMojoApp); + static std::unique_ptr<mojo::ShellClient> CreateTestApp() { + return std::unique_ptr<mojo::ShellClient>(new TestMojoApp); } MojoShellContext::StaticApplicationMap test_apps_;
diff --git a/content/browser/net/network_errors_listing_ui.cc b/content/browser/net/network_errors_listing_ui.cc index cacb3d0e..9f29c286 100644 --- a/content/browser/net/network_errors_listing_ui.cc +++ b/content/browser/net/network_errors_listing_ui.cc
@@ -23,8 +23,8 @@ namespace { -scoped_ptr<base::ListValue> GetNetworkErrorData() { - scoped_ptr<base::DictionaryValue> error_codes = net::GetNetConstants(); +std::unique_ptr<base::ListValue> GetNetworkErrorData() { + std::unique_ptr<base::DictionaryValue> error_codes = net::GetNetConstants(); const base::DictionaryValue* net_error_codes_dict = nullptr; for (base::DictionaryValue::Iterator itr(*error_codes); !itr.IsAtEnd(); @@ -35,7 +35,7 @@ } } - scoped_ptr<base::ListValue> error_list(new base::ListValue()); + std::unique_ptr<base::ListValue> error_list(new base::ListValue()); for (base::DictionaryValue::Iterator itr(*net_error_codes_dict); !itr.IsAtEnd(); itr.Advance()) {
diff --git a/content/browser/net/quota_policy_cookie_store.cc b/content/browser/net/quota_policy_cookie_store.cc index 6767eb8d..c2ab6b0 100644 --- a/content/browser/net/quota_policy_cookie_store.cc +++ b/content/browser/net/quota_policy_cookie_store.cc
@@ -5,13 +5,13 @@ #include "content/browser/net/quota_policy_cookie_store.h" #include <list> +#include <memory> #include "base/bind.h" #include "base/callback.h" #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/profiler/scoped_tracker.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/cookie_store_factory.h" @@ -129,13 +129,13 @@ CookieStoreConfig::~CookieStoreConfig() { } -scoped_ptr<net::CookieStore> CreateCookieStore( +std::unique_ptr<net::CookieStore> CreateCookieStore( const CookieStoreConfig& config) { // TODO(bcwhite): Remove ScopedTracker below once crbug.com/483686 is fixed. tracked_objects::ScopedTracker tracking_profile( FROM_HERE_WITH_EXPLICIT_FUNCTION("483686 content::CreateCookieStore")); - scoped_ptr<net::CookieMonster> cookie_monster; + std::unique_ptr<net::CookieMonster> cookie_monster; if (config.path.empty()) { // Empty path means in-memory store.
diff --git a/content/browser/net/quota_policy_cookie_store_unittest.cc b/content/browser/net/quota_policy_cookie_store_unittest.cc index 01db50f9..3fb8a5b 100644 --- a/content/browser/net/quota_policy_cookie_store_unittest.cc +++ b/content/browser/net/quota_policy_cookie_store_unittest.cc
@@ -121,7 +121,7 @@ } TestBrowserThreadBundle bundle_; - scoped_ptr<base::SequencedWorkerPoolOwner> pool_owner_; + std::unique_ptr<base::SequencedWorkerPoolOwner> pool_owner_; base::WaitableEvent loaded_event_; base::WaitableEvent destroy_event_; base::ScopedTempDir temp_dir_;
diff --git a/content/browser/net/view_blob_internals_job_factory.cc b/content/browser/net/view_blob_internals_job_factory.cc index d15c59f84..2f00bede 100644 --- a/content/browser/net/view_blob_internals_job_factory.cc +++ b/content/browser/net/view_blob_internals_job_factory.cc
@@ -4,7 +4,8 @@ #include "content/browser/net/view_blob_internals_job_factory.h" -#include "base/memory/scoped_ptr.h" +#include <memory> + #include "base/strings/string_util.h" #include "content/public/common/url_constants.h" #include "storage/browser/blob/view_blob_internals_job.h"
diff --git a/content/browser/notifications/notification_database.cc b/content/browser/notifications/notification_database.cc index 4d9f42e..3b4ba9f 100644 --- a/content/browser/notifications/notification_database.cc +++ b/content/browser/notifications/notification_database.cc
@@ -301,7 +301,8 @@ leveldb::Slice prefix_slice(prefix); NotificationDatabaseData notification_database_data; - scoped_ptr<leveldb::Iterator> iter(db_->NewIterator(leveldb::ReadOptions())); + std::unique_ptr<leveldb::Iterator> iter( + db_->NewIterator(leveldb::ReadOptions())); for (iter->Seek(prefix_slice); iter->Valid(); iter->Next()) { if (!iter->key().starts_with(prefix_slice)) break; @@ -338,7 +339,8 @@ leveldb::WriteBatch batch; NotificationDatabaseData notification_database_data; - scoped_ptr<leveldb::Iterator> iter(db_->NewIterator(leveldb::ReadOptions())); + std::unique_ptr<leveldb::Iterator> iter( + db_->NewIterator(leveldb::ReadOptions())); for (iter->Seek(prefix_slice); iter->Valid(); iter->Next()) { if (!iter->key().starts_with(prefix_slice)) break;
diff --git a/content/browser/notifications/notification_database.h b/content/browser/notifications/notification_database.h index e5914e1a..00fae87 100644 --- a/content/browser/notifications/notification_database.h +++ b/content/browser/notifications/notification_database.h
@@ -7,12 +7,12 @@ #include <stdint.h> +#include <memory> #include <set> #include <vector> #include "base/files/file_path.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/sequence_checker.h" #include "content/common/content_export.h" @@ -185,12 +185,12 @@ int64_t next_notification_id_ = 0; - scoped_ptr<const leveldb::FilterPolicy> filter_policy_; + std::unique_ptr<const leveldb::FilterPolicy> filter_policy_; // The declaration order for these members matters, as |db_| depends on |env_| // and thus has to be destructed first. - scoped_ptr<leveldb::Env> env_; - scoped_ptr<leveldb::DB> db_; + std::unique_ptr<leveldb::Env> env_; + std::unique_ptr<leveldb::DB> db_; State state_ = STATE_UNINITIALIZED;
diff --git a/content/browser/notifications/notification_database_unittest.cc b/content/browser/notifications/notification_database_unittest.cc index 40b6950..c08114c 100644 --- a/content/browser/notifications/notification_database_unittest.cc +++ b/content/browser/notifications/notification_database_unittest.cc
@@ -97,7 +97,7 @@ }; TEST_F(NotificationDatabaseTest, OpenCloseMemory) { - scoped_ptr<NotificationDatabase> database(CreateDatabaseInMemory()); + std::unique_ptr<NotificationDatabase> database(CreateDatabaseInMemory()); // Should return false because the database does not exist in memory. EXPECT_EQ(NotificationDatabase::STATUS_ERROR_NOT_FOUND, @@ -121,7 +121,7 @@ base::ScopedTempDir database_dir; ASSERT_TRUE(database_dir.CreateUniqueTempDir()); - scoped_ptr<NotificationDatabase> database( + std::unique_ptr<NotificationDatabase> database( CreateDatabaseOnFileSystem(database_dir.path())); // Should return false because the database does not exist on the file system. @@ -146,7 +146,7 @@ base::ScopedTempDir database_dir; ASSERT_TRUE(database_dir.CreateUniqueTempDir()); - scoped_ptr<NotificationDatabase> database( + std::unique_ptr<NotificationDatabase> database( CreateDatabaseOnFileSystem(database_dir.path())); EXPECT_EQ(NotificationDatabase::STATUS_OK, @@ -168,7 +168,7 @@ base::ScopedTempDir database_dir; ASSERT_TRUE(database_dir.CreateUniqueTempDir()); - scoped_ptr<NotificationDatabase> database( + std::unique_ptr<NotificationDatabase> database( CreateDatabaseOnFileSystem(database_dir.path())); ASSERT_EQ(NotificationDatabase::STATUS_OK, @@ -200,7 +200,7 @@ } TEST_F(NotificationDatabaseTest, NotificationIdIncrementsStorage) { - scoped_ptr<NotificationDatabase> database(CreateDatabaseInMemory()); + std::unique_ptr<NotificationDatabase> database(CreateDatabaseInMemory()); ASSERT_EQ(NotificationDatabase::STATUS_OK, database->Open(true /* create_if_missing */)); @@ -225,7 +225,7 @@ base::ScopedTempDir database_dir; ASSERT_TRUE(database_dir.CreateUniqueTempDir()); - scoped_ptr<NotificationDatabase> database( + std::unique_ptr<NotificationDatabase> database( CreateDatabaseOnFileSystem(database_dir.path())); ASSERT_EQ(NotificationDatabase::STATUS_OK, @@ -253,7 +253,7 @@ } TEST_F(NotificationDatabaseTest, ReadInvalidNotificationData) { - scoped_ptr<NotificationDatabase> database(CreateDatabaseInMemory()); + std::unique_ptr<NotificationDatabase> database(CreateDatabaseInMemory()); ASSERT_EQ(NotificationDatabase::STATUS_OK, database->Open(true /* create_if_missing */)); @@ -267,7 +267,7 @@ } TEST_F(NotificationDatabaseTest, ReadNotificationDataDifferentOrigin) { - scoped_ptr<NotificationDatabase> database(CreateDatabaseInMemory()); + std::unique_ptr<NotificationDatabase> database(CreateDatabaseInMemory()); ASSERT_EQ(NotificationDatabase::STATUS_OK, database->Open(true /* create_if_missing */)); @@ -299,7 +299,7 @@ } TEST_F(NotificationDatabaseTest, ReadNotificationDataReflection) { - scoped_ptr<NotificationDatabase> database(CreateDatabaseInMemory()); + std::unique_ptr<NotificationDatabase> database(CreateDatabaseInMemory()); ASSERT_EQ(NotificationDatabase::STATUS_OK, database->Open(true /* create_if_missing */)); @@ -356,7 +356,7 @@ } TEST_F(NotificationDatabaseTest, ReadWriteMultipleNotificationData) { - scoped_ptr<NotificationDatabase> database(CreateDatabaseInMemory()); + std::unique_ptr<NotificationDatabase> database(CreateDatabaseInMemory()); ASSERT_EQ(NotificationDatabase::STATUS_OK, database->Open(true /* create_if_missing */)); @@ -385,7 +385,7 @@ } TEST_F(NotificationDatabaseTest, DeleteInvalidNotificationData) { - scoped_ptr<NotificationDatabase> database(CreateDatabaseInMemory()); + std::unique_ptr<NotificationDatabase> database(CreateDatabaseInMemory()); ASSERT_EQ(NotificationDatabase::STATUS_OK, database->Open(true /* create_if_missing */)); @@ -395,7 +395,7 @@ } TEST_F(NotificationDatabaseTest, DeleteNotificationDataSameOrigin) { - scoped_ptr<NotificationDatabase> database(CreateDatabaseInMemory()); + std::unique_ptr<NotificationDatabase> database(CreateDatabaseInMemory()); ASSERT_EQ(NotificationDatabase::STATUS_OK, database->Open(true /* create_if_missing */)); @@ -423,7 +423,7 @@ } TEST_F(NotificationDatabaseTest, DeleteNotificationDataDifferentOrigin) { - scoped_ptr<NotificationDatabase> database(CreateDatabaseInMemory()); + std::unique_ptr<NotificationDatabase> database(CreateDatabaseInMemory()); ASSERT_EQ(NotificationDatabase::STATUS_OK, database->Open(true /* create_if_missing */)); @@ -450,7 +450,7 @@ } TEST_F(NotificationDatabaseTest, ReadAllNotificationData) { - scoped_ptr<NotificationDatabase> database(CreateDatabaseInMemory()); + std::unique_ptr<NotificationDatabase> database(CreateDatabaseInMemory()); ASSERT_EQ(NotificationDatabase::STATUS_OK, database->Open(true /* create_if_missing */)); @@ -464,7 +464,7 @@ } TEST_F(NotificationDatabaseTest, ReadAllNotificationDataEmpty) { - scoped_ptr<NotificationDatabase> database(CreateDatabaseInMemory()); + std::unique_ptr<NotificationDatabase> database(CreateDatabaseInMemory()); ASSERT_EQ(NotificationDatabase::STATUS_OK, database->Open(true /* create_if_missing */)); @@ -476,7 +476,7 @@ } TEST_F(NotificationDatabaseTest, ReadAllNotificationDataForOrigin) { - scoped_ptr<NotificationDatabase> database(CreateDatabaseInMemory()); + std::unique_ptr<NotificationDatabase> database(CreateDatabaseInMemory()); ASSERT_EQ(NotificationDatabase::STATUS_OK, database->Open(true /* create_if_missing */)); @@ -493,7 +493,7 @@ TEST_F(NotificationDatabaseTest, ReadAllNotificationDataForServiceWorkerRegistration) { - scoped_ptr<NotificationDatabase> database(CreateDatabaseInMemory()); + std::unique_ptr<NotificationDatabase> database(CreateDatabaseInMemory()); ASSERT_EQ(NotificationDatabase::STATUS_OK, database->Open(true /* create_if_missing */)); @@ -510,7 +510,7 @@ } TEST_F(NotificationDatabaseTest, DeleteAllNotificationDataForOrigin) { - scoped_ptr<NotificationDatabase> database(CreateDatabaseInMemory()); + std::unique_ptr<NotificationDatabase> database(CreateDatabaseInMemory()); ASSERT_EQ(NotificationDatabase::STATUS_OK, database->Open(true /* create_if_missing */)); @@ -533,7 +533,7 @@ } TEST_F(NotificationDatabaseTest, DeleteAllNotificationDataForOriginEmpty) { - scoped_ptr<NotificationDatabase> database(CreateDatabaseInMemory()); + std::unique_ptr<NotificationDatabase> database(CreateDatabaseInMemory()); ASSERT_EQ(NotificationDatabase::STATUS_OK, database->Open(true /* create_if_missing */)); @@ -549,7 +549,7 @@ TEST_F(NotificationDatabaseTest, DeleteAllNotificationDataForServiceWorkerRegistration) { - scoped_ptr<NotificationDatabase> database(CreateDatabaseInMemory()); + std::unique_ptr<NotificationDatabase> database(CreateDatabaseInMemory()); ASSERT_EQ(NotificationDatabase::STATUS_OK, database->Open(true /* create_if_missing */));
diff --git a/content/browser/notifications/notification_message_filter.cc b/content/browser/notifications/notification_message_filter.cc index 0829750..b2fd920 100644 --- a/content/browser/notifications/notification_message_filter.cc +++ b/content/browser/notifications/notification_message_filter.cc
@@ -141,7 +141,7 @@ return; } - scoped_ptr<DesktopNotificationDelegate> delegate( + std::unique_ptr<DesktopNotificationDelegate> delegate( new PageNotificationDelegate(process_id_, notification_id)); PlatformNotificationService* service =
diff --git a/content/browser/notifications/platform_notification_context_impl.h b/content/browser/notifications/platform_notification_context_impl.h index 250a2d83..f2eb599f 100644 --- a/content/browser/notifications/platform_notification_context_impl.h +++ b/content/browser/notifications/platform_notification_context_impl.h
@@ -148,7 +148,7 @@ scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; scoped_refptr<base::SequencedTaskRunner> task_runner_; - scoped_ptr<NotificationDatabase> database_; + std::unique_ptr<NotificationDatabase> database_; // Indicates whether the database should be pruned when it's opened. bool prune_database_on_open_ = false;
diff --git a/content/browser/notifications/platform_notification_context_unittest.cc b/content/browser/notifications/platform_notification_context_unittest.cc index c3a2e54..163213e 100644 --- a/content/browser/notifications/platform_notification_context_unittest.cc +++ b/content/browser/notifications/platform_notification_context_unittest.cc
@@ -228,7 +228,7 @@ } TEST_F(PlatformNotificationContextTest, ServiceWorkerUnregistered) { - scoped_ptr<EmbeddedWorkerTestHelper> embedded_worker_test_helper( + std::unique_ptr<EmbeddedWorkerTestHelper> embedded_worker_test_helper( new EmbeddedWorkerTestHelper(base::FilePath())); // Manually create the PlatformNotificationContextImpl so that the Service
diff --git a/content/browser/plugin_data_remover_impl.cc b/content/browser/plugin_data_remover_impl.cc index 5299f6bf..e927399 100644 --- a/content/browser/plugin_data_remover_impl.cc +++ b/content/browser/plugin_data_remover_impl.cc
@@ -234,7 +234,7 @@ event_->Signal(); } - scoped_ptr<base::WaitableEvent> event_; + std::unique_ptr<base::WaitableEvent> event_; // The point in time when we start removing data. base::Time remove_start_time_; // The point in time from which on we remove data. @@ -250,7 +250,7 @@ // The channel is NULL until we have opened a connection to the plugin // process. - scoped_ptr<IPC::Channel> channel_; + std::unique_ptr<IPC::Channel> channel_; };
diff --git a/content/browser/plugin_service_impl.h b/content/browser/plugin_service_impl.h index e167cc3..25f5719b 100644 --- a/content/browser/plugin_service_impl.h +++ b/content/browser/plugin_service_impl.h
@@ -13,6 +13,7 @@ #endif #include <map> +#include <memory> #include <set> #include <vector> @@ -32,7 +33,6 @@ #include "url/gurl.h" #if defined(OS_WIN) -#include "base/memory/scoped_ptr.h" #include "base/win/registry.h" #endif
diff --git a/content/browser/power_monitor_message_broadcaster_unittest.cc b/content/browser/power_monitor_message_broadcaster_unittest.cc index 72e2729..c843f35 100644 --- a/content/browser/power_monitor_message_broadcaster_unittest.cc +++ b/content/browser/power_monitor_message_broadcaster_unittest.cc
@@ -52,7 +52,7 @@ PowerMonitorMessageBroadcasterTest() { power_monitor_source_ = new base::PowerMonitorTestSource(); power_monitor_.reset(new base::PowerMonitor( - scoped_ptr<base::PowerMonitorSource>(power_monitor_source_))); + std::unique_ptr<base::PowerMonitorSource>(power_monitor_source_))); } ~PowerMonitorMessageBroadcasterTest() override {} @@ -61,7 +61,7 @@ private: base::PowerMonitorTestSource* power_monitor_source_; - scoped_ptr<base::PowerMonitor> power_monitor_; + std::unique_ptr<base::PowerMonitor> power_monitor_; DISALLOW_COPY_AND_ASSIGN(PowerMonitorMessageBroadcasterTest); };
diff --git a/content/browser/power_save_blocker_impl.cc b/content/browser/power_save_blocker_impl.cc index 069cd3a3..52cb6a1d 100644 --- a/content/browser/power_save_blocker_impl.cc +++ b/content/browser/power_save_blocker_impl.cc
@@ -10,11 +10,11 @@ PowerSaveBlocker::~PowerSaveBlocker() {} // static -scoped_ptr<PowerSaveBlocker> PowerSaveBlocker::Create( +std::unique_ptr<PowerSaveBlocker> PowerSaveBlocker::Create( PowerSaveBlockerType type, Reason reason, const std::string& description) { - return scoped_ptr<PowerSaveBlocker>( + return std::unique_ptr<PowerSaveBlocker>( new PowerSaveBlockerImpl(type, reason, description)); }
diff --git a/content/browser/power_save_blocker_x11.cc b/content/browser/power_save_blocker_x11.cc index babc814..e80265c 100644 --- a/content/browser/power_save_blocker_x11.cc +++ b/content/browser/power_save_blocker_x11.cc
@@ -2,12 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/browser/power_save_blocker_impl.h" - #include <X11/Xlib.h> -#include <stdint.h> #include <X11/extensions/dpms.h> #include <X11/extensions/scrnsaver.h> +#include <stdint.h> + +#include <memory> + +#include "content/browser/power_save_blocker_impl.h" // Xlib #defines Status, but we can't have that for some of our headers. #ifdef Status #undef Status @@ -21,7 +23,6 @@ #include "base/logging.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/singleton.h" #include "base/nix/xdg_util.h" #include "base/synchronization/lock.h" @@ -236,8 +237,8 @@ bus_ = new dbus::Bus(options); scoped_refptr<dbus::ObjectProxy> object_proxy; - scoped_ptr<dbus::MethodCall> method_call; - scoped_ptr<dbus::MessageWriter> message_writer; + std::unique_ptr<dbus::MethodCall> method_call; + std::unique_ptr<dbus::MessageWriter> message_writer; switch (api_) { case NO_API: @@ -347,7 +348,7 @@ } scoped_refptr<dbus::ObjectProxy> object_proxy; - scoped_ptr<dbus::MethodCall> method_call; + std::unique_ptr<dbus::MethodCall> method_call; switch (api_) { case NO_API: @@ -448,7 +449,7 @@ // static DBusAPI PowerSaveBlockerImpl::Delegate::SelectAPI() { DCHECK_CURRENTLY_ON(BrowserThread::UI); - scoped_ptr<base::Environment> env(base::Environment::Create()); + std::unique_ptr<base::Environment> env(base::Environment::Create()); switch (base::nix::GetDesktopEnvironment(env.get())) { case base::nix::DESKTOP_ENVIRONMENT_GNOME: case base::nix::DESKTOP_ENVIRONMENT_UNITY:
diff --git a/content/browser/power_usage_monitor_impl.cc b/content/browser/power_usage_monitor_impl.cc index 65d4d9dd..1a79826 100644 --- a/content/browser/power_usage_monitor_impl.cc +++ b/content/browser/power_usage_monitor_impl.cc
@@ -249,7 +249,7 @@ } void PowerUsageMonitor::SetSystemInterfaceForTest( - scoped_ptr<SystemInterface> interface) { + std::unique_ptr<SystemInterface> interface) { system_interface_ = std::move(interface); }
diff --git a/content/browser/power_usage_monitor_impl.h b/content/browser/power_usage_monitor_impl.h index 0e3b4e30..a2c7e96 100644 --- a/content/browser/power_usage_monitor_impl.h +++ b/content/browser/power_usage_monitor_impl.h
@@ -63,7 +63,7 @@ // system boot. void Start(); - void SetSystemInterfaceForTest(scoped_ptr<SystemInterface> interface); + void SetSystemInterfaceForTest(std::unique_ptr<SystemInterface> interface); // Overridden from base::PowerObserver: void OnPowerStateChange(bool on_battery_power) override; @@ -93,12 +93,12 @@ void CancelPendingHistogramReporting(); device::BatteryStatusService::BatteryUpdateCallback callback_; - scoped_ptr<device::BatteryStatusService::BatteryUpdateSubscription> + std::unique_ptr<device::BatteryStatusService::BatteryUpdateSubscription> subscription_; NotificationRegistrar registrar_; - scoped_ptr<SystemInterface> system_interface_; + std::unique_ptr<SystemInterface> system_interface_; // True if monitoring was started (Start() called). bool started_;
diff --git a/content/browser/power_usage_monitor_impl_unittest.cc b/content/browser/power_usage_monitor_impl_unittest.cc index 2aac5859..1b3446f 100644 --- a/content/browser/power_usage_monitor_impl_unittest.cc +++ b/content/browser/power_usage_monitor_impl_unittest.cc
@@ -65,7 +65,7 @@ void SetUp() override { monitor_.reset(new PowerUsageMonitor); // PowerUsageMonitor assumes ownership. - scoped_ptr<SystemInterfaceForTest> test_interface( + std::unique_ptr<SystemInterfaceForTest> test_interface( new SystemInterfaceForTest()); system_interface_ = test_interface.get(); monitor_->SetSystemInterfaceForTest(std::move(test_interface)); @@ -87,7 +87,7 @@ NOTIFICATION_RENDERER_PROCESS_CLOSED, kDummyRenderProcessHostID); } - scoped_ptr<PowerUsageMonitor> monitor_; + std::unique_ptr<PowerUsageMonitor> monitor_; SystemInterfaceForTest* system_interface_; TestBrowserThreadBundle thread_bundle_; };
diff --git a/content/browser/ppapi_plugin_process_host.h b/content/browser/ppapi_plugin_process_host.h index 85e2b64d..7c64901 100644 --- a/content/browser/ppapi_plugin_process_host.h +++ b/content/browser/ppapi_plugin_process_host.h
@@ -7,13 +7,13 @@ #include <stdint.h> +#include <memory> #include <queue> #include <vector> #include "base/files/file_path.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/process/process.h" #include "base/strings/string16.h" #include "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h" @@ -154,10 +154,10 @@ scoped_refptr<PepperMessageFilter> filter_; ppapi::PpapiPermissions permissions_; - scoped_ptr<BrowserPpapiHostImpl> host_impl_; + std::unique_ptr<BrowserPpapiHostImpl> host_impl_; // Observes network changes. May be NULL. - scoped_ptr<PluginNetworkObserver> network_observer_; + std::unique_ptr<PluginNetworkObserver> network_observer_; // Channel requests that we are waiting to send to the plugin process once // the channel is opened. @@ -175,7 +175,7 @@ const bool is_broker_; - scoped_ptr<BrowserChildProcessHostImpl> process_; + std::unique_ptr<BrowserChildProcessHostImpl> process_; DISALLOW_COPY_AND_ASSIGN(PpapiPluginProcessHost); };
diff --git a/content/browser/presentation/presentation_service_impl.cc b/content/browser/presentation/presentation_service_impl.cc index ee77e360..53d8dcb1 100644 --- a/content/browser/presentation/presentation_service_impl.cc +++ b/content/browser/presentation/presentation_service_impl.cc
@@ -65,10 +65,10 @@ return output; } -scoped_ptr<PresentationSessionMessage> GetPresentationSessionMessage( +std::unique_ptr<PresentationSessionMessage> GetPresentationSessionMessage( mojom::SessionMessagePtr input) { DCHECK(!input.is_null()); - scoped_ptr<content::PresentationSessionMessage> output; + std::unique_ptr<content::PresentationSessionMessage> output; switch (input->type) { case mojom::PresentationMessageType::TEXT: { DCHECK(!input->message.is_null()); @@ -194,7 +194,7 @@ if (screen_availability_listeners_.count(availability_url)) return; - scoped_ptr<ScreenAvailabilityListenerImpl> listener( + std::unique_ptr<ScreenAvailabilityListenerImpl> listener( new ScreenAvailabilityListenerImpl(availability_url, this)); if (delegate_->AddScreenAvailabilityListener( render_process_id_,
diff --git a/content/browser/presentation/presentation_service_impl.h b/content/browser/presentation/presentation_service_impl.h index b0243353..ebb1ef12 100644 --- a/content/browser/presentation/presentation_service_impl.h +++ b/content/browser/presentation/presentation_service_impl.h
@@ -7,6 +7,7 @@ #include <deque> #include <map> +#include <memory> #include <string> #include "base/compiler_specific.h" @@ -14,7 +15,6 @@ #include "base/gtest_prod_util.h" #include "base/macros.h" #include "base/memory/linked_ptr.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_vector.h" #include "base/memory/weak_ptr.h" #include "content/common/content_export.h" @@ -257,13 +257,13 @@ std::string default_presentation_url_; using ScreenAvailabilityListenerMap = - std::map<std::string, scoped_ptr<ScreenAvailabilityListenerImpl>>; + std::map<std::string, std::unique_ptr<ScreenAvailabilityListenerImpl>>; ScreenAvailabilityListenerMap screen_availability_listeners_; // For StartSession requests. // Set to a positive value when a StartSession request is being processed. int start_session_request_id_; - scoped_ptr<NewSessionMojoCallbackWrapper> pending_start_session_cb_; + std::unique_ptr<NewSessionMojoCallbackWrapper> pending_start_session_cb_; // For JoinSession requests. base::hash_map<int, linked_ptr<NewSessionMojoCallbackWrapper>> @@ -271,12 +271,12 @@ // RAII binding of |this| to an Presentation interface request. // The binding is removed when binding_ is cleared or goes out of scope. - scoped_ptr<mojo::Binding<mojom::PresentationService>> binding_; + std::unique_ptr<mojo::Binding<mojom::PresentationService>> binding_; // There can be only one send message request at a time. - scoped_ptr<SendMessageMojoCallback> send_message_callback_; + std::unique_ptr<SendMessageMojoCallback> send_message_callback_; - scoped_ptr<SessionMessagesCallback> on_session_messages_callback_; + std::unique_ptr<SessionMessagesCallback> on_session_messages_callback_; // ID of the RenderFrameHost this object is associated with. int render_process_id_;
diff --git a/content/browser/presentation/presentation_service_impl_unittest.cc b/content/browser/presentation/presentation_service_impl_unittest.cc index e25190bd..172e8b5 100644 --- a/content/browser/presentation/presentation_service_impl_unittest.cc +++ b/content/browser/presentation/presentation_service_impl_unittest.cc
@@ -6,12 +6,13 @@ #include <stddef.h> #include <stdint.h> + +#include <memory> #include <string> #include <utility> #include <vector> #include "base/location.h" -#include "base/memory/scoped_ptr.h" #include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/test/test_timeouts.h" @@ -126,7 +127,7 @@ void SendMessage(int render_process_id, int render_frame_id, const content::PresentationSessionInfo& session, - scoped_ptr<PresentationSessionMessage> message_request, + std::unique_ptr<PresentationSessionMessage> message_request, const SendMessageCallback& send_message_cb) override { SendMessageRawPtr(render_process_id, render_frame_id, session, message_request.release(), send_message_cb); @@ -334,7 +335,7 @@ } ScopedVector<PresentationSessionMessage> messages; - scoped_ptr<content::PresentationSessionMessage> message; + std::unique_ptr<content::PresentationSessionMessage> message; message.reset( new content::PresentationSessionMessage(PresentationMessageType::TEXT)); message->message = text_msg; @@ -357,11 +358,12 @@ MockPresentationServiceDelegate mock_delegate_; - scoped_ptr<PresentationServiceImpl> service_impl_; + std::unique_ptr<PresentationServiceImpl> service_impl_; mojo::InterfacePtr<mojom::PresentationService> service_ptr_; MockPresentationServiceClient mock_client_; - scoped_ptr<mojo::Binding<mojom::PresentationServiceClient>> client_binding_; + std::unique_ptr<mojo::Binding<mojom::PresentationServiceClient>> + client_binding_; base::Closure run_loop_quit_closure_; int default_session_started_count_; @@ -686,7 +688,7 @@ run_loop.Run(); // Make sure |test_message| gets deleted. - scoped_ptr<PresentationSessionMessage> scoped_test_message(test_message); + std::unique_ptr<PresentationSessionMessage> scoped_test_message(test_message); EXPECT_TRUE(test_message); EXPECT_FALSE(test_message->is_binary()); EXPECT_LE(test_message->message.size(), kMaxPresentationSessionMessageSize); @@ -723,7 +725,7 @@ run_loop.Run(); // Make sure |test_message| gets deleted. - scoped_ptr<PresentationSessionMessage> scoped_test_message(test_message); + std::unique_ptr<PresentationSessionMessage> scoped_test_message(test_message); EXPECT_TRUE(test_message); EXPECT_TRUE(test_message->is_binary()); EXPECT_EQ(PresentationMessageType::ARRAY_BUFFER, test_message->type); @@ -796,7 +798,7 @@ run_loop.Run(); // Make sure |test_message| gets deleted. - scoped_ptr<PresentationSessionMessage> scoped_test_message(test_message); + std::unique_ptr<PresentationSessionMessage> scoped_test_message(test_message); EXPECT_TRUE(test_message); EXPECT_TRUE(test_message->is_binary()); EXPECT_EQ(PresentationMessageType::BLOB, test_message->type);
diff --git a/content/browser/push_messaging/push_messaging_message_filter.cc b/content/browser/push_messaging/push_messaging_message_filter.cc index 26184cf0..107b06f 100644 --- a/content/browser/push_messaging/push_messaging_message_filter.cc +++ b/content/browser/push_messaging/push_messaging_message_filter.cc
@@ -12,6 +12,7 @@ #include "base/command_line.h" #include "base/logging.h" #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/metrics/histogram.h" #include "base/strings/string_number_conversions.h" #include "content/browser/renderer_host/render_process_host_impl.h" @@ -968,10 +969,11 @@ BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&PushMessagingMessageFilter::SendIPC, io_parent_, - base::Passed(make_scoped_ptr(message)))); + base::Passed(base::WrapUnique(message)))); } -void PushMessagingMessageFilter::SendIPC(scoped_ptr<IPC::Message> message) { +void PushMessagingMessageFilter::SendIPC( + std::unique_ptr<IPC::Message> message) { Send(message.release()); }
diff --git a/content/browser/push_messaging/push_messaging_message_filter.h b/content/browser/push_messaging/push_messaging_message_filter.h index d2db18a..77548ea0 100644 --- a/content/browser/push_messaging/push_messaging_message_filter.h +++ b/content/browser/push_messaging/push_messaging_message_filter.h
@@ -6,11 +6,12 @@ #define CONTENT_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_MESSAGE_FILTER_H_ #include <stdint.h> + +#include <memory> #include <string> #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "content/common/service_worker/service_worker_status_code.h" #include "content/public/browser/browser_message_filter.h" @@ -162,10 +163,10 @@ // Helper methods on IO thread ----------------------------------------------- // Called via PostTask from UI thread. - void SendIPC(scoped_ptr<IPC::Message> message); + void SendIPC(std::unique_ptr<IPC::Message> message); // Inner core of this message filter which lives on the UI thread. - scoped_ptr<Core, BrowserThread::DeleteOnUIThread> ui_core_; + std::unique_ptr<Core, BrowserThread::DeleteOnUIThread> ui_core_; scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_;
diff --git a/content/browser/quota/mock_quota_manager.cc b/content/browser/quota/mock_quota_manager.cc index 9067408..ee34a504 100644 --- a/content/browser/quota/mock_quota_manager.cc +++ b/content/browser/quota/mock_quota_manager.cc
@@ -5,10 +5,10 @@ #include "content/browser/quota/mock_quota_manager.h" #include <limits> +#include <memory> #include "base/location.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/single_thread_task_runner.h" #include "base/thread_task_runner_handle.h" #include "url/gurl.h"
diff --git a/content/browser/quota/mock_quota_manager.h b/content/browser/quota/mock_quota_manager.h index 9dfd779c..172b7e92 100644 --- a/content/browser/quota/mock_quota_manager.h +++ b/content/browser/quota/mock_quota_manager.h
@@ -8,12 +8,12 @@ #include <stdint.h> #include <map> +#include <memory> #include <set> #include <utility> #include <vector> #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "storage/browser/quota/quota_client.h" #include "storage/browser/quota/quota_manager.h" #include "storage/browser/quota/quota_task.h"
diff --git a/content/browser/quota/mock_quota_manager_unittest.cc b/content/browser/quota/mock_quota_manager_unittest.cc index 9a46cf3..3a31a2b 100644 --- a/content/browser/quota/mock_quota_manager_unittest.cc +++ b/content/browser/quota/mock_quota_manager_unittest.cc
@@ -2,16 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/browser/quota/mock_quota_manager.h" + +#include <memory> #include <set> #include "base/bind.h" #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/run_loop.h" #include "base/thread_task_runner_handle.h" -#include "content/browser/quota/mock_quota_manager.h" #include "content/public/test/mock_special_storage_policy.h" #include "content/public/test/mock_storage_client.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/content/browser/quota/quota_backend_impl_unittest.cc b/content/browser/quota/quota_backend_impl_unittest.cc index 5dfa0371..c779096 100644 --- a/content/browser/quota/quota_backend_impl_unittest.cc +++ b/content/browser/quota/quota_backend_impl_unittest.cc
@@ -6,11 +6,11 @@ #include <stdint.h> +#include <memory> #include <string> #include "base/files/scoped_temp_dir.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/thread_task_runner_handle.h" #include "storage/browser/fileapi/file_system_usage_cache.h" #include "storage/browser/fileapi/obfuscated_file_util.h" @@ -148,11 +148,11 @@ base::MessageLoop message_loop_; base::ScopedTempDir data_dir_; - scoped_ptr<leveldb::Env> in_memory_env_; - scoped_ptr<ObfuscatedFileUtil> file_util_; + std::unique_ptr<leveldb::Env> in_memory_env_; + std::unique_ptr<ObfuscatedFileUtil> file_util_; FileSystemUsageCache file_system_usage_cache_; scoped_refptr<MockQuotaManagerProxy> quota_manager_proxy_; - scoped_ptr<QuotaBackendImpl> backend_; + std::unique_ptr<QuotaBackendImpl> backend_; private: DISALLOW_COPY_AND_ASSIGN(QuotaBackendImplTest);
diff --git a/content/browser/quota/quota_database_unittest.cc b/content/browser/quota/quota_database_unittest.cc index 026a46a4..0ec69dd 100644 --- a/content/browser/quota/quota_database_unittest.cc +++ b/content/browser/quota/quota_database_unittest.cc
@@ -535,8 +535,8 @@ const base::FilePath& kDbFile, const QuotaTableEntry* entries, size_t entries_size) { - scoped_ptr<sql::Connection> db(new sql::Connection); - scoped_ptr<sql::MetaTable> meta_table(new sql::MetaTable); + std::unique_ptr<sql::Connection> db(new sql::Connection); + std::unique_ptr<sql::MetaTable> meta_table(new sql::MetaTable); // V2 schema definitions. static const int kCurrentVersion = 2;
diff --git a/content/browser/quota/quota_manager_unittest.cc b/content/browser/quota/quota_manager_unittest.cc index 665acd9..fcf2ea8 100644 --- a/content/browser/quota/quota_manager_unittest.cc +++ b/content/browser/quota/quota_manager_unittest.cc
@@ -6,6 +6,7 @@ #include <stdint.h> #include <algorithm> +#include <memory> #include <set> #include <sstream> #include <vector> @@ -14,7 +15,7 @@ #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" +#include "base/memory/ptr_util.h" #include "base/memory/weak_ptr.h" #include "base/run_loop.h" #include "base/stl_util.h" @@ -1302,7 +1303,7 @@ TEST_F(QuotaManagerTest, SetTemporaryStorageEvictionPolicy) { quota_manager()->SetTemporaryStorageEvictionPolicy( - make_scoped_ptr(new TestEvictionPolicy)); + base::WrapUnique(new TestEvictionPolicy)); GetEvictionOrigin(kTemp); base::RunLoop().RunUntilIdle();
diff --git a/content/browser/quota/quota_reservation_manager_unittest.cc b/content/browser/quota/quota_reservation_manager_unittest.cc index 2a9d2e4..5199e7f 100644 --- a/content/browser/quota/quota_reservation_manager_unittest.cc +++ b/content/browser/quota/quota_reservation_manager_unittest.cc
@@ -3,6 +3,8 @@ // found in the LICENSE file. #include <stdint.h> + +#include <memory> #include <utility> #include "base/bind.h" @@ -12,7 +14,6 @@ #include "base/files/scoped_temp_dir.h" #include "base/location.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/thread_task_runner_handle.h" @@ -102,7 +103,7 @@ class FakeWriter { public: - explicit FakeWriter(scoped_ptr<OpenFileHandle> handle) + explicit FakeWriter(std::unique_ptr<OpenFileHandle> handle) : handle_(std::move(handle)), path_(handle_->platform_path()), max_written_offset_(handle_->GetEstimatedFileSize()), @@ -158,7 +159,7 @@ } private: - scoped_ptr<OpenFileHandle> handle_; + std::unique_ptr<OpenFileHandle> handle_; base::FilePath path_; int64_t max_written_offset_; int64_t append_mode_write_amount_; @@ -192,7 +193,8 @@ file_path_ = work_dir_.path().Append(FILE_PATH_LITERAL("hoge")); SetFileSize(file_path_, kInitialFileSize); - scoped_ptr<QuotaReservationManager::QuotaBackend> backend(new FakeBackend); + std::unique_ptr<QuotaReservationManager::QuotaBackend> backend( + new FakeBackend); reservation_manager_.reset(new QuotaReservationManager(std::move(backend))); } @@ -214,7 +216,7 @@ base::MessageLoop message_loop_; base::ScopedTempDir work_dir_; base::FilePath file_path_; - scoped_ptr<QuotaReservationManager> reservation_manager_; + std::unique_ptr<QuotaReservationManager> reservation_manager_; DISALLOW_COPY_AND_ASSIGN(QuotaReservationManagerTest); }; @@ -305,10 +307,10 @@ RefreshReservation(reservation2.get(), 20); int64_t cached_reserved_quota2 = reservation2->remaining_quota(); - scoped_ptr<FakeWriter> writer1( + std::unique_ptr<FakeWriter> writer1( new FakeWriter(reservation1->GetOpenFileHandle(file_path()))); - scoped_ptr<FakeWriter> writer2( + std::unique_ptr<FakeWriter> writer2( new FakeWriter(reservation2->GetOpenFileHandle(file_path()))); cached_reserved_quota1 -= writer1->Write(kInitialFileSize + 10);
diff --git a/content/browser/quota/quota_temporary_storage_evictor_unittest.cc b/content/browser/quota/quota_temporary_storage_evictor_unittest.cc index 351c8a1b..989c63d 100644 --- a/content/browser/quota/quota_temporary_storage_evictor_unittest.cc +++ b/content/browser/quota/quota_temporary_storage_evictor_unittest.cc
@@ -6,12 +6,12 @@ #include <list> #include <map> +#include <memory> #include <utility> #include "base/bind.h" #include "base/callback.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/run_loop.h" #include "content/public/test/mock_storage_client.h" @@ -224,8 +224,8 @@ } base::MessageLoop message_loop_; - scoped_ptr<MockQuotaEvictionHandler> quota_eviction_handler_; - scoped_ptr<QuotaTemporaryStorageEvictor> temporary_storage_evictor_; + std::unique_ptr<MockQuotaEvictionHandler> quota_eviction_handler_; + std::unique_ptr<QuotaTemporaryStorageEvictor> temporary_storage_evictor_; int num_get_usage_and_quota_for_eviction_;
diff --git a/content/browser/renderer_host/begin_frame_observer_proxy_unittest.cc b/content/browser/renderer_host/begin_frame_observer_proxy_unittest.cc index 9ba78c4..56e89760 100644 --- a/content/browser/renderer_host/begin_frame_observer_proxy_unittest.cc +++ b/content/browser/renderer_host/begin_frame_observer_proxy_unittest.cc
@@ -2,15 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/browser/renderer_host/begin_frame_observer_proxy.h" + #include <algorithm> #include <list> +#include <memory> #include "base/compiler_specific.h" -#include "base/memory/scoped_ptr.h" #include "base/test/test_simple_task_runner.h" #include "cc/output/begin_frame_args.h" #include "cc/test/begin_frame_args_test.h" -#include "content/browser/renderer_host/begin_frame_observer_proxy.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/compositor/compositor.h" @@ -51,7 +52,7 @@ private: scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; - scoped_ptr<ui::Compositor> compositor_; + std::unique_ptr<ui::Compositor> compositor_; }; } // namespace
diff --git a/content/browser/renderer_host/browser_compositor_view_mac.h b/content/browser/renderer_host/browser_compositor_view_mac.h index 9ad7e48..7d17e8a4 100644 --- a/content/browser/renderer_host/browser_compositor_view_mac.h +++ b/content/browser/renderer_host/browser_compositor_view_mac.h
@@ -21,10 +21,10 @@ virtual ~BrowserCompositorMac(); // Create a compositor, or recycle a preexisting one. - static scoped_ptr<BrowserCompositorMac> Create(); + static std::unique_ptr<BrowserCompositorMac> Create(); // Delete a compositor, or allow it to be recycled. - static void Recycle(scoped_ptr<BrowserCompositorMac> compositor); + static void Recycle(std::unique_ptr<BrowserCompositorMac> compositor); // Indicate that the recyclable compositor should be destroyed, and no future // compositors should be recycled. @@ -53,7 +53,7 @@ void OnCompositingLockStateChanged(ui::Compositor* compositor) override {} void OnCompositingShuttingDown(ui::Compositor* compositor) override {} - scoped_ptr<ui::AcceleratedWidgetMac> accelerated_widget_mac_; + std::unique_ptr<ui::AcceleratedWidgetMac> accelerated_widget_mac_; ui::Compositor compositor_; scoped_refptr<ui::CompositorLock> compositor_suspended_lock_;
diff --git a/content/browser/renderer_host/browser_compositor_view_mac.mm b/content/browser/renderer_host/browser_compositor_view_mac.mm index 92ac2e7..6002eca 100644 --- a/content/browser/renderer_host/browser_compositor_view_mac.mm +++ b/content/browser/renderer_host/browser_compositor_view_mac.mm
@@ -31,7 +31,7 @@ uint32_t g_placeholder_count = 0; // A spare BrowserCompositorMac kept around for recycling. -base::LazyInstance<scoped_ptr<BrowserCompositorMac>> +base::LazyInstance<std::unique_ptr<BrowserCompositorMac>> g_recyclable_browser_compositor; } // namespace @@ -67,16 +67,16 @@ } // static -scoped_ptr<BrowserCompositorMac> BrowserCompositorMac::Create() { +std::unique_ptr<BrowserCompositorMac> BrowserCompositorMac::Create() { DCHECK(ui::WindowResizeHelperMac::Get()->task_runner()); if (g_recyclable_browser_compositor.Get()) return std::move(g_recyclable_browser_compositor.Get()); - return scoped_ptr<BrowserCompositorMac>(new BrowserCompositorMac); + return std::unique_ptr<BrowserCompositorMac>(new BrowserCompositorMac); } // static void BrowserCompositorMac::Recycle( - scoped_ptr<BrowserCompositorMac> compositor) { + std::unique_ptr<BrowserCompositorMac> compositor) { DCHECK(compositor); content::ImageTransportFactory::GetInstance() ->SetCompositorSuspendedForRecycle(compositor->compositor(), true);
diff --git a/content/browser/renderer_host/clipboard_message_filter.cc b/content/browser/renderer_host/clipboard_message_filter.cc index e50fedb..7e46a30 100644 --- a/content/browser/renderer_host/clipboard_message_filter.cc +++ b/content/browser/renderer_host/clipboard_message_filter.cc
@@ -4,11 +4,12 @@ #include "content/browser/renderer_host/clipboard_message_filter.h" +#include <memory> + #include "base/bind.h" #include "base/bind_helpers.h" #include "base/location.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/pickle.h" #include "base/strings/utf_string_conversions.h" #include "build/build_config.h" @@ -249,7 +250,7 @@ return; } - scoped_ptr<base::SharedMemory> bitmap_buffer( + std::unique_ptr<base::SharedMemory> bitmap_buffer( new base::SharedMemory(handle, true)); SkBitmap bitmap;
diff --git a/content/browser/renderer_host/clipboard_message_filter.h b/content/browser/renderer_host/clipboard_message_filter.h index 9e9aabe6..c855f3d0 100644 --- a/content/browser/renderer_host/clipboard_message_filter.h +++ b/content/browser/renderer_host/clipboard_message_filter.h
@@ -91,7 +91,7 @@ // thread. static ui::Clipboard* GetClipboard(); - scoped_ptr<ui::ScopedClipboardWriter> clipboard_writer_; + std::unique_ptr<ui::ScopedClipboardWriter> clipboard_writer_; DISALLOW_COPY_AND_ASSIGN(ClipboardMessageFilter); };
diff --git a/content/browser/renderer_host/clipboard_message_filter_unittest.cc b/content/browser/renderer_host/clipboard_message_filter_unittest.cc index 2f0c8ab..e7e1dc6 100644 --- a/content/browser/renderer_host/clipboard_message_filter_unittest.cc +++ b/content/browser/renderer_host/clipboard_message_filter_unittest.cc
@@ -31,15 +31,16 @@ ui::Clipboard::DestroyClipboardForCurrentThread(); } - scoped_ptr<base::SharedMemory> CreateAndMapReadOnlySharedMemory(size_t size) { - scoped_ptr<base::SharedMemory> m = CreateReadOnlySharedMemory(size); + std::unique_ptr<base::SharedMemory> CreateAndMapReadOnlySharedMemory( + size_t size) { + std::unique_ptr<base::SharedMemory> m = CreateReadOnlySharedMemory(size); if (!m->Map(size)) return nullptr; return m; } - scoped_ptr<base::SharedMemory> CreateReadOnlySharedMemory(size_t size) { - scoped_ptr<base::SharedMemory> m(new base::SharedMemory()); + std::unique_ptr<base::SharedMemory> CreateReadOnlySharedMemory(size_t size) { + std::unique_ptr<base::SharedMemory> m(new base::SharedMemory()); base::SharedMemoryCreateOptions options; options.size = size; options.share_read_only = true; @@ -84,7 +85,7 @@ 0xffffffff, 0x11111111, 0x22222222, 0xcccccccc, }; - scoped_ptr<base::SharedMemory> shared_memory = + std::unique_ptr<base::SharedMemory> shared_memory = CreateAndMapReadOnlySharedMemory(sizeof(bitmap_data)); memcpy(shared_memory->memory(), bitmap_data, sizeof(bitmap_data)); @@ -109,7 +110,7 @@ // Test with a size that would overflow a naive 32-bit row bytes calculation. TEST_F(ClipboardMessageFilterTest, ImageSizeOverflows32BitRowBytes) { - scoped_ptr<base::SharedMemory> shared_memory = + std::unique_ptr<base::SharedMemory> shared_memory = CreateReadOnlySharedMemory(0x20000000); CallWriteImage(gfx::Size(0x20000000, 1), shared_memory.get());
diff --git a/content/browser/renderer_host/compositor_impl_android.cc b/content/browser/renderer_host/compositor_impl_android.cc index 56b9201..4569a64 100644 --- a/content/browser/renderer_host/compositor_impl_android.cc +++ b/content/browser/renderer_host/compositor_impl_android.cc
@@ -7,6 +7,7 @@ #include <android/bitmap.h> #include <android/native_window_jni.h> #include <stdint.h> + #include <utility> #include "base/android/jni_android.h" @@ -18,6 +19,7 @@ #include "base/containers/hash_tables.h" #include "base/lazy_instance.h" #include "base/logging.h" +#include "base/memory/ptr_util.h" #include "base/memory/weak_ptr.h" #include "base/single_thread_task_runner.h" #include "base/synchronization/lock.h" @@ -153,7 +155,7 @@ base::CancelableCallback<void(const std::vector<ui::LatencyInfo>&, gfx::SwapResult)> swap_buffers_completion_callback_; - scoped_ptr<cc::OverlayCandidateValidator> overlay_candidate_validator_; + std::unique_ptr<cc::OverlayCandidateValidator> overlay_candidate_validator_; }; class ExternalBeginFrameSource : public cc::BeginFrameSourceBase, @@ -231,8 +233,9 @@ } // static -scoped_ptr<cc::SurfaceIdAllocator> CompositorImpl::CreateSurfaceIdAllocator() { - scoped_ptr<cc::SurfaceIdAllocator> allocator( +std::unique_ptr<cc::SurfaceIdAllocator> +CompositorImpl::CreateSurfaceIdAllocator() { + std::unique_ptr<cc::SurfaceIdAllocator> allocator( new cc::SurfaceIdAllocator(++g_surface_id_namespace)); cc::SurfaceManager* manager = GetSurfaceManager(); DCHECK(manager); @@ -409,7 +412,7 @@ host_->SetNeedsAnimate(); } -static scoped_ptr<WebGraphicsContext3DCommandBufferImpl> +static std::unique_ptr<WebGraphicsContext3DCommandBufferImpl> CreateGpuProcessViewContext( const scoped_refptr<gpu::GpuChannelHost>& gpu_channel_host, const gpu::gles2::ContextCreationAttribHelper& attributes, @@ -432,7 +435,7 @@ gpu::SurfaceHandle surface_handle = tracker->GetSurfaceHandle(surface_id); bool share_resources = true; bool automatic_flushes = false; - return make_scoped_ptr(new WebGraphicsContext3DCommandBufferImpl( + return base::WrapUnique(new WebGraphicsContext3DCommandBufferImpl( surface_handle, url, gpu_channel_host.get(), attributes, gfx::PreferIntegratedGpu, share_resources, automatic_flushes, limits, nullptr)); @@ -547,7 +550,7 @@ DISPLAY_COMPOSITOR_ONSCREEN_CONTEXT)); DCHECK(context_provider.get()); - scoped_ptr<cc::OutputSurface> real_output_surface( + std::unique_ptr<cc::OutputSurface> real_output_surface( new OutputSurfaceWithoutParent( this, context_provider, base::Bind(&CompositorImpl::PopulateGpuCapabilities, @@ -560,9 +563,9 @@ BrowserGpuMemoryBufferManager::current(), host_->settings().renderer_settings, base::ThreadTaskRunnerHandle::Get())); - scoped_ptr<cc::SurfaceDisplayOutputSurface> surface_output_surface( - new cc::SurfaceDisplayOutputSurface( - manager, surface_id_allocator_.get(), context_provider, nullptr)); + std::unique_ptr<cc::SurfaceDisplayOutputSurface> surface_output_surface( + new cc::SurfaceDisplayOutputSurface(manager, surface_id_allocator_.get(), + context_provider, nullptr)); display_client_->set_surface_output_surface(surface_output_surface.get()); surface_output_surface->set_display_client(display_client_.get()); @@ -623,7 +626,7 @@ } void CompositorImpl::RequestCopyOfOutputOnRootLayer( - scoped_ptr<cc::CopyOutputRequest> request) { + std::unique_ptr<cc::CopyOutputRequest> request) { root_layer_->RequestCopyOfOutput(std::move(request)); }
diff --git a/content/browser/renderer_host/compositor_impl_android.h b/content/browser/renderer_host/compositor_impl_android.h index e56c59f..1e284b7 100644 --- a/content/browser/renderer_host/compositor_impl_android.h +++ b/content/browser/renderer_host/compositor_impl_android.h
@@ -7,10 +7,11 @@ #include <stddef.h> +#include <memory> + #include "base/cancelable_callback.h" #include "base/compiler_specific.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/timer/timer.h" #include "cc/trees/layer_tree_host_client.h" @@ -60,7 +61,7 @@ static bool IsInitialized(); static cc::SurfaceManager* GetSurfaceManager(); - static scoped_ptr<cc::SurfaceIdAllocator> CreateSurfaceIdAllocator(); + static std::unique_ptr<cc::SurfaceIdAllocator> CreateSurfaceIdAllocator(); void PopulateGpuCapabilities(gpu::Capabilities gpu_capabilities); @@ -104,9 +105,10 @@ void DidCompleteSwapBuffers() override; void DidCompletePageScaleAnimation() override {} void RecordFrameTimingEvents( - scoped_ptr<cc::FrameTimingTracker::CompositeTimingSet> composite_events, - scoped_ptr<cc::FrameTimingTracker::MainFrameTimingSet> main_frame_events) - override {} + std::unique_ptr<cc::FrameTimingTracker::CompositeTimingSet> + composite_events, + std::unique_ptr<cc::FrameTimingTracker::MainFrameTimingSet> + main_frame_events) override {} // LayerTreeHostSingleThreadClient implementation. void DidPostSwapBuffers() override; @@ -114,7 +116,7 @@ // WindowAndroidCompositor implementation. void RequestCopyOfOutputOnRootLayer( - scoped_ptr<cc::CopyOutputRequest> request) override; + std::unique_ptr<cc::CopyOutputRequest> request) override; void OnVSync(base::TimeTicks frame_time, base::TimeDelta vsync_period) override; void SetNeedsAnimate() override; @@ -132,11 +134,11 @@ // Destruction order matters here: base::ObserverList<VSyncObserver, true> observer_list_; - scoped_ptr<cc::LayerTreeHost> host_; + std::unique_ptr<cc::LayerTreeHost> host_; ui::ResourceManagerImpl resource_manager_; - scoped_ptr<cc::OnscreenDisplayClient> display_client_; - scoped_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; + std::unique_ptr<cc::OnscreenDisplayClient> display_client_; + std::unique_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; gfx::Size size_; bool has_transparent_background_;
diff --git a/content/browser/renderer_host/delegated_frame_host.cc b/content/browser/renderer_host/delegated_frame_host.cc index e103e320..266d821 100644 --- a/content/browser/renderer_host/delegated_frame_host.cc +++ b/content/browser/renderer_host/delegated_frame_host.cc
@@ -11,6 +11,7 @@ #include "base/callback_helpers.h" #include "base/command_line.h" +#include "base/memory/ptr_util.h" #include "base/time/default_tick_clock.h" #include "cc/output/compositor_frame.h" #include "cc/output/compositor_frame_ack.h" @@ -151,7 +152,7 @@ return; } - scoped_ptr<cc::CopyOutputRequest> request = + std::unique_ptr<cc::CopyOutputRequest> request = cc::CopyOutputRequest::CreateRequest( base::Bind(&CopyFromCompositingSurfaceHasResult, output_size, preferred_color_type, callback)); @@ -169,7 +170,7 @@ return; } - scoped_ptr<cc::CopyOutputRequest> request = + std::unique_ptr<cc::CopyOutputRequest> request = cc::CopyOutputRequest::CreateRequest(base::Bind( &DelegatedFrameHost::CopyFromCompositingSurfaceHasResultForVideo, AsWeakPtr(), // For caching the ReadbackYUVInterface on this class. @@ -189,7 +190,7 @@ } void DelegatedFrameHost::BeginFrameSubscription( - scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) { + std::unique_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) { frame_subscriber_ = std::move(subscriber); } @@ -341,7 +342,7 @@ subscriber_texture = new OwnedMailbox(helper); } - scoped_ptr<cc::CopyOutputRequest> request = + std::unique_ptr<cc::CopyOutputRequest> request = cc::CopyOutputRequest::CreateRequest(base::Bind( &DelegatedFrameHost::CopyFromCompositingSurfaceHasResultForVideo, AsWeakPtr(), subscriber_texture, frame, @@ -375,7 +376,7 @@ void DelegatedFrameHost::SwapDelegatedFrame( uint32_t output_surface_id, - scoped_ptr<cc::CompositorFrame> frame) { + std::unique_ptr<cc::CompositorFrame> frame) { DCHECK(frame->delegated_frame_data.get()); cc::DelegatedFrameData* frame_data = frame->delegated_frame_data.get(); float frame_device_scale_factor = frame->metadata.device_scale_factor; @@ -445,7 +446,8 @@ ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); cc::SurfaceManager* manager = factory->GetSurfaceManager(); if (!surface_factory_) { - surface_factory_ = make_scoped_ptr(new cc::SurfaceFactory(manager, this)); + surface_factory_ = + base::WrapUnique(new cc::SurfaceFactory(manager, this)); } if (surface_id_.is_null() || frame_size != current_surface_size_ || frame_size_in_dip != current_frame_size_in_dip_) { @@ -585,7 +587,7 @@ base::WeakPtr<DelegatedFrameHost> dfh, const base::Callback<void(bool)>& callback, scoped_refptr<OwnedMailbox> subscriber_texture, - scoped_ptr<cc::SingleReleaseCallback> release_callback, + std::unique_ptr<cc::SingleReleaseCallback> release_callback, bool result) { callback.Run(result); @@ -610,7 +612,7 @@ scoped_refptr<OwnedMailbox> subscriber_texture, scoped_refptr<media::VideoFrame> video_frame, const base::Callback<void(const gfx::Rect&, bool)>& callback, - scoped_ptr<cc::CopyOutputResult> result) { + std::unique_ptr<cc::CopyOutputResult> result) { base::ScopedClosureRunner scoped_callback_runner( base::Bind(callback, gfx::Rect(), false)); base::ScopedClosureRunner scoped_return_subscriber_texture(base::Bind( @@ -639,7 +641,7 @@ if (!result->HasTexture()) { DCHECK(result->HasBitmap()); - scoped_ptr<SkBitmap> bitmap = result->TakeBitmap(); + std::unique_ptr<SkBitmap> bitmap = result->TakeBitmap(); // Scale the bitmap to the required size, if necessary. SkBitmap scaled_bitmap; if (result->size() != region_in_frame.size()) { @@ -672,7 +674,7 @@ return; cc::TextureMailbox texture_mailbox; - scoped_ptr<cc::SingleReleaseCallback> release_callback; + std::unique_ptr<cc::SingleReleaseCallback> release_callback; result->TakeTexture(&texture_mailbox, &release_callback); DCHECK(texture_mailbox.IsTexture()); @@ -845,7 +847,7 @@ } void DelegatedFrameHost::RequestCopyOfOutput( - scoped_ptr<cc::CopyOutputRequest> request) { + std::unique_ptr<cc::CopyOutputRequest> request) { if (!request_copy_of_output_callback_for_testing_.is_null()) { request_copy_of_output_callback_for_testing_.Run(std::move(request)); } else {
diff --git a/content/browser/renderer_host/delegated_frame_host.h b/content/browser/renderer_host/delegated_frame_host.h index 9f2b181..2fe54a52 100644 --- a/content/browser/renderer_host/delegated_frame_host.h +++ b/content/browser/renderer_host/delegated_frame_host.h
@@ -58,7 +58,7 @@ virtual gfx::Size DelegatedFrameHostDesiredSizeInDIP() const = 0; virtual bool DelegatedFrameCanCreateResizeLock() const = 0; - virtual scoped_ptr<ResizeLock> DelegatedFrameHostCreateResizeLock( + virtual std::unique_ptr<ResizeLock> DelegatedFrameHostCreateResizeLock( bool defer_compositor_lock) = 0; virtual void DelegatedFrameHostResizeLockWasReleased() = 0; @@ -123,7 +123,7 @@ // Public interface exposed to RenderWidgetHostView. void SwapDelegatedFrame(uint32_t output_surface_id, - scoped_ptr<cc::CompositorFrame> frame); + std::unique_ptr<cc::CompositorFrame> frame); void ClearDelegatedFrame(); void WasHidden(); void WasShown(const ui::LatencyInfo& latency_info); @@ -146,7 +146,7 @@ const base::Callback<void(const gfx::Rect&, bool)>& callback); bool CanCopyToVideoFrame() const; void BeginFrameSubscription( - scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber); + std::unique_ptr<RenderWidgetHostViewFrameSubscriber> subscriber); void EndFrameSubscription(); bool HasFrameSubscriber() const { return !!frame_subscriber_; } uint32_t GetSurfaceIdNamespace(); @@ -173,7 +173,8 @@ return !!released_front_lock_.get(); } void SetRequestCopyOfOutputCallbackForTesting( - const base::Callback<void(scoped_ptr<cc::CopyOutputRequest>)>& callback) { + const base::Callback<void(std::unique_ptr<cc::CopyOutputRequest>)>& + callback) { request_copy_of_output_callback_for_testing_ = callback; } @@ -191,7 +192,7 @@ bool ShouldCreateResizeLock(); void LockResources(); void UnlockResources(); - void RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request); + void RequestCopyOfOutput(std::unique_ptr<cc::CopyOutputRequest> request); bool ShouldSkipFrame(gfx::Size size_in_dip) const; @@ -213,12 +214,12 @@ scoped_refptr<OwnedMailbox> subscriber_texture, scoped_refptr<media::VideoFrame> video_frame, const base::Callback<void(const gfx::Rect&, bool)>& callback, - scoped_ptr<cc::CopyOutputResult> result); + std::unique_ptr<cc::CopyOutputResult> result); static void CopyFromCompositingSurfaceFinishedForVideo( base::WeakPtr<DelegatedFrameHost> rwhva, const base::Callback<void(bool)>& callback, scoped_refptr<OwnedMailbox> subscriber_texture, - scoped_ptr<cc::SingleReleaseCallback> release_callback, + std::unique_ptr<cc::SingleReleaseCallback> release_callback, bool result); static void ReturnSubscriberTexture( base::WeakPtr<DelegatedFrameHost> rwhva, @@ -245,7 +246,7 @@ base::TimeDelta vsync_interval_; // Overridable tick clock used for testing functions using current time. - scoped_ptr<base::TickClock> tick_clock_; + std::unique_ptr<base::TickClock> tick_clock_; // With delegated renderer, this is the last output surface, used to // disambiguate resources with the same id coming from different output @@ -261,15 +262,15 @@ bool skipped_frames_; std::vector<ui::LatencyInfo> skipped_latency_info_list_; - scoped_ptr<ui::Layer> right_gutter_; - scoped_ptr<ui::Layer> bottom_gutter_; + std::unique_ptr<ui::Layer> right_gutter_; + std::unique_ptr<ui::Layer> bottom_gutter_; // This is the last root background color from a swapped frame. SkColor background_color_; // State for rendering into a Surface. - scoped_ptr<cc::SurfaceIdAllocator> id_allocator_; - scoped_ptr<cc::SurfaceFactory> surface_factory_; + std::unique_ptr<cc::SurfaceIdAllocator> id_allocator_; + std::unique_ptr<cc::SurfaceFactory> surface_factory_; cc::SurfaceId surface_id_; gfx::Size current_surface_size_; float current_scale_factor_; @@ -281,7 +282,7 @@ // size. It keeps track of the size we expect from the renderer, and locks the // compositor, as well as the UI for a short time to give a chance to the // renderer of producing a frame of the right size. - scoped_ptr<ResizeLock> resize_lock_; + std::unique_ptr<ResizeLock> resize_lock_; // Keeps track of the current frame size. gfx::Size current_frame_size_in_dip_; @@ -303,18 +304,18 @@ base::TimeTicks last_draw_ended_; // Subscriber that listens to frame presentation events. - scoped_ptr<RenderWidgetHostViewFrameSubscriber> frame_subscriber_; + std::unique_ptr<RenderWidgetHostViewFrameSubscriber> frame_subscriber_; std::vector<scoped_refptr<OwnedMailbox>> idle_frame_subscriber_textures_; // Callback used to pass the output request to the layer or to a function // specified by a test. - base::Callback<void(scoped_ptr<cc::CopyOutputRequest>)> + base::Callback<void(std::unique_ptr<cc::CopyOutputRequest>)> request_copy_of_output_callback_for_testing_; // YUV readback pipeline. - scoped_ptr<content::ReadbackYUVInterface> yuv_readback_pipeline_; + std::unique_ptr<content::ReadbackYUVInterface> yuv_readback_pipeline_; - scoped_ptr<DelegatedFrameEvictor> delegated_frame_evictor_; + std::unique_ptr<DelegatedFrameEvictor> delegated_frame_evictor_; cc::BeginFrameSource* begin_frame_source_; };
diff --git a/content/browser/renderer_host/dwrite_font_proxy_message_filter_win_unittest.cc b/content/browser/renderer_host/dwrite_font_proxy_message_filter_win_unittest.cc index 65359e9..b9772c1 100644 --- a/content/browser/renderer_host/dwrite_font_proxy_message_filter_win_unittest.cc +++ b/content/browser/renderer_host/dwrite_font_proxy_message_filter_win_unittest.cc
@@ -37,7 +37,7 @@ private: ~FilterWithFakeSender() override = default; - scoped_ptr<IPC::Message> reply_message_; + std::unique_ptr<IPC::Message> reply_message_; }; class DWriteFontProxyMessageFilterUnitTest : public testing::Test { @@ -48,7 +48,7 @@ void Send(IPC::SyncMessage* message) { std::unique_ptr<IPC::SyncMessage> deleter(message); - scoped_ptr<IPC::MessageReplyDeserializer> serializer( + std::unique_ptr<IPC::MessageReplyDeserializer> serializer( message->GetReplyDeserializer()); filter_->OnMessageReceived(*message); base::RunLoop().RunUntilIdle();
diff --git a/content/browser/renderer_host/ime_adapter_android.cc b/content/browser/renderer_host/ime_adapter_android.cc index 233c042..f41ebefe 100644 --- a/content/browser/renderer_host/ime_adapter_android.cc +++ b/content/browser/renderer_host/ime_adapter_android.cc
@@ -276,7 +276,7 @@ return; const size_t coordinates_array_size = character_bounds.size() * 4; - scoped_ptr<float[]> coordinates_array(new float[coordinates_array_size]); + std::unique_ptr<float[]> coordinates_array(new float[coordinates_array_size]); for (size_t i = 0; i < character_bounds.size(); ++i) { const gfx::RectF& rect = character_bounds[i]; const size_t coordinates_array_index = i * 4;
diff --git a/content/browser/renderer_host/input/composited_scrolling_browsertest.cc b/content/browser/renderer_host/input/composited_scrolling_browsertest.cc index fdca6bc..bc17284 100644 --- a/content/browser/renderer_host/input/composited_scrolling_browsertest.cc +++ b/content/browser/renderer_host/input/composited_scrolling_browsertest.cc
@@ -129,7 +129,7 @@ runner_ = new MessageLoopRunner(); - scoped_ptr<SyntheticSmoothScrollGesture> gesture( + std::unique_ptr<SyntheticSmoothScrollGesture> gesture( new SyntheticSmoothScrollGesture(params)); GetWidgetHost()->QueueSyntheticGesture( std::move(gesture),
diff --git a/content/browser/renderer_host/input/gesture_event_queue.h b/content/browser/renderer_host/input/gesture_event_queue.h index 457a9ec..41faa36 100644 --- a/content/browser/renderer_host/input/gesture_event_queue.h +++ b/content/browser/renderer_host/input/gesture_event_queue.h
@@ -8,9 +8,9 @@ #include <stddef.h> #include <deque> +#include <memory> #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/timer/timer.h" #include "content/browser/renderer_host/event_with_latency_info.h" #include "content/browser/renderer_host/input/tap_suppression_controller.h"
diff --git a/content/browser/renderer_host/input/gesture_event_queue_unittest.cc b/content/browser/renderer_host/input/gesture_event_queue_unittest.cc index 4408727..80b0c9b 100644 --- a/content/browser/renderer_host/input/gesture_event_queue_unittest.cc +++ b/content/browser/renderer_host/input/gesture_event_queue_unittest.cc
@@ -5,12 +5,13 @@ #include "content/browser/renderer_host/input/gesture_event_queue.h" #include <stddef.h> + +#include <memory> #include <utility> #include <vector> #include "base/location.h" #include "base/logging.h" -#include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" #include "base/single_thread_task_runner.h" #include "base/thread_task_runner_handle.h" @@ -54,7 +55,8 @@ const GestureEventWithLatencyInfo& event) override { ++sent_gesture_event_count_; if (sync_ack_result_) { - scoped_ptr<InputEventAckState> ack_result = std::move(sync_ack_result_); + std::unique_ptr<InputEventAckState> ack_result = + std::move(sync_ack_result_); SendInputEventACK(event.event.type, *ack_result); } } @@ -189,12 +191,12 @@ } private: - scoped_ptr<GestureEventQueue> queue_; + std::unique_ptr<GestureEventQueue> queue_; size_t acked_gesture_event_count_; size_t sent_gesture_event_count_; WebGestureEvent last_acked_event_; - scoped_ptr<InputEventAckState> sync_ack_result_; - scoped_ptr<WebGestureEvent> sync_followup_event_; + std::unique_ptr<InputEventAckState> sync_ack_result_; + std::unique_ptr<WebGestureEvent> sync_followup_event_; base::MessageLoopForUI message_loop_; }; @@ -872,7 +874,7 @@ // Tests an event with an synchronous ack which enqueues an additional event. TEST_F(GestureEventQueueTest, SyncAckQueuesEvent) { - scoped_ptr<WebGestureEvent> queued_event; + std::unique_ptr<WebGestureEvent> queued_event; set_synchronous_ack(INPUT_EVENT_ACK_STATE_CONSUMED); set_sync_followup_event(WebInputEvent::GestureShowPress, blink::WebGestureDeviceTouchscreen);
diff --git a/content/browser/renderer_host/input/input_router.h b/content/browser/renderer_host/input/input_router.h index 3b466cbb..ee940d5f7 100644 --- a/content/browser/renderer_host/input/input_router.h +++ b/content/browser/renderer_host/input/input_router.h
@@ -26,7 +26,7 @@ // Send and take ownership of the the given InputMsg_*. This should be used // only for event types not associated with a WebInputEvent. Returns true on // success and false otherwise. - virtual bool SendInput(scoped_ptr<IPC::Message> message) = 0; + virtual bool SendInput(std::unique_ptr<IPC::Message> message) = 0; // WebInputEvents virtual void SendMouseEvent(
diff --git a/content/browser/renderer_host/input/input_router_impl.cc b/content/browser/renderer_host/input/input_router_impl.cc index ed58284..598e2174 100644 --- a/content/browser/renderer_host/input/input_router_impl.cc +++ b/content/browser/renderer_host/input/input_router_impl.cc
@@ -5,10 +5,12 @@ #include "content/browser/renderer_host/input/input_router_impl.h" #include <math.h> + #include <utility> #include "base/auto_reset.h" #include "base/command_line.h" +#include "base/memory/ptr_util.h" #include "base/metrics/histogram.h" #include "base/strings/string_number_conversions.h" #include "content/browser/renderer_host/input/gesture_event_queue.h" @@ -97,7 +99,7 @@ STLDeleteElements(&pending_select_messages_); } -bool InputRouterImpl::SendInput(scoped_ptr<IPC::Message> message) { +bool InputRouterImpl::SendInput(std::unique_ptr<IPC::Message> message) { DCHECK(IPC_MESSAGE_ID_CLASS(message->type()) == InputMsgStart); switch (message->type()) { // Check for types that require an ACK. @@ -304,8 +306,7 @@ ack_handler_->OnWheelEventAck(event, ack_result); } -bool InputRouterImpl::SendSelectMessage( - scoped_ptr<IPC::Message> message) { +bool InputRouterImpl::SendSelectMessage(std::unique_ptr<IPC::Message> message) { DCHECK(message->type() == InputMsg_SelectRange::ID || message->type() == InputMsg_MoveRangeSelectionExtent::ID); @@ -326,7 +327,7 @@ return Send(message.release()); } -bool InputRouterImpl::SendMoveCaret(scoped_ptr<IPC::Message> message) { +bool InputRouterImpl::SendMoveCaret(std::unique_ptr<IPC::Message> message) { DCHECK(message->type() == InputMsg_MoveCaret::ID); if (move_caret_pending_) { next_move_caret_ = std::move(message); @@ -426,7 +427,7 @@ // This conversion is temporary. WebInputEvent should be generated // directly from ui::Event with the viewport coordinates. See // crbug.com/563730. - scoped_ptr<blink::WebInputEvent> event_in_viewport = + std::unique_ptr<blink::WebInputEvent> event_in_viewport = ui::ScaleWebInputEvent(input_event, device_scale_factor_); const WebInputEvent* event_to_send = event_in_viewport ? event_in_viewport.get() : &input_event; @@ -474,8 +475,8 @@ void InputRouterImpl::OnSelectMessageAck() { select_message_pending_ = false; if (!pending_select_messages_.empty()) { - scoped_ptr<IPC::Message> next_message = - make_scoped_ptr(pending_select_messages_.front()); + std::unique_ptr<IPC::Message> next_message = + base::WrapUnique(pending_select_messages_.front()); pending_select_messages_.pop_front(); SendSelectMessage(std::move(next_message)); @@ -593,7 +594,7 @@ if (next_mouse_move_) { DCHECK(next_mouse_move_->event.type == WebInputEvent::MouseMove); - scoped_ptr<MouseEventWithLatencyInfo> next_mouse_move = + std::unique_ptr<MouseEventWithLatencyInfo> next_mouse_move = std::move(next_mouse_move_); SendMouseEvent(*next_mouse_move); }
diff --git a/content/browser/renderer_host/input/input_router_impl.h b/content/browser/renderer_host/input/input_router_impl.h index a0f9fc2..44dd0b42 100644 --- a/content/browser/renderer_host/input/input_router_impl.h +++ b/content/browser/renderer_host/input/input_router_impl.h
@@ -7,10 +7,10 @@ #include <stdint.h> +#include <memory> #include <queue> #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/time/time.h" #include "content/browser/renderer_host/input/gesture_event_queue.h" #include "content/browser/renderer_host/input/input_router.h" @@ -60,7 +60,7 @@ ~InputRouterImpl() override; // InputRouter - bool SendInput(scoped_ptr<IPC::Message> message) override; + bool SendInput(std::unique_ptr<IPC::Message> message) override; void SendMouseEvent(const MouseEventWithLatencyInfo& mouse_event) override; void SendWheelEvent( const MouseWheelEventWithLatencyInfo& wheel_event) override; @@ -109,8 +109,8 @@ void OnMouseWheelEventAck(const MouseWheelEventWithLatencyInfo& event, InputEventAckState ack_result) override; - bool SendMoveCaret(scoped_ptr<IPC::Message> message); - bool SendSelectMessage(scoped_ptr<IPC::Message> message); + bool SendMoveCaret(std::unique_ptr<IPC::Message> message); + bool SendSelectMessage(std::unique_ptr<IPC::Message> message); bool Send(IPC::Message* message); // Filters and forwards |input_event| to the appropriate handler. @@ -216,7 +216,7 @@ bool move_caret_pending_; // (Similar to |next_mouse_move_|.) The next MoveCaret to send, if any. - scoped_ptr<IPC::Message> next_move_caret_; + std::unique_ptr<IPC::Message> next_move_caret_; // True if a mouse move event was sent to the render view and we are waiting // for a corresponding InputHostMsg_HandleInputEvent_ACK message. @@ -224,7 +224,7 @@ // The next mouse move event to send (only non-null while mouse_move_pending_ // is true). - scoped_ptr<MouseEventWithLatencyInfo> next_mouse_move_; + std::unique_ptr<MouseEventWithLatencyInfo> next_mouse_move_; MouseEventWithLatencyInfo current_mouse_move_; // A queue of keyboard events. We can't trust data from the renderer so we
diff --git a/content/browser/renderer_host/input/input_router_impl_perftest.cc b/content/browser/renderer_host/input/input_router_impl_perftest.cc index 5860ca85..2a3eb64a 100644 --- a/content/browser/renderer_host/input/input_router_impl_perftest.cc +++ b/content/browser/renderer_host/input/input_router_impl_perftest.cc
@@ -5,8 +5,9 @@ #include <stddef.h> #include <stdint.h> +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/renderer_host/input/input_ack_handler.h" #include "content/browser/renderer_host/input/input_router_client.h" #include "content/browser/renderer_host/input/input_router_impl.h" @@ -334,10 +335,10 @@ private: int64_t last_input_id_; - scoped_ptr<NullIPCSender> sender_; - scoped_ptr<NullInputRouterClient> client_; - scoped_ptr<NullInputAckHandler> ack_handler_; - scoped_ptr<InputRouterImpl> input_router_; + std::unique_ptr<NullIPCSender> sender_; + std::unique_ptr<NullInputRouterClient> client_; + std::unique_ptr<NullInputAckHandler> ack_handler_; + std::unique_ptr<InputRouterImpl> input_router_; base::MessageLoopForUI message_loop_; };
diff --git a/content/browser/renderer_host/input/input_router_impl_unittest.cc b/content/browser/renderer_host/input/input_router_impl_unittest.cc index 861ecae..e5d16cb 100644 --- a/content/browser/renderer_host/input/input_router_impl_unittest.cc +++ b/content/browser/renderer_host/input/input_router_impl_unittest.cc
@@ -2,21 +2,23 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/browser/renderer_host/input/input_router_impl.h" + #include <math.h> #include <stddef.h> #include <stdint.h> +#include <memory> + #include "base/command_line.h" #include "base/location.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/single_thread_task_runner.h" #include "base/strings/utf_string_conversions.h" #include "base/thread_task_runner_handle.h" #include "build/build_config.h" #include "content/browser/renderer_host/input/gesture_event_queue.h" #include "content/browser/renderer_host/input/input_router_client.h" -#include "content/browser/renderer_host/input/input_router_impl.h" #include "content/browser/renderer_host/input/mock_input_ack_handler.h" #include "content/browser/renderer_host/input/mock_input_router_client.h" #include "content/common/content_constants_internal.h" @@ -352,20 +354,20 @@ } InputRouterImpl::Config config_; - scoped_ptr<MockRenderProcessHost> process_; - scoped_ptr<MockInputRouterClient> client_; - scoped_ptr<MockInputAckHandler> ack_handler_; - scoped_ptr<InputRouterImpl> input_router_; + std::unique_ptr<MockRenderProcessHost> process_; + std::unique_ptr<MockInputRouterClient> client_; + std::unique_ptr<MockInputAckHandler> ack_handler_; + std::unique_ptr<InputRouterImpl> input_router_; private: base::MessageLoopForUI message_loop_; SyntheticWebTouchEvent touch_event_; - scoped_ptr<TestBrowserContext> browser_context_; + std::unique_ptr<TestBrowserContext> browser_context_; }; TEST_F(InputRouterImplTest, CoalescesRangeSelection) { - input_router_->SendInput(scoped_ptr<IPC::Message>( + input_router_->SendInput(std::unique_ptr<IPC::Message>( new InputMsg_SelectRange(0, gfx::Point(1, 2), gfx::Point(3, 4)))); ExpectIPCMessageWithArg2<InputMsg_SelectRange>( process_->sink().GetMessageAt(0), @@ -374,17 +376,17 @@ EXPECT_EQ(1u, GetSentMessageCountAndResetSink()); // Send two more messages without acking. - input_router_->SendInput(scoped_ptr<IPC::Message>( + input_router_->SendInput(std::unique_ptr<IPC::Message>( new InputMsg_SelectRange(0, gfx::Point(5, 6), gfx::Point(7, 8)))); EXPECT_EQ(0u, GetSentMessageCountAndResetSink()); - input_router_->SendInput(scoped_ptr<IPC::Message>( + input_router_->SendInput(std::unique_ptr<IPC::Message>( new InputMsg_SelectRange(0, gfx::Point(9, 10), gfx::Point(11, 12)))); EXPECT_EQ(0u, GetSentMessageCountAndResetSink()); // Now ack the first message. { - scoped_ptr<IPC::Message> response(new InputHostMsg_SelectRange_ACK(0)); + std::unique_ptr<IPC::Message> response(new InputHostMsg_SelectRange_ACK(0)); input_router_->OnMessageReceived(*response); } @@ -397,14 +399,14 @@ // Acking the coalesced msg should not send any more msg. { - scoped_ptr<IPC::Message> response(new InputHostMsg_SelectRange_ACK(0)); + std::unique_ptr<IPC::Message> response(new InputHostMsg_SelectRange_ACK(0)); input_router_->OnMessageReceived(*response); } EXPECT_EQ(0u, GetSentMessageCountAndResetSink()); } TEST_F(InputRouterImplTest, CoalescesMoveRangeSelectionExtent) { - input_router_->SendInput(scoped_ptr<IPC::Message>( + input_router_->SendInput(std::unique_ptr<IPC::Message>( new InputMsg_MoveRangeSelectionExtent(0, gfx::Point(1, 2)))); ExpectIPCMessageWithArg1<InputMsg_MoveRangeSelectionExtent>( process_->sink().GetMessageAt(0), @@ -412,17 +414,17 @@ EXPECT_EQ(1u, GetSentMessageCountAndResetSink()); // Send two more messages without acking. - input_router_->SendInput(scoped_ptr<IPC::Message>( + input_router_->SendInput(std::unique_ptr<IPC::Message>( new InputMsg_MoveRangeSelectionExtent(0, gfx::Point(3, 4)))); EXPECT_EQ(0u, GetSentMessageCountAndResetSink()); - input_router_->SendInput(scoped_ptr<IPC::Message>( + input_router_->SendInput(std::unique_ptr<IPC::Message>( new InputMsg_MoveRangeSelectionExtent(0, gfx::Point(5, 6)))); EXPECT_EQ(0u, GetSentMessageCountAndResetSink()); // Now ack the first message. { - scoped_ptr<IPC::Message> response( + std::unique_ptr<IPC::Message> response( new InputHostMsg_MoveRangeSelectionExtent_ACK(0)); input_router_->OnMessageReceived(*response); } @@ -435,7 +437,7 @@ // Acking the coalesced msg should not send any more msg. { - scoped_ptr<IPC::Message> response( + std::unique_ptr<IPC::Message> response( new InputHostMsg_MoveRangeSelectionExtent_ACK(0)); input_router_->OnMessageReceived(*response); } @@ -444,7 +446,7 @@ TEST_F(InputRouterImplTest, InterleaveSelectRangeAndMoveRangeSelectionExtent) { // Send first message: SelectRange. - input_router_->SendInput(scoped_ptr<IPC::Message>( + input_router_->SendInput(std::unique_ptr<IPC::Message>( new InputMsg_SelectRange(0, gfx::Point(1, 2), gfx::Point(3, 4)))); ExpectIPCMessageWithArg2<InputMsg_SelectRange>( process_->sink().GetMessageAt(0), @@ -453,12 +455,12 @@ EXPECT_EQ(1u, GetSentMessageCountAndResetSink()); // Send second message: MoveRangeSelectionExtent. - input_router_->SendInput(scoped_ptr<IPC::Message>( + input_router_->SendInput(std::unique_ptr<IPC::Message>( new InputMsg_MoveRangeSelectionExtent(0, gfx::Point(5, 6)))); EXPECT_EQ(0u, GetSentMessageCountAndResetSink()); // Send third message: SelectRange. - input_router_->SendInput(scoped_ptr<IPC::Message>( + input_router_->SendInput(std::unique_ptr<IPC::Message>( new InputMsg_SelectRange(0, gfx::Point(7, 8), gfx::Point(9, 10)))); EXPECT_EQ(0u, GetSentMessageCountAndResetSink()); @@ -467,8 +469,7 @@ // Ack the first message. { - scoped_ptr<IPC::Message> response( - new InputHostMsg_SelectRange_ACK(0)); + std::unique_ptr<IPC::Message> response(new InputHostMsg_SelectRange_ACK(0)); input_router_->OnMessageReceived(*response); } @@ -479,7 +480,7 @@ // Ack the second message. { - scoped_ptr<IPC::Message> response( + std::unique_ptr<IPC::Message> response( new InputHostMsg_MoveRangeSelectionExtent_ACK(0)); input_router_->OnMessageReceived(*response); } @@ -492,8 +493,7 @@ // Ack the third message. { - scoped_ptr<IPC::Message> response( - new InputHostMsg_SelectRange_ACK(0)); + std::unique_ptr<IPC::Message> response(new InputHostMsg_SelectRange_ACK(0)); input_router_->OnMessageReceived(*response); } EXPECT_EQ(0u, GetSentMessageCountAndResetSink()); @@ -511,7 +511,7 @@ // > SelectRange // > MoveRangeSelectionExtent - input_router_->SendInput(scoped_ptr<IPC::Message>( + input_router_->SendInput(std::unique_ptr<IPC::Message>( new InputMsg_SelectRange(0, gfx::Point(1, 2), gfx::Point(3, 4)))); ExpectIPCMessageWithArg2<InputMsg_SelectRange>( process_->sink().GetMessageAt(0), @@ -519,34 +519,33 @@ gfx::Point(3, 4)); EXPECT_EQ(1u, GetSentMessageCountAndResetSink()); - input_router_->SendInput(scoped_ptr<IPC::Message>( + input_router_->SendInput(std::unique_ptr<IPC::Message>( new InputMsg_MoveRangeSelectionExtent(0, gfx::Point(5, 6)))); EXPECT_EQ(0u, GetSentMessageCountAndResetSink()); - input_router_->SendInput(scoped_ptr<IPC::Message>( + input_router_->SendInput(std::unique_ptr<IPC::Message>( new InputMsg_MoveRangeSelectionExtent(0, gfx::Point(7, 8)))); EXPECT_EQ(0u, GetSentMessageCountAndResetSink()); - input_router_->SendInput(scoped_ptr<IPC::Message>( + input_router_->SendInput(std::unique_ptr<IPC::Message>( new InputMsg_MoveRangeSelectionExtent(0, gfx::Point(9, 10)))); EXPECT_EQ(0u, GetSentMessageCountAndResetSink()); - input_router_->SendInput(scoped_ptr<IPC::Message>( + input_router_->SendInput(std::unique_ptr<IPC::Message>( new InputMsg_SelectRange(0, gfx::Point(11, 12), gfx::Point(13, 14)))); EXPECT_EQ(0u, GetSentMessageCountAndResetSink()); - input_router_->SendInput(scoped_ptr<IPC::Message>( + input_router_->SendInput(std::unique_ptr<IPC::Message>( new InputMsg_SelectRange(0, gfx::Point(15, 16), gfx::Point(17, 18)))); EXPECT_EQ(0u, GetSentMessageCountAndResetSink()); - input_router_->SendInput(scoped_ptr<IPC::Message>( + input_router_->SendInput(std::unique_ptr<IPC::Message>( new InputMsg_MoveRangeSelectionExtent(0, gfx::Point(19, 20)))); EXPECT_EQ(0u, GetSentMessageCountAndResetSink()); // Ack the first message. { - scoped_ptr<IPC::Message> response( - new InputHostMsg_SelectRange_ACK(0)); + std::unique_ptr<IPC::Message> response(new InputHostMsg_SelectRange_ACK(0)); input_router_->OnMessageReceived(*response); } @@ -559,7 +558,7 @@ // Ack the second message. { - scoped_ptr<IPC::Message> response( + std::unique_ptr<IPC::Message> response( new InputHostMsg_MoveRangeSelectionExtent_ACK(0)); input_router_->OnMessageReceived(*response); } @@ -573,8 +572,7 @@ // Ack the third message. { - scoped_ptr<IPC::Message> response( - new InputHostMsg_SelectRange_ACK(0)); + std::unique_ptr<IPC::Message> response(new InputHostMsg_SelectRange_ACK(0)); input_router_->OnMessageReceived(*response); } @@ -586,7 +584,7 @@ // Ack the fourth message. { - scoped_ptr<IPC::Message> response( + std::unique_ptr<IPC::Message> response( new InputHostMsg_MoveRangeSelectionExtent_ACK(0)); input_router_->OnMessageReceived(*response); } @@ -594,24 +592,24 @@ } TEST_F(InputRouterImplTest, CoalescesCaretMove) { - input_router_->SendInput( - scoped_ptr<IPC::Message>(new InputMsg_MoveCaret(0, gfx::Point(1, 2)))); + input_router_->SendInput(std::unique_ptr<IPC::Message>( + new InputMsg_MoveCaret(0, gfx::Point(1, 2)))); ExpectIPCMessageWithArg1<InputMsg_MoveCaret>( process_->sink().GetMessageAt(0), gfx::Point(1, 2)); EXPECT_EQ(1u, GetSentMessageCountAndResetSink()); // Send two more messages without acking. - input_router_->SendInput( - scoped_ptr<IPC::Message>(new InputMsg_MoveCaret(0, gfx::Point(5, 6)))); + input_router_->SendInput(std::unique_ptr<IPC::Message>( + new InputMsg_MoveCaret(0, gfx::Point(5, 6)))); EXPECT_EQ(0u, GetSentMessageCountAndResetSink()); - input_router_->SendInput( - scoped_ptr<IPC::Message>(new InputMsg_MoveCaret(0, gfx::Point(9, 10)))); + input_router_->SendInput(std::unique_ptr<IPC::Message>( + new InputMsg_MoveCaret(0, gfx::Point(9, 10)))); EXPECT_EQ(0u, GetSentMessageCountAndResetSink()); // Now ack the first message. { - scoped_ptr<IPC::Message> response(new InputHostMsg_MoveCaret_ACK(0)); + std::unique_ptr<IPC::Message> response(new InputHostMsg_MoveCaret_ACK(0)); input_router_->OnMessageReceived(*response); } @@ -622,7 +620,7 @@ // Acking the coalesced msg should not send any more msg. { - scoped_ptr<IPC::Message> response(new InputHostMsg_MoveCaret_ACK(0)); + std::unique_ptr<IPC::Message> response(new InputHostMsg_MoveCaret_ACK(0)); input_router_->OnMessageReceived(*response); } EXPECT_EQ(0u, GetSentMessageCountAndResetSink());
diff --git a/content/browser/renderer_host/input/mock_input_ack_handler.h b/content/browser/renderer_host/input/mock_input_ack_handler.h index 4753a151..90310ff9 100644 --- a/content/browser/renderer_host/input/mock_input_ack_handler.h +++ b/content/browser/renderer_host/input/mock_input_ack_handler.h
@@ -6,9 +6,10 @@ #define CONTENT_BROWSER_RENDERER_HOST_INPUT_MOCK_INPUT_ACK_HANDLER_H_ #include <stddef.h> + +#include <memory> #include <utility> -#include "base/memory/scoped_ptr.h" #include "content/browser/renderer_host/input/input_ack_handler.h" namespace content { @@ -39,11 +40,13 @@ input_router_ = input_router; } - void set_followup_touch_event(scoped_ptr<GestureEventWithLatencyInfo> event) { + void set_followup_touch_event( + std::unique_ptr<GestureEventWithLatencyInfo> event) { gesture_followup_event_ = std::move(event); } - void set_followup_touch_event(scoped_ptr<TouchEventWithLatencyInfo> event) { + void set_followup_touch_event( + std::unique_ptr<TouchEventWithLatencyInfo> event) { touch_followup_event_ = std::move(event); } @@ -83,8 +86,8 @@ blink::WebGestureEvent acked_gesture_event_; blink::WebMouseEvent acked_mouse_event_; - scoped_ptr<GestureEventWithLatencyInfo> gesture_followup_event_; - scoped_ptr<TouchEventWithLatencyInfo> touch_followup_event_; + std::unique_ptr<GestureEventWithLatencyInfo> gesture_followup_event_; + std::unique_ptr<TouchEventWithLatencyInfo> touch_followup_event_; }; } // namespace content
diff --git a/content/browser/renderer_host/input/mock_input_router_client.h b/content/browser/renderer_host/input/mock_input_router_client.h index fbe50661..7a67e5f 100644 --- a/content/browser/renderer_host/input/mock_input_router_client.h +++ b/content/browser/renderer_host/input/mock_input_router_client.h
@@ -7,7 +7,8 @@ #include <stddef.h> -#include "base/memory/scoped_ptr.h" +#include <memory> + #include "content/browser/renderer_host/input/input_router_client.h" #include "content/common/input/did_overscroll_params.h" #include "content/common/input/input_event.h" @@ -64,7 +65,7 @@ InputEventAckState filter_state_; bool filter_input_event_called_; - scoped_ptr<InputEvent> last_filter_event_; + std::unique_ptr<InputEvent> last_filter_event_; size_t did_flush_called_count_;
diff --git a/content/browser/renderer_host/input/mouse_wheel_event_queue.h b/content/browser/renderer_host/input/mouse_wheel_event_queue.h index c84d5302..316edcaf 100644 --- a/content/browser/renderer_host/input/mouse_wheel_event_queue.h +++ b/content/browser/renderer_host/input/mouse_wheel_event_queue.h
@@ -87,7 +87,7 @@ typedef std::deque<QueuedWebMouseWheelEvent*> WheelEventQueue; WheelEventQueue wheel_queue_; - scoped_ptr<QueuedWebMouseWheelEvent> event_sent_for_gesture_ack_; + std::unique_ptr<QueuedWebMouseWheelEvent> event_sent_for_gesture_ack_; // True if a non-synthetic GSB needs to be sent before a GSU is sent. bool needs_scroll_begin_;
diff --git a/content/browser/renderer_host/input/mouse_wheel_event_queue_unittest.cc b/content/browser/renderer_host/input/mouse_wheel_event_queue_unittest.cc index a877a16f..813c241 100644 --- a/content/browser/renderer_host/input/mouse_wheel_event_queue_unittest.cc +++ b/content/browser/renderer_host/input/mouse_wheel_event_queue_unittest.cc
@@ -5,10 +5,11 @@ #include "content/browser/renderer_host/input/mouse_wheel_event_queue.h" #include <stddef.h> + +#include <memory> #include <utility> #include "base/location.h" -#include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" #include "base/single_thread_task_runner.h" #include "base/thread_task_runner_handle.h" @@ -130,14 +131,14 @@ void SendMouseWheelEventImmediately( const MouseWheelEventWithLatencyInfo& event) override { WebMouseWheelEvent* cloned_event = new WebMouseWheelEvent(); - scoped_ptr<WebInputEvent> cloned_event_holder(cloned_event); + std::unique_ptr<WebInputEvent> cloned_event_holder(cloned_event); *cloned_event = event.event; sent_events_.push_back(std::move(cloned_event_holder)); } void ForwardGestureEvent(const blink::WebGestureEvent& event) override { WebGestureEvent* cloned_event = new WebGestureEvent(); - scoped_ptr<WebInputEvent> cloned_event_holder(cloned_event); + std::unique_ptr<WebInputEvent> cloned_event_holder(cloned_event); *cloned_event = event; sent_events_.push_back(std::move(cloned_event_holder)); } @@ -159,11 +160,11 @@ bool event_in_flight() const { return queue_->event_in_flight(); } - std::vector<scoped_ptr<WebInputEvent>>& all_sent_events() { + std::vector<std::unique_ptr<WebInputEvent>>& all_sent_events() { return sent_events_; } - const scoped_ptr<WebInputEvent>& sent_input_event(size_t index) { + const std::unique_ptr<WebInputEvent>& sent_input_event(size_t index) { return sent_events_[index]; } const WebGestureEvent* sent_gesture_event(size_t index) { @@ -368,8 +369,8 @@ EXPECT_EQ(2U, GetAndResetSentEventCount()); } - scoped_ptr<MouseWheelEventQueue> queue_; - std::vector<scoped_ptr<WebInputEvent>> sent_events_; + std::unique_ptr<MouseWheelEventQueue> queue_; + std::vector<std::unique_ptr<WebInputEvent>> sent_events_; size_t acked_event_count_; InputEventAckState last_acked_event_state_; base::MessageLoopForUI message_loop_;
diff --git a/content/browser/renderer_host/input/non_blocking_event_browsertest.cc b/content/browser/renderer_host/input/non_blocking_event_browsertest.cc index b5fbe71c..7711e2d 100644 --- a/content/browser/renderer_host/input/non_blocking_event_browsertest.cc +++ b/content/browser/renderer_host/input/non_blocking_event_browsertest.cc
@@ -150,7 +150,7 @@ params.anchor = gfx::PointF(50, 50); params.distances.push_back(gfx::Vector2d(0, -45)); - scoped_ptr<SyntheticSmoothScrollGesture> gesture( + std::unique_ptr<SyntheticSmoothScrollGesture> gesture( new SyntheticSmoothScrollGesture(params)); GetWidgetHost()->QueueSyntheticGesture( std::move(gesture),
diff --git a/content/browser/renderer_host/input/render_widget_host_latency_tracker_unittest.cc b/content/browser/renderer_host/input/render_widget_host_latency_tracker_unittest.cc index 3249744..769650d3 100644 --- a/content/browser/renderer_host/input/render_widget_host_latency_tracker_unittest.cc +++ b/content/browser/renderer_host/input/render_widget_host_latency_tracker_unittest.cc
@@ -78,7 +78,7 @@ DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostLatencyTrackerTest); const int kTestRoutingId = 3; const int kTestProcessId = 1; - scoped_ptr<base::HistogramTester> histogram_tester_; + std::unique_ptr<base::HistogramTester> histogram_tester_; RenderWidgetHostLatencyTracker tracker_; };
diff --git a/content/browser/renderer_host/input/stylus_text_selector.cc b/content/browser/renderer_host/input/stylus_text_selector.cc index 20eee82..b383b6c 100644 --- a/content/browser/renderer_host/input/stylus_text_selector.cc +++ b/content/browser/renderer_host/input/stylus_text_selector.cc
@@ -14,7 +14,7 @@ namespace content { namespace { -scoped_ptr<GestureDetector> CreateGestureDetector( +std::unique_ptr<GestureDetector> CreateGestureDetector( ui::GestureListener* listener) { GestureDetector::Config config = ui::GetGestureProviderConfig( @@ -25,7 +25,7 @@ // Doubletap, showpress and longpress detection are not required, and // should be explicitly disabled for efficiency. - scoped_ptr<ui::GestureDetector> detector( + std::unique_ptr<ui::GestureDetector> detector( new ui::GestureDetector(config, listener, null_double_tap_listener)); detector->set_longpress_enabled(false); detector->set_showpress_enabled(false);
diff --git a/content/browser/renderer_host/input/stylus_text_selector.h b/content/browser/renderer_host/input/stylus_text_selector.h index e4b1f591..8510a9ea 100644 --- a/content/browser/renderer_host/input/stylus_text_selector.h +++ b/content/browser/renderer_host/input/stylus_text_selector.h
@@ -5,9 +5,10 @@ #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_STYLUS_TEXT_SELECTOR_H_ #define CONTENT_BROWSER_RENDERER_HOST_INPUT_STYLUS_TEXT_SELECTOR_H_ +#include <memory> + #include "base/gtest_prod_util.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/time/time.h" #include "content/common/content_export.h" #include "ui/events/gesture_detection/gesture_listeners.h" @@ -68,7 +69,7 @@ bool dragged_; float anchor_x_; float anchor_y_; - scoped_ptr<ui::GestureDetector> gesture_detector_; + std::unique_ptr<ui::GestureDetector> gesture_detector_; DISALLOW_COPY_AND_ASSIGN(StylusTextSelector); };
diff --git a/content/browser/renderer_host/input/stylus_text_selector_unittest.cc b/content/browser/renderer_host/input/stylus_text_selector_unittest.cc index 1c8e510..887b4c2 100644 --- a/content/browser/renderer_host/input/stylus_text_selector_unittest.cc +++ b/content/browser/renderer_host/input/stylus_text_selector_unittest.cc
@@ -2,12 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/browser/renderer_host/input/stylus_text_selector.h" + +#include <memory> #include <string> #include <vector> -#include "base/memory/scoped_ptr.h" #include "base/time/time.h" -#include "content/browser/renderer_host/input/stylus_text_selector.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/events/event_constants.h" #include "ui/events/gesture_detection/motion_event.h" @@ -56,7 +57,7 @@ } protected: - scoped_ptr<StylusTextSelector> selector_; + std::unique_ptr<StylusTextSelector> selector_; std::vector<std::string> event_log_; };
diff --git a/content/browser/renderer_host/input/synthetic_gesture.cc b/content/browser/renderer_host/input/synthetic_gesture.cc index a6aa6bd..b334af1 100644 --- a/content/browser/renderer_host/input/synthetic_gesture.cc +++ b/content/browser/renderer_host/input/synthetic_gesture.cc
@@ -16,9 +16,9 @@ namespace { template <typename GestureType, typename GestureParamsType> -static scoped_ptr<SyntheticGesture> CreateGesture( +static std::unique_ptr<SyntheticGesture> CreateGesture( const SyntheticGestureParams& gesture_params) { - return scoped_ptr<SyntheticGesture>( + return std::unique_ptr<SyntheticGesture>( new GestureType(*GestureParamsType::Cast(&gesture_params))); } @@ -28,7 +28,7 @@ SyntheticGesture::~SyntheticGesture() {} -scoped_ptr<SyntheticGesture> SyntheticGesture::Create( +std::unique_ptr<SyntheticGesture> SyntheticGesture::Create( const SyntheticGestureParams& gesture_params) { switch (gesture_params.GetGestureType()) { case SyntheticGestureParams::SMOOTH_SCROLL_GESTURE: @@ -48,7 +48,7 @@ SyntheticPointerActionParams>(gesture_params); } NOTREACHED() << "Invalid synthetic gesture type"; - return scoped_ptr<SyntheticGesture>(); + return std::unique_ptr<SyntheticGesture>(); } } // namespace content
diff --git a/content/browser/renderer_host/input/synthetic_gesture.h b/content/browser/renderer_host/input/synthetic_gesture.h index 4177b06..f880e5d 100644 --- a/content/browser/renderer_host/input/synthetic_gesture.h +++ b/content/browser/renderer_host/input/synthetic_gesture.h
@@ -5,8 +5,9 @@ #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_GESTURE_H_ #define CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_GESTURE_H_ +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/time/time.h" #include "content/common/content_export.h" #include "content/common/input/synthetic_gesture_params.h" @@ -31,7 +32,7 @@ SyntheticGesture(); virtual ~SyntheticGesture(); - static scoped_ptr<SyntheticGesture> Create( + static std::unique_ptr<SyntheticGesture> Create( const SyntheticGestureParams& gesture_params); enum Result {
diff --git a/content/browser/renderer_host/input/synthetic_gesture_controller.cc b/content/browser/renderer_host/input/synthetic_gesture_controller.cc index 109ce346..9e5bc844 100644 --- a/content/browser/renderer_host/input/synthetic_gesture_controller.cc +++ b/content/browser/renderer_host/input/synthetic_gesture_controller.cc
@@ -15,13 +15,13 @@ namespace content { SyntheticGestureController::SyntheticGestureController( - scoped_ptr<SyntheticGestureTarget> gesture_target) + std::unique_ptr<SyntheticGestureTarget> gesture_target) : gesture_target_(std::move(gesture_target)) {} SyntheticGestureController::~SyntheticGestureController() {} void SyntheticGestureController::QueueSyntheticGesture( - scoped_ptr<SyntheticGesture> synthetic_gesture, + std::unique_ptr<SyntheticGesture> synthetic_gesture, const OnGestureCompleteCallback& completion_callback) { DCHECK(synthetic_gesture);
diff --git a/content/browser/renderer_host/input/synthetic_gesture_controller.h b/content/browser/renderer_host/input/synthetic_gesture_controller.h index f7b03c2..5a92f31 100644 --- a/content/browser/renderer_host/input/synthetic_gesture_controller.h +++ b/content/browser/renderer_host/input/synthetic_gesture_controller.h
@@ -5,12 +5,12 @@ #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_GESTURE_CONTROLLER_H_ #define CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_GESTURE_CONTROLLER_H_ +#include <memory> #include <queue> #include <utility> #include "base/callback.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_vector.h" #include "base/time/time.h" #include "content/browser/renderer_host/input/synthetic_gesture.h" @@ -27,13 +27,13 @@ class CONTENT_EXPORT SyntheticGestureController { public: explicit SyntheticGestureController( - scoped_ptr<SyntheticGestureTarget> gesture_target); + std::unique_ptr<SyntheticGestureTarget> gesture_target); virtual ~SyntheticGestureController(); typedef base::Callback<void(SyntheticGesture::Result)> OnGestureCompleteCallback; void QueueSyntheticGesture( - scoped_ptr<SyntheticGesture> synthetic_gesture, + std::unique_ptr<SyntheticGesture> synthetic_gesture, const OnGestureCompleteCallback& completion_callback); // Forward input events of the currently processed gesture. @@ -49,8 +49,8 @@ const OnGestureCompleteCallback& completion_callback, SyntheticGesture::Result result); - scoped_ptr<SyntheticGestureTarget> gesture_target_; - scoped_ptr<SyntheticGesture::Result> pending_gesture_result_; + std::unique_ptr<SyntheticGestureTarget> gesture_target_; + std::unique_ptr<SyntheticGesture::Result> pending_gesture_result_; // A queue of gesture/callback pairs. Implemented as two queues to // simplify the ownership of SyntheticGesture pointers. @@ -58,8 +58,8 @@ public: GestureAndCallbackQueue(); ~GestureAndCallbackQueue(); - void Push(scoped_ptr<SyntheticGesture> gesture, - const OnGestureCompleteCallback& callback) { + void Push(std::unique_ptr<SyntheticGesture> gesture, + const OnGestureCompleteCallback& callback) { gestures_.push_back(std::move(gesture)); callbacks_.push(callback); }
diff --git a/content/browser/renderer_host/input/synthetic_gesture_controller_unittest.cc b/content/browser/renderer_host/input/synthetic_gesture_controller_unittest.cc index c1e36823b..748f0ae 100644 --- a/content/browser/renderer_host/input/synthetic_gesture_controller_unittest.cc +++ b/content/browser/renderer_host/input/synthetic_gesture_controller_unittest.cc
@@ -6,10 +6,11 @@ #include <stddef.h> #include <stdint.h> + +#include <memory> #include <utility> #include "base/bind.h" -#include "base/memory/scoped_ptr.h" #include "base/time/time.h" #include "content/browser/renderer_host/input/synthetic_gesture.h" #include "content/browser/renderer_host/input/synthetic_gesture_target.h" @@ -520,10 +521,10 @@ void CreateControllerAndTarget() { target_ = new MockGestureTarget(); controller_.reset(new SyntheticGestureController( - scoped_ptr<SyntheticGestureTarget>(target_))); + std::unique_ptr<SyntheticGestureTarget>(target_))); } - void QueueSyntheticGesture(scoped_ptr<SyntheticGesture> gesture) { + void QueueSyntheticGesture(std::unique_ptr<SyntheticGesture> gesture) { controller_->QueueSyntheticGesture( std::move(gesture), base::Bind( @@ -553,7 +554,7 @@ base::TimeDelta GetTotalTime() const { return time_ - start_time_; } MockSyntheticGestureTarget* target_; - scoped_ptr<SyntheticGestureController> controller_; + std::unique_ptr<SyntheticGestureController> controller_; base::TimeTicks start_time_; base::TimeTicks time_; int num_success_; @@ -600,7 +601,7 @@ CreateControllerAndTarget<MockSyntheticGestureTarget>(); bool finished = false; - scoped_ptr<MockSyntheticGesture> gesture( + std::unique_ptr<MockSyntheticGesture> gesture( new MockSyntheticGesture(&finished, 3)); QueueSyntheticGesture(std::move(gesture)); FlushInputUntilComplete(); @@ -614,7 +615,7 @@ CreateControllerAndTarget<MockSyntheticGestureTarget>(); bool finished = false; - scoped_ptr<MockSyntheticGesture> gesture( + std::unique_ptr<MockSyntheticGesture> gesture( new MockSyntheticGesture(&finished, 0)); QueueSyntheticGesture(std::move(gesture)); FlushInputUntilComplete(); @@ -628,10 +629,10 @@ CreateControllerAndTarget<MockSyntheticGestureTarget>(); bool finished_1 = false; - scoped_ptr<MockSyntheticGesture> gesture_1( + std::unique_ptr<MockSyntheticGesture> gesture_1( new MockSyntheticGesture(&finished_1, 2)); bool finished_2 = false; - scoped_ptr<MockSyntheticGesture> gesture_2( + std::unique_ptr<MockSyntheticGesture> gesture_2( new MockSyntheticGesture(&finished_2, 4)); // Queue first gesture and wait for it to finish @@ -655,10 +656,10 @@ CreateControllerAndTarget<MockSyntheticGestureTarget>(); bool finished_1 = false; - scoped_ptr<MockSyntheticGesture> gesture_1( + std::unique_ptr<MockSyntheticGesture> gesture_1( new MockSyntheticGesture(&finished_1, 2)); bool finished_2 = false; - scoped_ptr<MockSyntheticGesture> gesture_2( + std::unique_ptr<MockSyntheticGesture> gesture_2( new MockSyntheticGesture(&finished_2, 4)); QueueSyntheticGesture(std::move(gesture_1)); @@ -676,9 +677,9 @@ CreateControllerAndTarget<MockSyntheticGestureTarget>(); bool finished_1, finished_2; - scoped_ptr<MockSyntheticGesture> gesture_1( + std::unique_ptr<MockSyntheticGesture> gesture_1( new MockSyntheticGesture(&finished_1, 2)); - scoped_ptr<MockSyntheticGesture> gesture_2( + std::unique_ptr<MockSyntheticGesture> gesture_2( new MockSyntheticGesture(&finished_2, 4)); QueueSyntheticGesture(std::move(gesture_1)); @@ -734,7 +735,7 @@ params.start_point.SetPoint(89, 32); params.distances.push_back(gfx::Vector2d(0, 123)); - scoped_ptr<SyntheticSmoothMoveGesture> gesture( + std::unique_ptr<SyntheticSmoothMoveGesture> gesture( new SyntheticSmoothMoveGesture(params)); QueueSyntheticGesture(std::move(gesture)); FlushInputUntilComplete(); @@ -763,7 +764,7 @@ params.start_point.SetPoint(12, -23); params.distances.push_back(gfx::Vector2d(-234, 0)); - scoped_ptr<SyntheticSmoothMoveGesture> gesture( + std::unique_ptr<SyntheticSmoothMoveGesture> gesture( new SyntheticSmoothMoveGesture(params)); QueueSyntheticGesture(std::move(gesture)); FlushInputUntilComplete(); @@ -808,7 +809,7 @@ params.start_point.SetPoint(0, 7); params.distances.push_back(gfx::Vector2d(413, -83)); - scoped_ptr<SyntheticSmoothMoveGesture> gesture( + std::unique_ptr<SyntheticSmoothMoveGesture> gesture( new SyntheticSmoothMoveGesture(params)); QueueSyntheticGesture(std::move(gesture)); FlushInputUntilComplete(); @@ -834,7 +835,7 @@ params.prevent_fling = true; target_->set_pointer_assumed_stopped_time_ms(543); - scoped_ptr<SyntheticSmoothMoveGesture> gesture( + std::unique_ptr<SyntheticSmoothMoveGesture> gesture( new SyntheticSmoothMoveGesture(params)); QueueSyntheticGesture(std::move(gesture)); FlushInputUntilComplete(); @@ -862,7 +863,7 @@ target_->set_pointer_assumed_stopped_time_ms(543); - scoped_ptr<SyntheticSmoothMoveGesture> gesture( + std::unique_ptr<SyntheticSmoothMoveGesture> gesture( new SyntheticSmoothMoveGesture(params)); QueueSyntheticGesture(std::move(gesture)); FlushInputUntilComplete(); @@ -888,7 +889,7 @@ params.start_point.SetPoint(-32, 43); params.distances.push_back(gfx::Vector2d(0, 0)); - scoped_ptr<SyntheticSmoothMoveGesture> gesture( + std::unique_ptr<SyntheticSmoothMoveGesture> gesture( new SyntheticSmoothMoveGesture(params)); QueueSyntheticGesture(std::move(gesture)); FlushInputUntilComplete(); @@ -908,7 +909,7 @@ params.start_point.SetPoint(432, 89); params.distances.push_back(gfx::Vector2d(0, -234)); - scoped_ptr<SyntheticSmoothMoveGesture> gesture( + std::unique_ptr<SyntheticSmoothMoveGesture> gesture( new SyntheticSmoothMoveGesture(params)); QueueSyntheticGesture(std::move(gesture)); FlushInputUntilComplete(); @@ -928,7 +929,7 @@ params.start_point.SetPoint(90, 12); params.distances.push_back(gfx::Vector2d(345, 0)); - scoped_ptr<SyntheticSmoothMoveGesture> gesture( + std::unique_ptr<SyntheticSmoothMoveGesture> gesture( new SyntheticSmoothMoveGesture(params)); QueueSyntheticGesture(std::move(gesture)); FlushInputUntilComplete(); @@ -948,7 +949,7 @@ params.start_point.SetPoint(90, 12); params.distances.push_back(gfx::Vector2d(-194, 303)); - scoped_ptr<SyntheticSmoothMoveGesture> gesture( + std::unique_ptr<SyntheticSmoothMoveGesture> gesture( new SyntheticSmoothMoveGesture(params)); QueueSyntheticGesture(std::move(gesture)); FlushInputUntilComplete(); @@ -969,7 +970,7 @@ params.distances.push_back(gfx::Vector2d(-129, 212)); params.distances.push_back(gfx::Vector2d(8, -9)); - scoped_ptr<SyntheticSmoothMoveGesture> gesture( + std::unique_ptr<SyntheticSmoothMoveGesture> gesture( new SyntheticSmoothMoveGesture(params)); QueueSyntheticGesture(std::move(gesture)); FlushInputUntilComplete(); @@ -991,7 +992,7 @@ params.distances.push_back(gfx::Vector2d(-129, 0)); params.distances.push_back(gfx::Vector2d(79, 0)); - scoped_ptr<SyntheticSmoothMoveGesture> gesture( + std::unique_ptr<SyntheticSmoothMoveGesture> gesture( new SyntheticSmoothMoveGesture(params)); QueueSyntheticGesture(std::move(gesture)); FlushInputUntilComplete(); @@ -1037,7 +1038,7 @@ params.distances.push_back(gfx::Vector2d(234, 133)); params.distances.push_back(gfx::Vector2d(-9, 78)); - scoped_ptr<SyntheticSmoothMoveGesture> gesture( + std::unique_ptr<SyntheticSmoothMoveGesture> gesture( new SyntheticSmoothMoveGesture(params)); QueueSyntheticGesture(std::move(gesture)); FlushInputUntilComplete(); @@ -1065,7 +1066,7 @@ params.distances.push_back(gfx::Vector2d(0, 133)); params.distances.push_back(gfx::Vector2d(0, 78)); - scoped_ptr<SyntheticSmoothMoveGesture> gesture( + std::unique_ptr<SyntheticSmoothMoveGesture> gesture( new SyntheticSmoothMoveGesture(params)); QueueSyntheticGesture(std::move(gesture)); FlushInputUntilComplete(); @@ -1102,7 +1103,7 @@ params.start_point.SetPoint(0, 7); params.distances.push_back(gfx::Vector2d(413, -83)); - scoped_ptr<SyntheticSmoothMoveGesture> gesture( + std::unique_ptr<SyntheticSmoothMoveGesture> gesture( new SyntheticSmoothMoveGesture(params)); QueueSyntheticGesture(std::move(gesture)); FlushInputUntilComplete(); @@ -1122,7 +1123,7 @@ params.start_point.SetPoint(-32, 43); params.distances.push_back(gfx::Vector2d(0, 0)); - scoped_ptr<SyntheticSmoothMoveGesture> gesture( + std::unique_ptr<SyntheticSmoothMoveGesture> gesture( new SyntheticSmoothMoveGesture(params)); QueueSyntheticGesture(std::move(gesture)); FlushInputUntilComplete(); @@ -1143,7 +1144,7 @@ params.distances.push_back(gfx::Vector2d(234, 133)); params.distances.push_back(gfx::Vector2d(-9, 78)); - scoped_ptr<SyntheticSmoothMoveGesture> gesture( + std::unique_ptr<SyntheticSmoothMoveGesture> gesture( new SyntheticSmoothMoveGesture(params)); QueueSyntheticGesture(std::move(gesture)); FlushInputUntilComplete(); @@ -1165,7 +1166,7 @@ params.distances.push_back(gfx::Vector2d(234, 133)); params.speed_in_pixels_s = 800; - scoped_ptr<SyntheticSmoothDragGesture> gesture( + std::unique_ptr<SyntheticSmoothDragGesture> gesture( new SyntheticSmoothDragGesture(params)); const base::TimeTicks timestamp; gesture->ForwardInputEvents(timestamp, target_); @@ -1181,7 +1182,7 @@ params.distances.push_back(gfx::Vector2d(0, 123)); params.speed_in_pixels_s = 800; - scoped_ptr<SyntheticSmoothDragGesture> gesture( + std::unique_ptr<SyntheticSmoothDragGesture> gesture( new SyntheticSmoothDragGesture(params)); const base::TimeTicks timestamp; gesture->ForwardInputEvents(timestamp, target_); @@ -1194,7 +1195,7 @@ SyntheticSmoothScrollGestureParams params; params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; - scoped_ptr<SyntheticSmoothScrollGesture> gesture( + std::unique_ptr<SyntheticSmoothScrollGesture> gesture( new SyntheticSmoothScrollGesture(params)); const base::TimeTicks timestamp; gesture->ForwardInputEvents(timestamp, target_); @@ -1210,7 +1211,7 @@ params.distances.push_back(gfx::Vector2d(0, -234)); params.speed_in_pixels_s = 800; - scoped_ptr<SyntheticSmoothScrollGesture> gesture( + std::unique_ptr<SyntheticSmoothScrollGesture> gesture( new SyntheticSmoothScrollGesture(params)); const base::TimeTicks timestamp; gesture->ForwardInputEvents(timestamp, target_); @@ -1225,7 +1226,7 @@ params.scale_factor = 2.3f; params.anchor.SetPoint(54, 89); - scoped_ptr<SyntheticTouchscreenPinchGesture> gesture( + std::unique_ptr<SyntheticTouchscreenPinchGesture> gesture( new SyntheticTouchscreenPinchGesture(params)); QueueSyntheticGesture(std::move(gesture)); FlushInputUntilComplete(); @@ -1248,7 +1249,7 @@ params.scale_factor = 0.4f; params.anchor.SetPoint(-12, 93); - scoped_ptr<SyntheticTouchscreenPinchGesture> gesture( + std::unique_ptr<SyntheticTouchscreenPinchGesture> gesture( new SyntheticTouchscreenPinchGesture(params)); QueueSyntheticGesture(std::move(gesture)); FlushInputUntilComplete(); @@ -1270,7 +1271,7 @@ params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; params.scale_factor = 1.0f; - scoped_ptr<SyntheticTouchscreenPinchGesture> gesture( + std::unique_ptr<SyntheticTouchscreenPinchGesture> gesture( new SyntheticTouchscreenPinchGesture(params)); QueueSyntheticGesture(std::move(gesture)); FlushInputUntilComplete(); @@ -1292,7 +1293,7 @@ params.scale_factor = 2.3f; params.anchor.SetPoint(54, 89); - scoped_ptr<SyntheticTouchpadPinchGesture> gesture( + std::unique_ptr<SyntheticTouchpadPinchGesture> gesture( new SyntheticTouchpadPinchGesture(params)); QueueSyntheticGesture(std::move(gesture)); FlushInputUntilComplete(); @@ -1314,7 +1315,7 @@ params.scale_factor = 0.4f; params.anchor.SetPoint(-12, 93); - scoped_ptr<SyntheticTouchpadPinchGesture> gesture( + std::unique_ptr<SyntheticTouchpadPinchGesture> gesture( new SyntheticTouchpadPinchGesture(params)); QueueSyntheticGesture(std::move(gesture)); FlushInputUntilComplete(); @@ -1335,7 +1336,7 @@ params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT; params.scale_factor = 1.0f; - scoped_ptr<SyntheticTouchpadPinchGesture> gesture( + std::unique_ptr<SyntheticTouchpadPinchGesture> gesture( new SyntheticTouchpadPinchGesture(params)); QueueSyntheticGesture(std::move(gesture)); FlushInputUntilComplete(); @@ -1359,7 +1360,8 @@ params.scale_factor = 2.3f; params.anchor.SetPoint(54, 89); - scoped_ptr<SyntheticPinchGesture> gesture(new SyntheticPinchGesture(params)); + std::unique_ptr<SyntheticPinchGesture> gesture( + new SyntheticPinchGesture(params)); QueueSyntheticGesture(std::move(gesture)); FlushInputUntilComplete(); @@ -1377,7 +1379,8 @@ params.scale_factor = 2.3f; params.anchor.SetPoint(54, 89); - scoped_ptr<SyntheticPinchGesture> gesture(new SyntheticPinchGesture(params)); + std::unique_ptr<SyntheticPinchGesture> gesture( + new SyntheticPinchGesture(params)); QueueSyntheticGesture(std::move(gesture)); FlushInputUntilComplete(); @@ -1395,7 +1398,8 @@ params.scale_factor = 2.3f; params.anchor.SetPoint(54, 89); - scoped_ptr<SyntheticPinchGesture> gesture(new SyntheticPinchGesture(params)); + std::unique_ptr<SyntheticPinchGesture> gesture( + new SyntheticPinchGesture(params)); QueueSyntheticGesture(std::move(gesture)); FlushInputUntilComplete(); @@ -1413,7 +1417,8 @@ params.scale_factor = 2.3f; params.anchor.SetPoint(54, 89); - scoped_ptr<SyntheticPinchGesture> gesture(new SyntheticPinchGesture(params)); + std::unique_ptr<SyntheticPinchGesture> gesture( + new SyntheticPinchGesture(params)); QueueSyntheticGesture(std::move(gesture)); FlushInputUntilComplete(); @@ -1429,7 +1434,7 @@ params.duration_ms = 123; params.position.SetPoint(87, -124); - scoped_ptr<SyntheticTapGesture> gesture(new SyntheticTapGesture(params)); + std::unique_ptr<SyntheticTapGesture> gesture(new SyntheticTapGesture(params)); QueueSyntheticGesture(std::move(gesture)); FlushInputUntilComplete(); @@ -1452,7 +1457,7 @@ params.duration_ms = 79; params.position.SetPoint(98, 123); - scoped_ptr<SyntheticTapGesture> gesture(new SyntheticTapGesture(params)); + std::unique_ptr<SyntheticTapGesture> gesture(new SyntheticTapGesture(params)); QueueSyntheticGesture(std::move(gesture)); FlushInputUntilComplete(); @@ -1477,7 +1482,7 @@ params.set_position(gfx::PointF(54, 89)); SyntheticTouchPointer synthetic_pointer; - scoped_ptr<SyntheticPointerAction> gesture( + std::unique_ptr<SyntheticPointerAction> gesture( new SyntheticPointerAction(params, &synthetic_pointer)); QueueSyntheticGesture(std::move(gesture)); FlushInputUntilComplete();
diff --git a/content/browser/renderer_host/input/synthetic_pinch_gesture.h b/content/browser/renderer_host/input/synthetic_pinch_gesture.h index 970bd87..e3c387ef 100644 --- a/content/browser/renderer_host/input/synthetic_pinch_gesture.h +++ b/content/browser/renderer_host/input/synthetic_pinch_gesture.h
@@ -29,7 +29,7 @@ private: SyntheticPinchGestureParams params_; - scoped_ptr<SyntheticGesture> lazy_gesture_; + std::unique_ptr<SyntheticGesture> lazy_gesture_; DISALLOW_COPY_AND_ASSIGN(SyntheticPinchGesture); };
diff --git a/content/browser/renderer_host/input/synthetic_pointer.cc b/content/browser/renderer_host/input/synthetic_pointer.cc index 29228fc..a9e253f 100644 --- a/content/browser/renderer_host/input/synthetic_pointer.cc +++ b/content/browser/renderer_host/input/synthetic_pointer.cc
@@ -4,6 +4,7 @@ #include "content/browser/renderer_host/input/synthetic_pointer.h" +#include "base/memory/ptr_util.h" #include "content/browser/renderer_host/input/synthetic_mouse_pointer.h" #include "content/browser/renderer_host/input/synthetic_touch_pointer.h" #include "third_party/WebKit/public/web/WebInputEvent.h" @@ -14,15 +15,15 @@ SyntheticPointer::~SyntheticPointer() {} // static -scoped_ptr<SyntheticPointer> SyntheticPointer::Create( +std::unique_ptr<SyntheticPointer> SyntheticPointer::Create( SyntheticGestureParams::GestureSourceType gesture_source_type) { if (gesture_source_type == SyntheticGestureParams::TOUCH_INPUT) { - return make_scoped_ptr(new SyntheticTouchPointer()); + return base::WrapUnique(new SyntheticTouchPointer()); } else if (gesture_source_type == SyntheticGestureParams::MOUSE_INPUT) { - return make_scoped_ptr(new SyntheticMousePointer()); + return base::WrapUnique(new SyntheticMousePointer()); } else { NOTREACHED() << "Invalid gesture source type"; - return scoped_ptr<SyntheticPointer>(); + return std::unique_ptr<SyntheticPointer>(); } }
diff --git a/content/browser/renderer_host/input/synthetic_pointer.h b/content/browser/renderer_host/input/synthetic_pointer.h index ae4fd35..b102a07 100644 --- a/content/browser/renderer_host/input/synthetic_pointer.h +++ b/content/browser/renderer_host/input/synthetic_pointer.h
@@ -5,8 +5,9 @@ #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_POINTER_H_ #define CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_POINTER_H_ +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "content/common/content_export.h" #include "content/common/input/synthetic_gesture_params.h" #include "content/common/input/synthetic_web_input_event_builders.h" @@ -20,7 +21,7 @@ SyntheticPointer(); virtual ~SyntheticPointer(); - static scoped_ptr<SyntheticPointer> Create( + static std::unique_ptr<SyntheticPointer> Create( SyntheticGestureParams::GestureSourceType gesture_source_type); virtual void DispatchEvent(SyntheticGestureTarget* target,
diff --git a/content/browser/renderer_host/input/synthetic_smooth_drag_gesture.h b/content/browser/renderer_host/input/synthetic_smooth_drag_gesture.h index 05de242..1d9614ec 100644 --- a/content/browser/renderer_host/input/synthetic_smooth_drag_gesture.h +++ b/content/browser/renderer_host/input/synthetic_smooth_drag_gesture.h
@@ -29,7 +29,7 @@ SyntheticGestureParams::GestureSourceType gesture_type, SyntheticGestureTarget* target); - scoped_ptr<SyntheticSmoothMoveGesture> move_gesture_; + std::unique_ptr<SyntheticSmoothMoveGesture> move_gesture_; SyntheticSmoothDragGestureParams params_; };
diff --git a/content/browser/renderer_host/input/synthetic_smooth_move_gesture.h b/content/browser/renderer_host/input/synthetic_smooth_move_gesture.h index 28be20e..b370ff5 100644 --- a/content/browser/renderer_host/input/synthetic_smooth_move_gesture.h +++ b/content/browser/renderer_host/input/synthetic_smooth_move_gesture.h
@@ -93,7 +93,7 @@ bool MoveIsNoOp() const; SyntheticSmoothMoveGestureParams params_; - scoped_ptr<SyntheticPointer> synthetic_pointer_; + std::unique_ptr<SyntheticPointer> synthetic_pointer_; // Used for mouse input. gfx::Vector2d current_move_segment_total_delta_discrete_; // Used for touch input.
diff --git a/content/browser/renderer_host/input/synthetic_smooth_scroll_gesture.h b/content/browser/renderer_host/input/synthetic_smooth_scroll_gesture.h index 1819b3d..f84013d 100644 --- a/content/browser/renderer_host/input/synthetic_smooth_scroll_gesture.h +++ b/content/browser/renderer_host/input/synthetic_smooth_scroll_gesture.h
@@ -29,7 +29,7 @@ SyntheticGestureParams::GestureSourceType gesture_type, SyntheticGestureTarget* target); - scoped_ptr<SyntheticSmoothMoveGesture> move_gesture_; + std::unique_ptr<SyntheticSmoothMoveGesture> move_gesture_; SyntheticSmoothScrollGestureParams params_; };
diff --git a/content/browser/renderer_host/input/synthetic_tap_gesture.h b/content/browser/renderer_host/input/synthetic_tap_gesture.h index 4f74630..b326433 100644 --- a/content/browser/renderer_host/input/synthetic_tap_gesture.h +++ b/content/browser/renderer_host/input/synthetic_tap_gesture.h
@@ -37,7 +37,7 @@ base::TimeDelta GetDuration() const; SyntheticTapGestureParams params_; - scoped_ptr<SyntheticPointer> synthetic_pointer_; + std::unique_ptr<SyntheticPointer> synthetic_pointer_; base::TimeTicks start_time_; SyntheticGestureParams::GestureSourceType gesture_source_type_; GestureState state_;
diff --git a/content/browser/renderer_host/input/synthetic_touchscreen_pinch_gesture.h b/content/browser/renderer_host/input/synthetic_touchscreen_pinch_gesture.h index c42e608a..de538912 100644 --- a/content/browser/renderer_host/input/synthetic_touchscreen_pinch_gesture.h +++ b/content/browser/renderer_host/input/synthetic_touchscreen_pinch_gesture.h
@@ -48,7 +48,7 @@ bool HasReachedTarget(const base::TimeTicks& timestamp) const; SyntheticPinchGestureParams params_; - scoped_ptr<SyntheticPointer> synthetic_pointer_; + std::unique_ptr<SyntheticPointer> synthetic_pointer_; float start_y_0_; float start_y_1_; float max_pointer_delta_0_;
diff --git a/content/browser/renderer_host/input/tap_suppression_controller_unittest.cc b/content/browser/renderer_host/input/tap_suppression_controller_unittest.cc index c8e30c9..3dd0834 100644 --- a/content/browser/renderer_host/input/tap_suppression_controller_unittest.cc +++ b/content/browser/renderer_host/input/tap_suppression_controller_unittest.cc
@@ -2,9 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/renderer_host/input/tap_suppression_controller.h" + +#include <memory> + +#include "base/macros.h" #include "content/browser/renderer_host/input/tap_suppression_controller_client.h" #include "testing/gtest/include/gtest/gtest.h" @@ -144,7 +146,7 @@ return config; } - scoped_ptr<MockTapSuppressionController> tap_suppression_controller_; + std::unique_ptr<MockTapSuppressionController> tap_suppression_controller_; }; // Test TapSuppressionController for when GestureFlingCancel Ack comes before
diff --git a/content/browser/renderer_host/input/touch_action_browsertest.cc b/content/browser/renderer_host/input/touch_action_browsertest.cc index a1a9e837..2c4ab95 100644 --- a/content/browser/renderer_host/input/touch_action_browsertest.cc +++ b/content/browser/renderer_host/input/touch_action_browsertest.cc
@@ -147,7 +147,7 @@ runner_ = new MessageLoopRunner(); - scoped_ptr<SyntheticSmoothScrollGesture> gesture( + std::unique_ptr<SyntheticSmoothScrollGesture> gesture( new SyntheticSmoothScrollGesture(params)); GetWidgetHost()->QueueSyntheticGesture( std::move(gesture),
diff --git a/content/browser/renderer_host/input/touch_emulator.h b/content/browser/renderer_host/input/touch_emulator.h index c4fd18f7..7994ffc 100644 --- a/content/browser/renderer_host/input/touch_emulator.h +++ b/content/browser/renderer_host/input/touch_emulator.h
@@ -80,7 +80,7 @@ // Emulator is enabled iff gesture provider is created. // Disabled emulator does only process touch acks left from previous // emulation. It does not intercept any events. - scoped_ptr<ui::FilteredGestureProvider> gesture_provider_; + std::unique_ptr<ui::FilteredGestureProvider> gesture_provider_; ui::GestureProviderConfigType gesture_provider_config_type_; bool double_tap_enabled_;
diff --git a/content/browser/renderer_host/input/touch_emulator_unittest.cc b/content/browser/renderer_host/input/touch_emulator_unittest.cc index 0062a2f6..5c6993c 100644 --- a/content/browser/renderer_host/input/touch_emulator_unittest.cc +++ b/content/browser/renderer_host/input/touch_emulator_unittest.cc
@@ -2,14 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/browser/renderer_host/input/touch_emulator.h" + #include <stddef.h> +#include <memory> #include <vector> -#include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" #include "base/time/time.h" -#include "content/browser/renderer_host/input/touch_emulator.h" #include "content/browser/renderer_host/input/touch_emulator_client.h" #include "content/common/input/web_input_event_traits.h" #include "testing/gtest/include/gtest/gtest.h" @@ -234,7 +235,7 @@ void DisableSynchronousTouchAck() { ack_touches_synchronously_ = false; } private: - scoped_ptr<TouchEmulator> emulator_; + std::unique_ptr<TouchEmulator> emulator_; std::vector<WebInputEvent::Type> forwarded_events_; double last_event_time_seconds_; double event_time_delta_seconds_;
diff --git a/content/browser/renderer_host/input/touch_event_queue.cc b/content/browser/renderer_host/input/touch_event_queue.cc index 66023b1..a36520fd 100644 --- a/content/browser/renderer_host/input/touch_event_queue.cc +++ b/content/browser/renderer_host/input/touch_event_queue.cc
@@ -623,7 +623,7 @@ void TouchEventQueue::FlushPendingAsyncTouchmove() { DCHECK(!dispatching_touch_); - scoped_ptr<TouchEventWithLatencyInfo> touch = + std::unique_ptr<TouchEventWithLatencyInfo> touch = std::move(pending_async_touchmove_); touch->event.cancelable = false; touch_queue_.push_front(new CoalescedWebTouchEvent(*touch, true)); @@ -730,7 +730,7 @@ void TouchEventQueue::AckTouchEventToClient( InputEventAckState ack_result, - scoped_ptr<CoalescedWebTouchEvent> acked_event, + std::unique_ptr<CoalescedWebTouchEvent> acked_event, const ui::LatencyInfo* optional_latency_info) { DCHECK(acked_event); DCHECK(!dispatching_touch_ack_); @@ -742,9 +742,9 @@ acked_event->DispatchAckToClient(ack_result, optional_latency_info, client_); } -scoped_ptr<CoalescedWebTouchEvent> TouchEventQueue::PopTouchEvent() { +std::unique_ptr<CoalescedWebTouchEvent> TouchEventQueue::PopTouchEvent() { DCHECK(!touch_queue_.empty()); - scoped_ptr<CoalescedWebTouchEvent> event(touch_queue_.front()); + std::unique_ptr<CoalescedWebTouchEvent> event(touch_queue_.front()); touch_queue_.pop_front(); return event; }
diff --git a/content/browser/renderer_host/input/touch_event_queue.h b/content/browser/renderer_host/input/touch_event_queue.h index 8a19586..64fcf4d8 100644 --- a/content/browser/renderer_host/input/touch_event_queue.h +++ b/content/browser/renderer_host/input/touch_event_queue.h
@@ -157,12 +157,13 @@ // Ack all coalesced events in |acked_event| to the client with |ack_result|, // updating the acked events with |optional_latency_info| if it exists. - void AckTouchEventToClient(InputEventAckState ack_result, - scoped_ptr<CoalescedWebTouchEvent> acked_event, - const ui::LatencyInfo* optional_latency_info); + void AckTouchEventToClient( + InputEventAckState ack_result, + std::unique_ptr<CoalescedWebTouchEvent> acked_event, + const ui::LatencyInfo* optional_latency_info); // Safely pop the head of the queue. - scoped_ptr<CoalescedWebTouchEvent> PopTouchEvent(); + std::unique_ptr<CoalescedWebTouchEvent> PopTouchEvent(); // Dispatch |touch| to the client. Before dispatching, updates pointer // states in touchmove events for pointers that have not changed position. @@ -214,11 +215,11 @@ bool drop_remaining_touches_in_sequence_; // Optional handler for timed-out touch event acks. - scoped_ptr<TouchTimeoutHandler> timeout_handler_; + std::unique_ptr<TouchTimeoutHandler> timeout_handler_; // Suppression of TouchMove's within a slop region when a sequence has not yet // been preventDefaulted. - scoped_ptr<TouchMoveSlopSuppressor> touchmove_slop_suppressor_; + std::unique_ptr<TouchMoveSlopSuppressor> touchmove_slop_suppressor_; // Whether touch events should remain buffered and dispatched asynchronously // while a scroll sequence is active. In this mode, touchmove's are throttled @@ -226,7 +227,7 @@ // until a sufficient time period has elapsed since the last sent touch event. // For details see the design doc at http://goo.gl/lVyJAa. bool send_touch_events_async_; - scoped_ptr<TouchEventWithLatencyInfo> pending_async_touchmove_; + std::unique_ptr<TouchEventWithLatencyInfo> pending_async_touchmove_; // For uncancelable touch moves, not only we send a fake ack, but also a real // ack from render, which we use to decide when to send the next async @@ -241,7 +242,7 @@ double last_sent_touch_timestamp_sec_; // Event is saved to compare pointer positions for new touchmove events. - scoped_ptr<blink::WebTouchEvent> last_sent_touchevent_; + std::unique_ptr<blink::WebTouchEvent> last_sent_touchevent_; DISALLOW_COPY_AND_ASSIGN(TouchEventQueue); };
diff --git a/content/browser/renderer_host/input/touch_event_queue_unittest.cc b/content/browser/renderer_host/input/touch_event_queue_unittest.cc index 01865db..26233c1 100644 --- a/content/browser/renderer_host/input/touch_event_queue_unittest.cc +++ b/content/browser/renderer_host/input/touch_event_queue_unittest.cc
@@ -5,11 +5,12 @@ #include "content/browser/renderer_host/input/touch_event_queue.h" #include <stddef.h> + +#include <memory> #include <utility> #include "base/location.h" #include "base/logging.h" -#include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" #include "base/single_thread_task_runner.h" #include "base/thread_task_runner_handle.h" @@ -71,12 +72,12 @@ last_acked_event_ = event.event; last_acked_event_state_ = ack_result; if (followup_touch_event_) { - scoped_ptr<WebTouchEvent> followup_touch_event = + std::unique_ptr<WebTouchEvent> followup_touch_event = std::move(followup_touch_event_); SendTouchEvent(*followup_touch_event); } if (followup_gesture_event_) { - scoped_ptr<WebGestureEvent> followup_gesture_event = + std::unique_ptr<WebGestureEvent> followup_gesture_event = std::move(followup_gesture_event_); queue_->OnGestureScrollEvent( GestureEventWithLatencyInfo(*followup_gesture_event, @@ -323,15 +324,15 @@ queue_->OnHasTouchEventHandlers(true); } - scoped_ptr<TouchEventQueue> queue_; + std::unique_ptr<TouchEventQueue> queue_; size_t acked_event_count_; WebTouchEvent last_acked_event_; std::vector<WebTouchEvent> sent_events_; InputEventAckState last_acked_event_state_; SyntheticWebTouchEvent touch_event_; - scoped_ptr<WebTouchEvent> followup_touch_event_; - scoped_ptr<WebGestureEvent> followup_gesture_event_; - scoped_ptr<InputEventAckState> sync_ack_result_; + std::unique_ptr<WebTouchEvent> followup_touch_event_; + std::unique_ptr<WebGestureEvent> followup_gesture_event_; + std::unique_ptr<InputEventAckState> sync_ack_result_; double slop_length_dips_; gfx::PointF anchor_; base::MessageLoopForUI message_loop_;
diff --git a/content/browser/renderer_host/input/touch_selection_controller_client_aura.cc b/content/browser/renderer_host/input/touch_selection_controller_client_aura.cc index 88e9663..4508e28 100644 --- a/content/browser/renderer_host/input/touch_selection_controller_client_aura.cc +++ b/content/browser/renderer_host/input/touch_selection_controller_client_aura.cc
@@ -303,9 +303,9 @@ }; } -scoped_ptr<ui::TouchHandleDrawable> +std::unique_ptr<ui::TouchHandleDrawable> TouchSelectionControllerClientAura::CreateDrawable() { - return scoped_ptr<ui::TouchHandleDrawable>( + return std::unique_ptr<ui::TouchHandleDrawable>( new ui::TouchHandleDrawableAura(rwhva_->GetNativeView())); }
diff --git a/content/browser/renderer_host/input/touch_selection_controller_client_aura.h b/content/browser/renderer_host/input/touch_selection_controller_client_aura.h index feeefec..3c80250 100644 --- a/content/browser/renderer_host/input/touch_selection_controller_client_aura.h +++ b/content/browser/renderer_host/input/touch_selection_controller_client_aura.h
@@ -62,7 +62,7 @@ void SelectBetweenCoordinates(const gfx::PointF& base, const gfx::PointF& extent) override; void OnSelectionEvent(ui::SelectionEventType event) override; - scoped_ptr<ui::TouchHandleDrawable> CreateDrawable() override; + std::unique_ptr<ui::TouchHandleDrawable> CreateDrawable() override; // ui::TouchSelectionMenuClient: bool IsCommandIdEnabled(int command_id) const override; @@ -82,7 +82,7 @@ // A pre-target event handler for aura::Env which deactivates touch selection // on mouse and keyboard events. - scoped_ptr<EnvPreTargetHandler> env_pre_target_handler_; + std::unique_ptr<EnvPreTargetHandler> env_pre_target_handler_; DISALLOW_COPY_AND_ASSIGN(TouchSelectionControllerClientAura); };
diff --git a/content/browser/renderer_host/input/touch_selection_controller_client_aura_browsertest.cc b/content/browser/renderer_host/input/touch_selection_controller_client_aura_browsertest.cc index 348b5e6..8f92c25 100644 --- a/content/browser/renderer_host/input/touch_selection_controller_client_aura_browsertest.cc +++ b/content/browser/renderer_host/input/touch_selection_controller_client_aura_browsertest.cc
@@ -7,6 +7,7 @@ #include "base/command_line.h" #include "base/json/json_reader.h" #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/run_loop.h" #include "content/browser/renderer_host/render_widget_host_view_aura.h" #include "content/browser/web_contents/web_contents_impl.h" @@ -25,7 +26,7 @@ namespace { bool JSONToPoint(const std::string& str, gfx::PointF* point) { - scoped_ptr<base::Value> value = base::JSONReader::Read(str); + std::unique_ptr<base::Value> value = base::JSONReader::Read(str); if (!value) return false; base::DictionaryValue* root; @@ -110,7 +111,7 @@ } ui::SelectionEventType expected_event_; - scoped_ptr<base::RunLoop> run_loop_; + std::unique_ptr<base::RunLoop> run_loop_; DISALLOW_COPY_AND_ASSIGN(TestTouchSelectionControllerClientAura); }; @@ -169,7 +170,7 @@ selection_controller_client_ = new TestTouchSelectionControllerClientAura(rwhva); rwhva->SetSelectionControllerClientForTest( - make_scoped_ptr(selection_controller_client_)); + base::WrapUnique(selection_controller_client_)); } private: @@ -185,7 +186,7 @@ ContentBrowserTest::TearDownOnMainThread(); } - scoped_ptr<TestTouchSelectionMenuRunner> menu_runner_; + std::unique_ptr<TestTouchSelectionMenuRunner> menu_runner_; TestTouchSelectionControllerClientAura* selection_controller_client_ = nullptr;
diff --git a/content/browser/renderer_host/input/touchscreen_tap_suppression_controller.h b/content/browser/renderer_host/input/touchscreen_tap_suppression_controller.h index 0f07f729..3e7623e 100644 --- a/content/browser/renderer_host/input/touchscreen_tap_suppression_controller.h +++ b/content/browser/renderer_host/input/touchscreen_tap_suppression_controller.h
@@ -5,8 +5,9 @@ #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCHSCREEN_TAP_SUPPRESSION_CONTROLLER_H_ #define CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCHSCREEN_TAP_SUPPRESSION_CONTROLLER_H_ +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/renderer_host/event_with_latency_info.h" #include "content/browser/renderer_host/input/tap_suppression_controller.h" #include "content/browser/renderer_host/input/tap_suppression_controller_client.h" @@ -43,7 +44,7 @@ GestureEventQueue* gesture_event_queue_; - typedef scoped_ptr<GestureEventWithLatencyInfo> ScopedGestureEvent; + typedef std::unique_ptr<GestureEventWithLatencyInfo> ScopedGestureEvent; ScopedGestureEvent stashed_tap_down_; ScopedGestureEvent stashed_show_press_;
diff --git a/content/browser/renderer_host/input/web_input_event_util.h b/content/browser/renderer_host/input/web_input_event_util.h index b7963a3..d422274 100644 --- a/content/browser/renderer_host/input/web_input_event_util.h +++ b/content/browser/renderer_host/input/web_input_event_util.h
@@ -5,7 +5,8 @@ #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_WEB_INPUT_EVENT_UTIL_H_ #define CONTENT_BROWSER_RENDERER_HOST_INPUT_WEB_INPUT_EVENT_UTIL_H_ -#include "base/memory/scoped_ptr.h" +#include <memory> + #include "base/time/time.h" #include "content/common/content_export.h" #include "third_party/WebKit/public/web/WebInputEvent.h"
diff --git a/content/browser/renderer_host/legacy_render_widget_host_win.cc b/content/browser/renderer_host/legacy_render_widget_host_win.cc index 3412b33c..40b68610 100644 --- a/content/browser/renderer_host/legacy_render_widget_host_win.cc +++ b/content/browser/renderer_host/legacy_render_widget_host_win.cc
@@ -4,8 +4,9 @@ #include "content/browser/renderer_host/legacy_render_widget_host_win.h" +#include <memory> + #include "base/command_line.h" -#include "base/memory/scoped_ptr.h" #include "base/win/win_util.h" #include "base/win/windows_version.h" #include "content/browser/accessibility/browser_accessibility_manager_win.h"
diff --git a/content/browser/renderer_host/legacy_render_widget_host_win.h b/content/browser/renderer_host/legacy_render_widget_host_win.h index 09b1d82..ab2d635e5 100644 --- a/content/browser/renderer_host/legacy_render_widget_host_win.h +++ b/content/browser/renderer_host/legacy_render_widget_host_win.h
@@ -6,12 +6,13 @@ #define CONTENT_BROWSER_RENDERER_HOST_LEGACY_RENDER_WIDGET_HOST_WIN_H_ #include <atlbase.h> -#include <atlwin.h> #include <atlcrack.h> +#include <atlwin.h> #include <oleacc.h> +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/win/scoped_comptr.h" #include "content/common/content_export.h" #include "ui/gfx/geometry/rect.h" @@ -155,7 +156,8 @@ // This class provides functionality to register the legacy window as a // Direct Manipulation consumer. This allows us to support smooth scroll // in Chrome on Windows 10. - scoped_ptr<gfx::win::DirectManipulationHelper> direct_manipulation_helper_; + std::unique_ptr<gfx::win::DirectManipulationHelper> + direct_manipulation_helper_; DISALLOW_COPY_AND_ASSIGN(LegacyRenderWidgetHostHWND); };
diff --git a/content/browser/renderer_host/p2p/socket_dispatcher_host.cc b/content/browser/renderer_host/p2p/socket_dispatcher_host.cc index b1bc3c3c..f044331 100644 --- a/content/browser/renderer_host/p2p/socket_dispatcher_host.cc +++ b/content/browser/renderer_host/p2p/socket_dispatcher_host.cc
@@ -246,7 +246,7 @@ return; } - scoped_ptr<P2PSocketHost> socket(P2PSocketHost::Create( + std::unique_ptr<P2PSocketHost> socket(P2PSocketHost::Create( this, socket_id, type, url_context_.get(), &throttler_)); if (!socket) { @@ -357,7 +357,7 @@ // Creation and connection of a UDP socket might be janky. DCHECK_CURRENTLY_ON(BrowserThread::FILE); - scoped_ptr<net::DatagramClientSocket> socket( + std::unique_ptr<net::DatagramClientSocket> socket( net::ClientSocketFactory::GetDefaultFactory()->CreateDatagramClientSocket( net::DatagramSocket::DEFAULT_BIND, net::RandIntCallback(), NULL, net::NetLog::Source()));
diff --git a/content/browser/renderer_host/p2p/socket_host.cc b/content/browser/renderer_host/p2p/socket_host.cc index fa593fcf..d2ef8f5 100644 --- a/content/browser/renderer_host/p2p/socket_host.cc +++ b/content/browser/renderer_host/p2p/socket_host.cc
@@ -222,7 +222,7 @@ return; } - scoped_ptr<uint8_t[]> header_buffer(new uint8_t[header_length]); + std::unique_ptr<uint8_t[]> header_buffer(new uint8_t[header_length]); memcpy(header_buffer.get(), packet, header_length); // Posts to the IO thread as the data members should be accessed on the IO @@ -234,10 +234,11 @@ header_length, rtp_packet_length, incoming)); } -void P2PSocketHost::DumpRtpPacketOnIOThread(scoped_ptr<uint8_t[]> packet_header, - size_t header_length, - size_t packet_length, - bool incoming) { +void P2PSocketHost::DumpRtpPacketOnIOThread( + std::unique_ptr<uint8_t[]> packet_header, + size_t header_length, + size_t packet_length, + bool incoming) { DCHECK_CURRENTLY_ON(BrowserThread::IO); if ((incoming && !dump_incoming_rtp_packet_) ||
diff --git a/content/browser/renderer_host/p2p/socket_host.h b/content/browser/renderer_host/p2p/socket_host.h index 0b14f0f..70e7276 100644 --- a/content/browser/renderer_host/p2p/socket_host.h +++ b/content/browser/renderer_host/p2p/socket_host.h
@@ -119,7 +119,7 @@ void DumpRtpPacket(const char* packet, size_t length, bool incoming); // A helper to dump the packet on the IO thread. - void DumpRtpPacketOnIOThread(scoped_ptr<uint8_t[]> packet_header, + void DumpRtpPacketOnIOThread(std::unique_ptr<uint8_t[]> packet_header, size_t header_length, size_t packet_length, bool incoming);
diff --git a/content/browser/renderer_host/p2p/socket_host_tcp.cc b/content/browser/renderer_host/p2p/socket_host_tcp.cc index 10398dc6..e55cce7 100644 --- a/content/browser/renderer_host/p2p/socket_host_tcp.cc +++ b/content/browser/renderer_host/p2p/socket_host_tcp.cc
@@ -156,7 +156,7 @@ state_ = STATE_TLS_CONNECTING; StartTls(); } else if (IsPseudoTlsClientSocket(type_)) { - scoped_ptr<net::StreamSocket> transport_socket = std::move(socket_); + std::unique_ptr<net::StreamSocket> transport_socket = std::move(socket_); socket_.reset( new jingle_glue::FakeSSLClientSocket(std::move(transport_socket))); state_ = STATE_TLS_CONNECTING; @@ -179,7 +179,7 @@ DCHECK_EQ(state_, STATE_TLS_CONNECTING); DCHECK(socket_.get()); - scoped_ptr<net::ClientSocketHandle> socket_handle( + std::unique_ptr<net::ClientSocketHandle> socket_handle( new net::ClientSocketHandle()); socket_handle->SetSocket(std::move(socket_));
diff --git a/content/browser/renderer_host/p2p/socket_host_tcp.h b/content/browser/renderer_host/p2p/socket_host_tcp.h index fb4b995..af410f3 100644 --- a/content/browser/renderer_host/p2p/socket_host_tcp.h +++ b/content/browser/renderer_host/p2p/socket_host_tcp.h
@@ -7,13 +7,13 @@ #include <stdint.h> +#include <memory> #include <queue> #include <vector> #include "base/compiler_specific.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" #include "content/browser/renderer_host/p2p/socket_host.h" #include "content/common/p2p_socket_type.h" @@ -88,7 +88,7 @@ P2PHostAndIPEndPoint remote_address_; - scoped_ptr<net::StreamSocket> socket_; + std::unique_ptr<net::StreamSocket> socket_; scoped_refptr<net::GrowableIOBuffer> read_buffer_; std::queue<scoped_refptr<net::DrainableIOBuffer> > write_queue_; scoped_refptr<net::DrainableIOBuffer> write_buffer_;
diff --git a/content/browser/renderer_host/p2p/socket_host_tcp_server.cc b/content/browser/renderer_host/p2p/socket_host_tcp_server.cc index 3d55c29b..a2c031e 100644 --- a/content/browser/renderer_host/p2p/socket_host_tcp_server.cc +++ b/content/browser/renderer_host/p2p/socket_host_tcp_server.cc
@@ -133,7 +133,7 @@ net::StreamSocket* socket = it->second; accepted_sockets_.erase(it); - scoped_ptr<P2PSocketHostTcpBase> result; + std::unique_ptr<P2PSocketHostTcpBase> result; if (client_type_ == P2P_SOCKET_TCP_CLIENT) { result.reset(new P2PSocketHostTcp(message_sender_, id, client_type_, NULL)); } else {
diff --git a/content/browser/renderer_host/p2p/socket_host_tcp_server.h b/content/browser/renderer_host/p2p/socket_host_tcp_server.h index c709177e..9989ef7 100644 --- a/content/browser/renderer_host/p2p/socket_host_tcp_server.h +++ b/content/browser/renderer_host/p2p/socket_host_tcp_server.h
@@ -8,11 +8,11 @@ #include <stdint.h> #include <map> +#include <memory> #include <vector> #include "base/compiler_specific.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" #include "content/browser/renderer_host/p2p/socket_host.h" #include "content/common/content_export.h" @@ -60,10 +60,10 @@ void OnAccepted(int result); const P2PSocketType client_type_; - scoped_ptr<net::ServerSocket> socket_; + std::unique_ptr<net::ServerSocket> socket_; net::IPEndPoint local_address_; - scoped_ptr<net::StreamSocket> accept_socket_; + std::unique_ptr<net::StreamSocket> accept_socket_; AcceptedSocketsMap accepted_sockets_; net::CompletionCallback accept_callback_;
diff --git a/content/browser/renderer_host/p2p/socket_host_tcp_server_unittest.cc b/content/browser/renderer_host/p2p/socket_host_tcp_server_unittest.cc index e11c0c0..5a7efaf8 100644 --- a/content/browser/renderer_host/p2p/socket_host_tcp_server_unittest.cc +++ b/content/browser/renderer_host/p2p/socket_host_tcp_server_unittest.cc
@@ -60,7 +60,7 @@ return net::OK; } - int Accept(scoped_ptr<net::StreamSocket>* socket, + int Accept(std::unique_ptr<net::StreamSocket>* socket, const net::CompletionCallback& callback) override { DCHECK(socket); if (!incoming_sockets_.empty()) { @@ -79,7 +79,7 @@ net::IPEndPoint local_address_; - scoped_ptr<net::StreamSocket>* accept_socket_; + std::unique_ptr<net::StreamSocket>* accept_socket_; net::CompletionCallback accept_callback_; std::list<net::StreamSocket*> incoming_sockets_; @@ -118,7 +118,7 @@ MockIPCSender sender_; FakeServerSocket* socket_; // Owned by |socket_host_|. - scoped_ptr<P2PSocketHostTcpServer> socket_host_; + std::unique_ptr<P2PSocketHostTcpServer> socket_host_; }; // Accept incoming connection. @@ -134,7 +134,7 @@ const int kAcceptedSocketId = 1; - scoped_ptr<P2PSocketHost> new_host( + std::unique_ptr<P2PSocketHost> new_host( socket_host_->AcceptIncomingTcpConnection(addr, kAcceptedSocketId)); ASSERT_TRUE(new_host.get() != NULL); EXPECT_EQ(incoming, GetSocketFormTcpSocketHost( @@ -162,12 +162,12 @@ const int kAcceptedSocketId1 = 1; const int kAcceptedSocketId2 = 2; - scoped_ptr<P2PSocketHost> new_host1( + std::unique_ptr<P2PSocketHost> new_host1( socket_host_->AcceptIncomingTcpConnection(addr1, kAcceptedSocketId1)); ASSERT_TRUE(new_host1.get() != NULL); EXPECT_EQ(incoming1, GetSocketFormTcpSocketHost( reinterpret_cast<P2PSocketHostTcp*>(new_host1.get()))); - scoped_ptr<P2PSocketHost> new_host2( + std::unique_ptr<P2PSocketHost> new_host2( socket_host_->AcceptIncomingTcpConnection(addr2, kAcceptedSocketId2)); ASSERT_TRUE(new_host2.get() != NULL); EXPECT_EQ(incoming2, GetSocketFormTcpSocketHost(
diff --git a/content/browser/renderer_host/p2p/socket_host_tcp_unittest.cc b/content/browser/renderer_host/p2p/socket_host_tcp_unittest.cc index 59aa336..fc604b39 100644 --- a/content/browser/renderer_host/p2p/socket_host_tcp_unittest.cc +++ b/content/browser/renderer_host/p2p/socket_host_tcp_unittest.cc
@@ -66,7 +66,7 @@ std::string sent_data_; FakeSocket* socket_; // Owned by |socket_host_|. - scoped_ptr<P2PSocketHostTcpBase> socket_host_; + std::unique_ptr<P2PSocketHostTcpBase> socket_host_; MockIPCSender sender_; net::IPEndPoint local_address_;
diff --git a/content/browser/renderer_host/p2p/socket_host_throttler.cc b/content/browser/renderer_host/p2p/socket_host_throttler.cc index daefbcc7..8dfcd89e 100644 --- a/content/browser/renderer_host/p2p/socket_host_throttler.cc +++ b/content/browser/renderer_host/p2p/socket_host_throttler.cc
@@ -26,7 +26,7 @@ P2PMessageThrottler::~P2PMessageThrottler() { } -void P2PMessageThrottler::SetTiming(scoped_ptr<rtc::Timing> timing) { +void P2PMessageThrottler::SetTiming(std::unique_ptr<rtc::Timing> timing) { timing_ = std::move(timing); }
diff --git a/content/browser/renderer_host/p2p/socket_host_throttler.h b/content/browser/renderer_host/p2p/socket_host_throttler.h index 0ab1e9db..756e172 100644 --- a/content/browser/renderer_host/p2p/socket_host_throttler.h +++ b/content/browser/renderer_host/p2p/socket_host_throttler.h
@@ -7,8 +7,9 @@ #include <stddef.h> +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "content/common/content_export.h" namespace rtc { @@ -27,13 +28,13 @@ P2PMessageThrottler(); virtual ~P2PMessageThrottler(); - void SetTiming(scoped_ptr<rtc::Timing> timing); + void SetTiming(std::unique_ptr<rtc::Timing> timing); bool DropNextPacket(size_t packet_len); void SetSendIceBandwidth(int bandwith_kbps); private: - scoped_ptr<rtc::Timing> timing_; - scoped_ptr<rtc::RateLimiter> rate_limiter_; + std::unique_ptr<rtc::Timing> timing_; + std::unique_ptr<rtc::RateLimiter> rate_limiter_; DISALLOW_COPY_AND_ASSIGN(P2PMessageThrottler); };
diff --git a/content/browser/renderer_host/p2p/socket_host_udp.h b/content/browser/renderer_host/p2p/socket_host_udp.h index 57f1db3..5d5c1386 100644 --- a/content/browser/renderer_host/p2p/socket_host_udp.h +++ b/content/browser/renderer_host/p2p/socket_host_udp.h
@@ -9,13 +9,13 @@ #include <stdint.h> #include <deque> +#include <memory> #include <set> #include <vector> #include "base/compiler_specific.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" #include "content/browser/renderer_host/p2p/socket_host.h" #include "content/common/content_export.h" @@ -85,7 +85,7 @@ base::TimeTicks send_time, int result); - scoped_ptr<net::DatagramServerSocket> socket_; + std::unique_ptr<net::DatagramServerSocket> socket_; scoped_refptr<net::IOBuffer> recv_buffer_; net::IPEndPoint recv_address_;
diff --git a/content/browser/renderer_host/p2p/socket_host_udp_unittest.cc b/content/browser/renderer_host/p2p/socket_host_udp_unittest.cc index aecd85a7..c9a7b92 100644 --- a/content/browser/renderer_host/p2p/socket_host_udp_unittest.cc +++ b/content/browser/renderer_host/p2p/socket_host_udp_unittest.cc
@@ -187,14 +187,14 @@ dest1_ = ParseAddress(kTestIpAddress1, kTestPort1); dest2_ = ParseAddress(kTestIpAddress2, kTestPort2); - scoped_ptr<rtc::Timing> timing(new FakeTiming()); + std::unique_ptr<rtc::Timing> timing(new FakeTiming()); throttler_.SetTiming(std::move(timing)); } P2PMessageThrottler throttler_; std::deque<FakeDatagramServerSocket::UDPPacket> sent_packets_; FakeDatagramServerSocket* socket_; // Owned by |socket_host_|. - scoped_ptr<P2PSocketHostUdp> socket_host_; + std::unique_ptr<P2PSocketHostUdp> socket_host_; MockIPCSender sender_; net::IPEndPoint local_address_;
diff --git a/content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc b/content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc index 852a7d2..47fd90e 100644 --- a/content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc +++ b/content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc
@@ -4,6 +4,7 @@ #include "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h" +#include "base/memory/ptr_util.h" #include "base/metrics/sparse_histogram.h" #include "content/browser/renderer_host/pepper/pepper_message_filter.h" #include "content/browser/tracing/trace_message_filter.h" @@ -60,7 +61,7 @@ external_plugin_(external_plugin), ssl_context_helper_(new SSLContextHelper()) { message_filter_ = new HostMessageFilter(ppapi_host_.get(), this); - ppapi_host_->AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>( + ppapi_host_->AddHostFactoryFilter(std::unique_ptr<ppapi::host::HostFactory>( new ContentBrowserPepperHostFactory(this))); } @@ -154,7 +155,7 @@ const PepperRendererInstanceData& renderer_instance_data) { DCHECK(!instance_map_.contains(instance)); instance_map_.add(instance, - make_scoped_ptr(new InstanceData(renderer_instance_data))); + base::WrapUnique(new InstanceData(renderer_instance_data))); } void BrowserPpapiHostImpl::DeleteInstance(PP_Instance instance) {
diff --git a/content/browser/renderer_host/pepper/browser_ppapi_host_impl.h b/content/browser/renderer_host/pepper/browser_ppapi_host_impl.h index ca8c6ce..35949ad 100644 --- a/content/browser/renderer_host/pepper/browser_ppapi_host_impl.h +++ b/content/browser/renderer_host/pepper/browser_ppapi_host_impl.h
@@ -145,7 +145,7 @@ // Reports plugin activity to the callback set with SetOnKeepaliveCallback. void OnKeepalive(); - scoped_ptr<ppapi::host::PpapiHost> ppapi_host_; + std::unique_ptr<ppapi::host::PpapiHost> ppapi_host_; base::Process plugin_process_; std::string plugin_name_; base::FilePath plugin_path_; @@ -161,7 +161,8 @@ scoped_refptr<SSLContextHelper> ssl_context_helper_; // Tracks all PP_Instances in this plugin and associated data. - base::ScopedPtrHashMap<PP_Instance, scoped_ptr<InstanceData>> instance_map_; + base::ScopedPtrHashMap<PP_Instance, std::unique_ptr<InstanceData>> + instance_map_; scoped_refptr<HostMessageFilter> message_filter_;
diff --git a/content/browser/renderer_host/pepper/browser_ppapi_host_test.h b/content/browser/renderer_host/pepper/browser_ppapi_host_test.h index b7ca9d4..4137e75 100644 --- a/content/browser/renderer_host/pepper/browser_ppapi_host_test.h +++ b/content/browser/renderer_host/pepper/browser_ppapi_host_test.h
@@ -5,8 +5,9 @@ #ifndef CONTENT_BROWSER_RENDERER_HOST_PEPPER_BROWSER_PPAPI_HOST_TEST_H_ #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_BROWSER_PPAPI_HOST_TEST_H_ +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "content/public/browser/browser_ppapi_host.h" #include "ppapi/proxy/resource_message_test_sink.h" @@ -27,7 +28,7 @@ private: ppapi::proxy::ResourceMessageTestSink sink_; - scoped_ptr<BrowserPpapiHostImpl> ppapi_host_; + std::unique_ptr<BrowserPpapiHostImpl> ppapi_host_; DISALLOW_COPY_AND_ASSIGN(BrowserPpapiHostTest); };
diff --git a/content/browser/renderer_host/pepper/content_browser_pepper_host_factory.cc b/content/browser/renderer_host/pepper/content_browser_pepper_host_factory.cc index 9ad8d5b..2e4a7dc 100644 --- a/content/browser/renderer_host/pepper/content_browser_pepper_host_factory.cc +++ b/content/browser/renderer_host/pepper/content_browser_pepper_host_factory.cc
@@ -57,7 +57,8 @@ ContentBrowserPepperHostFactory::~ContentBrowserPepperHostFactory() {} -scoped_ptr<ResourceHost> ContentBrowserPepperHostFactory::CreateResourceHost( +std::unique_ptr<ResourceHost> +ContentBrowserPepperHostFactory::CreateResourceHost( ppapi::host::PpapiHost* host, PP_Resource resource, PP_Instance instance, @@ -66,12 +67,12 @@ // Make sure the plugin is giving us a valid instance for this resource. if (!host_->IsValidInstance(instance)) - return scoped_ptr<ResourceHost>(); + return std::unique_ptr<ResourceHost>(); // Public interfaces. switch (message.type()) { case PpapiHostMsg_FileIO_Create::ID: { - return scoped_ptr<ResourceHost>( + return std::unique_ptr<ResourceHost>( new PepperFileIOHost(host_, instance, resource)); } case PpapiHostMsg_FileSystem_Create::ID: { @@ -79,23 +80,23 @@ if (!ppapi::UnpackMessage<PpapiHostMsg_FileSystem_Create>( message, &file_system_type)) { NOTREACHED(); - return scoped_ptr<ResourceHost>(); + return std::unique_ptr<ResourceHost>(); } - return scoped_ptr<ResourceHost>(new PepperFileSystemBrowserHost( + return std::unique_ptr<ResourceHost>(new PepperFileSystemBrowserHost( host_, instance, resource, file_system_type)); } case PpapiHostMsg_Gamepad_Create::ID: { - return scoped_ptr<ResourceHost>( + return std::unique_ptr<ResourceHost>( new PepperGamepadHost(host_, instance, resource)); } case PpapiHostMsg_NetworkProxy_Create::ID: { - return scoped_ptr<ResourceHost>( + return std::unique_ptr<ResourceHost>( new PepperNetworkProxyHost(host_, instance, resource)); } case PpapiHostMsg_HostResolver_Create::ID: { scoped_refptr<ResourceMessageFilter> host_resolver( new PepperHostResolverMessageFilter(host_, instance, false)); - return scoped_ptr<ResourceHost>(new MessageFilterHost( + return std::unique_ptr<ResourceHost>(new MessageFilterHost( host_->GetPpapiHost(), instance, resource, host_resolver)); } case PpapiHostMsg_FileRef_CreateForFileAPI::ID: { @@ -104,16 +105,16 @@ if (!UnpackMessage<PpapiHostMsg_FileRef_CreateForFileAPI>( message, &file_system, &internal_path)) { NOTREACHED(); - return scoped_ptr<ResourceHost>(); + return std::unique_ptr<ResourceHost>(); } - return scoped_ptr<ResourceHost>(new PepperFileRefHost( + return std::unique_ptr<ResourceHost>(new PepperFileRefHost( host_, instance, resource, file_system, internal_path)); } case PpapiHostMsg_TCPSocket_Create::ID: { ppapi::TCPSocketVersion version; if (!UnpackMessage<PpapiHostMsg_TCPSocket_Create>(message, &version) || version == ppapi::TCP_SOCKET_VERSION_PRIVATE) { - return scoped_ptr<ResourceHost>(); + return std::unique_ptr<ResourceHost>(); } return CreateNewTCPSocket(instance, resource, version); @@ -122,10 +123,10 @@ if (CanCreateSocket()) { scoped_refptr<ResourceMessageFilter> udp_socket( new PepperUDPSocketMessageFilter(host_, instance, false)); - return scoped_ptr<ResourceHost>(new MessageFilterHost( + return std::unique_ptr<ResourceHost>(new MessageFilterHost( host_->GetPpapiHost(), instance, resource, udp_socket)); } else { - return scoped_ptr<ResourceHost>(); + return std::unique_ptr<ResourceHost>(); } } } @@ -134,27 +135,27 @@ if (GetPermissions().HasPermission(ppapi::PERMISSION_DEV)) { switch (message.type()) { case PpapiHostMsg_Printing_Create::ID: { - scoped_ptr<PepperPrintSettingsManager> manager( + std::unique_ptr<PepperPrintSettingsManager> manager( new PepperPrintSettingsManagerImpl()); - return scoped_ptr<ResourceHost>(new PepperPrintingHost( + return std::unique_ptr<ResourceHost>(new PepperPrintingHost( host_->GetPpapiHost(), instance, resource, std::move(manager))); } case PpapiHostMsg_TrueTypeFont_Create::ID: { SerializedTrueTypeFontDesc desc; if (!UnpackMessage<PpapiHostMsg_TrueTypeFont_Create>(message, &desc)) { NOTREACHED(); - return scoped_ptr<ResourceHost>(); + return std::unique_ptr<ResourceHost>(); } // Check that the family name is valid UTF-8 before passing it to the // host OS. if (!base::IsStringUTF8(desc.family)) - return scoped_ptr<ResourceHost>(); + return std::unique_ptr<ResourceHost>(); - return scoped_ptr<ResourceHost>( + return std::unique_ptr<ResourceHost>( new PepperTrueTypeFontHost(host_, instance, resource, desc)); } case PpapiHostMsg_TrueTypeFontSingleton_Create::ID: { - return scoped_ptr<ResourceHost>( + return std::unique_ptr<ResourceHost>( new PepperTrueTypeFontListHost(host_, instance, resource)); } } @@ -164,7 +165,7 @@ if (GetPermissions().HasPermission(ppapi::PERMISSION_PRIVATE)) { switch (message.type()) { case PpapiHostMsg_BrowserFontSingleton_Create::ID: - return scoped_ptr<ResourceHost>( + return std::unique_ptr<ResourceHost>( new PepperBrowserFontSingletonHost(host_, instance, resource)); } } @@ -178,17 +179,17 @@ if (message.type() == PpapiHostMsg_HostResolver_CreatePrivate::ID) { scoped_refptr<ResourceMessageFilter> host_resolver( new PepperHostResolverMessageFilter(host_, instance, true)); - return scoped_ptr<ResourceHost>(new MessageFilterHost( + return std::unique_ptr<ResourceHost>(new MessageFilterHost( host_->GetPpapiHost(), instance, resource, host_resolver)); } if (message.type() == PpapiHostMsg_TCPServerSocket_CreatePrivate::ID) { if (CanCreateSocket()) { scoped_refptr<ResourceMessageFilter> tcp_server_socket( new PepperTCPServerSocketMessageFilter(this, host_, instance, true)); - return scoped_ptr<ResourceHost>(new MessageFilterHost( + return std::unique_ptr<ResourceHost>(new MessageFilterHost( host_->GetPpapiHost(), instance, resource, tcp_server_socket)); } else { - return scoped_ptr<ResourceHost>(); + return std::unique_ptr<ResourceHost>(); } } if (message.type() == PpapiHostMsg_TCPSocket_CreatePrivate::ID) { @@ -199,14 +200,14 @@ if (CanCreateSocket()) { scoped_refptr<ResourceMessageFilter> udp_socket( new PepperUDPSocketMessageFilter(host_, instance, true)); - return scoped_ptr<ResourceHost>(new MessageFilterHost( + return std::unique_ptr<ResourceHost>(new MessageFilterHost( host_->GetPpapiHost(), instance, resource, udp_socket)); } else { - return scoped_ptr<ResourceHost>(); + return std::unique_ptr<ResourceHost>(); } } if (message.type() == PpapiHostMsg_NetworkMonitor_Create::ID) { - return scoped_ptr<ResourceHost>( + return std::unique_ptr<ResourceHost>( new PepperNetworkMonitorHost(host_, instance, resource)); } @@ -216,43 +217,43 @@ case PpapiHostMsg_FlashFile_Create::ID: { scoped_refptr<ResourceMessageFilter> file_filter( new PepperFlashFileMessageFilter(instance, host_)); - return scoped_ptr<ResourceHost>(new MessageFilterHost( + return std::unique_ptr<ResourceHost>(new MessageFilterHost( host_->GetPpapiHost(), instance, resource, file_filter)); } } } - return scoped_ptr<ResourceHost>(); + return std::unique_ptr<ResourceHost>(); } -scoped_ptr<ppapi::host::ResourceHost> +std::unique_ptr<ppapi::host::ResourceHost> ContentBrowserPepperHostFactory::CreateAcceptedTCPSocket( PP_Instance instance, ppapi::TCPSocketVersion version, - scoped_ptr<net::TCPSocket> socket) { + std::unique_ptr<net::TCPSocket> socket) { if (!CanCreateSocket()) - return scoped_ptr<ResourceHost>(); + return std::unique_ptr<ResourceHost>(); scoped_refptr<ResourceMessageFilter> tcp_socket( new PepperTCPSocketMessageFilter(host_, instance, version, std::move(socket))); - return scoped_ptr<ResourceHost>( + return std::unique_ptr<ResourceHost>( new MessageFilterHost(host_->GetPpapiHost(), instance, 0, tcp_socket)); } -scoped_ptr<ppapi::host::ResourceHost> +std::unique_ptr<ppapi::host::ResourceHost> ContentBrowserPepperHostFactory::CreateNewTCPSocket( PP_Instance instance, PP_Resource resource, ppapi::TCPSocketVersion version) { if (!CanCreateSocket()) - return scoped_ptr<ResourceHost>(); + return std::unique_ptr<ResourceHost>(); scoped_refptr<ResourceMessageFilter> tcp_socket( new PepperTCPSocketMessageFilter(this, host_, instance, version)); if (!tcp_socket.get()) - return scoped_ptr<ResourceHost>(); + return std::unique_ptr<ResourceHost>(); - return scoped_ptr<ResourceHost>(new MessageFilterHost( + return std::unique_ptr<ResourceHost>(new MessageFilterHost( host_->GetPpapiHost(), instance, resource, tcp_socket)); }
diff --git a/content/browser/renderer_host/pepper/content_browser_pepper_host_factory.h b/content/browser/renderer_host/pepper/content_browser_pepper_host_factory.h index c8e98fa..d9b3a55 100644 --- a/content/browser/renderer_host/pepper/content_browser_pepper_host_factory.h +++ b/content/browser/renderer_host/pepper/content_browser_pepper_host_factory.h
@@ -5,10 +5,11 @@ #ifndef CONTENT_BROWSER_RENDERER_HOST_PEPPER_CONTENT_BROWSER_PEPPER_HOST_FACTORY_H_ #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_CONTENT_BROWSER_PEPPER_HOST_FACTORY_H_ +#include <memory> + #include "base/compiler_specific.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "net/socket/tcp_socket.h" #include "ppapi/c/pp_resource.h" #include "ppapi/host/host_factory.h" @@ -29,7 +30,7 @@ ~ContentBrowserPepperHostFactory() override; - scoped_ptr<ppapi::host::ResourceHost> CreateResourceHost( + std::unique_ptr<ppapi::host::ResourceHost> CreateResourceHost( ppapi::host::PpapiHost* host, PP_Resource resource, PP_Instance instance, @@ -37,13 +38,13 @@ // Creates ResourceHost for already accepted TCP |socket|. In the case of // failure returns wrapped NULL. - scoped_ptr<ppapi::host::ResourceHost> CreateAcceptedTCPSocket( + std::unique_ptr<ppapi::host::ResourceHost> CreateAcceptedTCPSocket( PP_Instance instance, ppapi::TCPSocketVersion version, - scoped_ptr<net::TCPSocket> socket); + std::unique_ptr<net::TCPSocket> socket); private: - scoped_ptr<ppapi::host::ResourceHost> CreateNewTCPSocket( + std::unique_ptr<ppapi::host::ResourceHost> CreateNewTCPSocket( PP_Instance instance, PP_Resource resource, ppapi::TCPSocketVersion version);
diff --git a/content/browser/renderer_host/pepper/pepper_browser_font_singleton_host.cc b/content/browser/renderer_host/pepper/pepper_browser_font_singleton_host.cc index 5a4db23..4cbaa79 100644 --- a/content/browser/renderer_host/pepper/pepper_browser_font_singleton_host.cc +++ b/content/browser/renderer_host/pepper/pepper_browser_font_singleton_host.cc
@@ -70,7 +70,7 @@ int32_t FontMessageFilter::OnHostMsgGetFontFamilies( ppapi::host::HostMessageContext* context) { // OK to use "slow blocking" version since we're on the blocking pool. - scoped_ptr<base::ListValue> list(GetFontList_SlowBlocking()); + std::unique_ptr<base::ListValue> list(GetFontList_SlowBlocking()); std::string output; for (size_t i = 0; i < list->GetSize(); i++) {
diff --git a/content/browser/renderer_host/pepper/pepper_file_ref_host.h b/content/browser/renderer_host/pepper/pepper_file_ref_host.h index cd8f67b..d5a6e56 100644 --- a/content/browser/renderer_host/pepper/pepper_file_ref_host.h +++ b/content/browser/renderer_host/pepper/pepper_file_ref_host.h
@@ -103,7 +103,7 @@ int32_t OnGetAbsolutePath(ppapi::host::HostMessageContext* context); BrowserPpapiHost* host_; - scoped_ptr<PepperFileRefBackend> backend_; + std::unique_ptr<PepperFileRefBackend> backend_; base::WeakPtr<PepperFileSystemBrowserHost> file_system_host_; PP_FileSystemType fs_type_;
diff --git a/content/browser/renderer_host/pepper/pepper_file_system_browser_host.h b/content/browser/renderer_host/pepper/pepper_file_system_browser_host.h index bf56a1ad..e41f2498 100644 --- a/content/browser/renderer_host/pepper/pepper_file_system_browser_host.h +++ b/content/browser/renderer_host/pepper/pepper_file_system_browser_host.h
@@ -151,7 +151,8 @@ GURL root_url_; scoped_refptr<storage::FileSystemContext> file_system_context_; - scoped_ptr<storage::FileSystemOperationRunner> file_system_operation_runner_; + std::unique_ptr<storage::FileSystemOperationRunner> + file_system_operation_runner_; // Used only for file systems with quota. // When a PepperFileIOHost calls OpenQuotaFile, we add the id and a non-owning
diff --git a/content/browser/renderer_host/pepper/pepper_file_system_browser_host_unittest.cc b/content/browser/renderer_host/pepper/pepper_file_system_browser_host_unittest.cc index bbc5a14b0a..6ae904b 100644 --- a/content/browser/renderer_host/pepper/pepper_file_system_browser_host_unittest.cc +++ b/content/browser/renderer_host/pepper/pepper_file_system_browser_host_unittest.cc
@@ -4,10 +4,10 @@ #include "content/browser/renderer_host/pepper/pepper_file_system_browser_host.h" +#include <memory> #include <string> #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/renderer_host/pepper/browser_ppapi_host_test.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" @@ -38,7 +38,7 @@ } private: - scoped_ptr<PepperFileSystemBrowserHost> host_; + std::unique_ptr<PepperFileSystemBrowserHost> host_; DISALLOW_COPY_AND_ASSIGN(PepperFileSystemBrowserHostTest); };
diff --git a/content/browser/renderer_host/pepper/pepper_gamepad_host_unittest.cc b/content/browser/renderer_host/pepper/pepper_gamepad_host_unittest.cc index a325e7a39..42ff212b 100644 --- a/content/browser/renderer_host/pepper/pepper_gamepad_host_unittest.cc +++ b/content/browser/renderer_host/pepper/pepper_gamepad_host_unittest.cc
@@ -2,16 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/browser/renderer_host/pepper/pepper_gamepad_host.h" + #include <stddef.h> #include <string.h> +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "build/build_config.h" #include "content/browser/gamepad/gamepad_test_helpers.h" #include "content/browser/renderer_host/pepper/browser_ppapi_host_test.h" -#include "content/browser/renderer_host/pepper/pepper_gamepad_host.h" #include "content/common/gamepad_hardware_buffer.h" #include "ppapi/c/pp_errors.h" #include "ppapi/host/host_message_context.h" @@ -38,7 +40,7 @@ GamepadService* gamepad_service() { return service_->gamepad_service(); } protected: - scoped_ptr<GamepadServiceTestConstructor> service_; + std::unique_ptr<GamepadServiceTestConstructor> service_; DISALLOW_COPY_AND_ASSIGN(PepperGamepadHostTest); };
diff --git a/content/browser/renderer_host/pepper/pepper_host_resolver_message_filter.cc b/content/browser/renderer_host/pepper/pepper_host_resolver_message_filter.cc index 60cba96..bccea9cf 100644 --- a/content/browser/renderer_host/pepper/pepper_host_resolver_message_filter.cc +++ b/content/browser/renderer_host/pepper/pepper_host_resolver_message_filter.cc
@@ -6,8 +6,9 @@ #include <stddef.h> +#include <memory> + #include "base/logging.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h" #include "content/browser/renderer_host/pepper/pepper_lookup_request.h" #include "content/browser/renderer_host/pepper/pepper_socket_utils.h" @@ -170,7 +171,8 @@ net::HostPortPair(host_port.host, host_port.port)); PrepareRequestInfo(hint, &request_info); - scoped_ptr<ReplyMessageContext> bound_info(new ReplyMessageContext(context)); + std::unique_ptr<ReplyMessageContext> bound_info( + new ReplyMessageContext(context)); // The lookup request will delete itself on completion. PepperLookupRequest<ReplyMessageContext>* lookup_request =
diff --git a/content/browser/renderer_host/pepper/pepper_lookup_request.h b/content/browser/renderer_host/pepper/pepper_lookup_request.h index ecbf646..82f3c6800 100644 --- a/content/browser/renderer_host/pepper/pepper_lookup_request.h +++ b/content/browser/renderer_host/pepper/pepper_lookup_request.h
@@ -5,9 +5,10 @@ #ifndef CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_LOOKUP_REQUEST_H_ #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_LOOKUP_REQUEST_H_ +#include <memory> + #include "base/callback.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "net/base/address_list.h" #include "net/base/net_errors.h" #include "net/dns/host_resolver.h" @@ -55,7 +56,7 @@ net::SingleRequestHostResolver resolver_; net::HostResolver::RequestInfo request_info_; net::RequestPriority priority_; - scoped_ptr<T> bound_info_; + std::unique_ptr<T> bound_info_; LookupRequestCallback callback_; net::AddressList addresses_;
diff --git a/content/browser/renderer_host/pepper/pepper_message_filter.h b/content/browser/renderer_host/pepper/pepper_message_filter.h index 04cd1208..3b868e7 100644 --- a/content/browser/renderer_host/pepper/pepper_message_filter.h +++ b/content/browser/renderer_host/pepper/pepper_message_filter.h
@@ -5,11 +5,11 @@ #ifndef CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_MESSAGE_FILTER_H_ #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_MESSAGE_FILTER_H_ +#include <memory> #include <vector> #include "base/compiler_specific.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "content/public/browser/browser_message_filter.h" namespace ppapi {
diff --git a/content/browser/renderer_host/pepper/pepper_network_monitor_host.cc b/content/browser/renderer_host/pepper/pepper_network_monitor_host.cc index 211906a1..4382f43 100644 --- a/content/browser/renderer_host/pepper/pepper_network_monitor_host.cc +++ b/content/browser/renderer_host/pepper/pepper_network_monitor_host.cc
@@ -33,8 +33,9 @@ render_frame_id); } -scoped_ptr<net::NetworkInterfaceList> GetNetworkList() { - scoped_ptr<net::NetworkInterfaceList> list(new net::NetworkInterfaceList()); +std::unique_ptr<net::NetworkInterfaceList> GetNetworkList() { + std::unique_ptr<net::NetworkInterfaceList> list( + new net::NetworkInterfaceList()); net::GetNetworkList(list.get(), net::INCLUDE_HOST_SCOPE_VIRTUAL_INTERFACES); return list; } @@ -93,10 +94,10 @@ } void PepperNetworkMonitorHost::SendNetworkList( - scoped_ptr<net::NetworkInterfaceList> list) { + std::unique_ptr<net::NetworkInterfaceList> list) { DCHECK_CURRENTLY_ON(BrowserThread::IO); - scoped_ptr<ppapi::proxy::SerializedNetworkList> list_copy( + std::unique_ptr<ppapi::proxy::SerializedNetworkList> list_copy( new ppapi::proxy::SerializedNetworkList(list->size())); for (size_t i = 0; i < list->size(); ++i) { const net::NetworkInterface& network = list->at(i);
diff --git a/content/browser/renderer_host/pepper/pepper_network_monitor_host.h b/content/browser/renderer_host/pepper/pepper_network_monitor_host.h index ef1b305..c04d499 100644 --- a/content/browser/renderer_host/pepper/pepper_network_monitor_host.h +++ b/content/browser/renderer_host/pepper/pepper_network_monitor_host.h
@@ -36,7 +36,7 @@ void OnPermissionCheckResult(bool can_use_network_monitor); void GetAndSendNetworkList(); - void SendNetworkList(scoped_ptr<net::NetworkInterfaceList> list); + void SendNetworkList(std::unique_ptr<net::NetworkInterfaceList> list); ppapi::host::ReplyMessageContext reply_context_;
diff --git a/content/browser/renderer_host/pepper/pepper_print_settings_manager.cc b/content/browser/renderer_host/pepper/pepper_print_settings_manager.cc index 1343f9a1..a264e5f0 100644 --- a/content/browser/renderer_host/pepper/pepper_print_settings_manager.cc +++ b/content/browser/renderer_host/pepper/pepper_print_settings_manager.cc
@@ -59,7 +59,7 @@ DCHECK_CURRENTLY_ON(BrowserThread::UI); PrintingContextDelegate delegate; - scoped_ptr<printing::PrintingContext> context( + std::unique_ptr<printing::PrintingContext> context( printing::PrintingContext::Create(&delegate)); if (!context.get() || context->UseDefaultSettings() != printing::PrintingContext::OK) {
diff --git a/content/browser/renderer_host/pepper/pepper_printing_host.cc b/content/browser/renderer_host/pepper/pepper_printing_host.cc index 5f9fcaa..97d4f42db 100644 --- a/content/browser/renderer_host/pepper/pepper_printing_host.cc +++ b/content/browser/renderer_host/pepper/pepper_printing_host.cc
@@ -19,7 +19,7 @@ ppapi::host::PpapiHost* host, PP_Instance instance, PP_Resource resource, - scoped_ptr<PepperPrintSettingsManager> print_settings_manager) + std::unique_ptr<PepperPrintSettingsManager> print_settings_manager) : ResourceHost(host, instance, resource), print_settings_manager_(std::move(print_settings_manager)), weak_factory_(this) {}
diff --git a/content/browser/renderer_host/pepper/pepper_printing_host.h b/content/browser/renderer_host/pepper/pepper_printing_host.h index fc022f1..5dd51d1 100644 --- a/content/browser/renderer_host/pepper/pepper_printing_host.h +++ b/content/browser/renderer_host/pepper/pepper_printing_host.h
@@ -7,9 +7,10 @@ #include <stdint.h> +#include <memory> + #include "base/compiler_specific.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "content/browser/renderer_host/pepper/pepper_print_settings_manager.h" #include "content/common/content_export.h" @@ -24,7 +25,7 @@ ppapi::host::PpapiHost* host, PP_Instance instance, PP_Resource resource, - scoped_ptr<PepperPrintSettingsManager> print_settings_manager); + std::unique_ptr<PepperPrintSettingsManager> print_settings_manager); ~PepperPrintingHost() override; // ppapi::host::ResourceHost implementation. @@ -38,7 +39,7 @@ void PrintSettingsCallback(ppapi::host::ReplyMessageContext reply_context, PepperPrintSettingsManager::Result result); - scoped_ptr<PepperPrintSettingsManager> print_settings_manager_; + std::unique_ptr<PepperPrintSettingsManager> print_settings_manager_; base::WeakPtrFactory<PepperPrintingHost> weak_factory_;
diff --git a/content/browser/renderer_host/pepper/pepper_printing_host_unittest.cc b/content/browser/renderer_host/pepper/pepper_printing_host_unittest.cc index b54ec04..30570b17 100644 --- a/content/browser/renderer_host/pepper/pepper_printing_host_unittest.cc +++ b/content/browser/renderer_host/pepper/pepper_printing_host_unittest.cc
@@ -81,7 +81,7 @@ PP_PRINTOUTPUTFORMAT_PDF}; // Construct the resource host. - scoped_ptr<PepperPrintSettingsManager> manager( + std::unique_ptr<PepperPrintSettingsManager> manager( new MockPepperPrintSettingsManager(expected_settings)); PepperPrintingHost printing(GetBrowserPpapiHost()->GetPpapiHost(), pp_instance, pp_resource, std::move(manager));
diff --git a/content/browser/renderer_host/pepper/pepper_renderer_connection.cc b/content/browser/renderer_host/pepper/pepper_renderer_connection.cc index da171c2..d62fe9c 100644 --- a/content/browser/renderer_host/pepper/pepper_renderer_connection.cc +++ b/content/browser/renderer_host/pepper/pepper_renderer_connection.cc
@@ -50,7 +50,7 @@ // attached to a real resource. void AddPendingResourceHost( size_t index, - scoped_ptr<ppapi::host::ResourceHost> resource_host); + std::unique_ptr<ppapi::host::ResourceHost> resource_host); private: friend class base::RefCounted<PendingHostCreator>; @@ -81,7 +81,7 @@ void PendingHostCreator::AddPendingResourceHost( size_t index, - scoped_ptr<ppapi::host::ResourceHost> resource_host) { + std::unique_ptr<ppapi::host::ResourceHost> resource_host) { pending_resource_host_ids_[index] = host_->GetPpapiHost()->AddPendingResourceHost(std::move(resource_host)); } @@ -173,7 +173,7 @@ host, this, routing_id, params.sequence(), nested_msgs.size()); for (size_t i = 0; i < nested_msgs.size(); ++i) { const IPC::Message& nested_msg = nested_msgs[i]; - scoped_ptr<ppapi::host::ResourceHost> resource_host; + std::unique_ptr<ppapi::host::ResourceHost> resource_host; if (host->IsValidInstance(instance)) { if (nested_msg.type() == PpapiHostMsg_FileRef_CreateForRawFS::ID) { // FileRef_CreateForRawFS is only permitted from the renderer. Because
diff --git a/content/browser/renderer_host/pepper/pepper_renderer_connection.h b/content/browser/renderer_host/pepper/pepper_renderer_connection.h index 37c5a07..00b4a7a 100644 --- a/content/browser/renderer_host/pepper/pepper_renderer_connection.h +++ b/content/browser/renderer_host/pepper/pepper_renderer_connection.h
@@ -5,11 +5,11 @@ #ifndef CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_RENDERER_CONNECTION_H_ #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_RENDERER_CONNECTION_H_ +#include <memory> #include <vector> #include "base/compiler_specific.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "content/public/browser/browser_message_filter.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" @@ -64,7 +64,7 @@ // running. This is just a work-around allowing new style resources to work // with the browser when running in-process but it means that plugin-specific // information (like the plugin name) won't be available. - scoped_ptr<BrowserPpapiHostImpl> in_process_host_; + std::unique_ptr<BrowserPpapiHostImpl> in_process_host_; DISALLOW_COPY_AND_ASSIGN(PepperRendererConnection); };
diff --git a/content/browser/renderer_host/pepper/pepper_socket_utils.h b/content/browser/renderer_host/pepper/pepper_socket_utils.h index ce33b02..b10c940 100644 --- a/content/browser/renderer_host/pepper/pepper_socket_utils.h +++ b/content/browser/renderer_host/pepper/pepper_socket_utils.h
@@ -5,13 +5,14 @@ #ifndef CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_SOCKET_UTILS_H_ #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_SOCKET_UTILS_H_ +#include <memory> + #include "build/build_config.h" #include "content/public/common/socket_permission_request.h" #include "ppapi/c/pp_stdint.h" #if defined(OS_CHROMEOS) #include "base/callback_forward.h" -#include "base/memory/scoped_ptr.h" #include "net/base/ip_endpoint.h" #endif // defined(OS_CHROMEOS) @@ -60,7 +61,7 @@ ppapi::PPB_X509Certificate_Fields* fields); #if defined(OS_CHROMEOS) -typedef base::Callback<void(scoped_ptr<chromeos::FirewallHole>)> +typedef base::Callback<void(std::unique_ptr<chromeos::FirewallHole>)> FirewallHoleOpenCallback; // Returns true if the open operation is in progress.
diff --git a/content/browser/renderer_host/pepper/pepper_tcp_server_socket_message_filter.cc b/content/browser/renderer_host/pepper/pepper_tcp_server_socket_message_filter.cc index 080a63a3..d29a59d 100644 --- a/content/browser/renderer_host/pepper/pepper_tcp_server_socket_message_filter.cc +++ b/content/browser/renderer_host/pepper/pepper_tcp_server_socket_message_filter.cc
@@ -264,7 +264,7 @@ void PepperTCPServerSocketMessageFilter::OnFirewallHoleOpened( const ppapi::host::ReplyMessageContext& context, int32_t net_result, - scoped_ptr<chromeos::FirewallHole> hole) { + std::unique_ptr<chromeos::FirewallHole> hole) { DCHECK_CURRENTLY_ON(BrowserThread::IO); LOG_IF(WARNING, !hole.get()) << "Firewall hole could not be opened."; @@ -311,7 +311,7 @@ return; } - scoped_ptr<ppapi::host::ResourceHost> host = + std::unique_ptr<ppapi::host::ResourceHost> host = factory_->CreateAcceptedTCPSocket(instance_, ppapi::TCP_SOCKET_VERSION_PRIVATE, std::move(accepted_socket_));
diff --git a/content/browser/renderer_host/pepper/pepper_tcp_server_socket_message_filter.h b/content/browser/renderer_host/pepper/pepper_tcp_server_socket_message_filter.h index f633ccb0..9c7be218 100644 --- a/content/browser/renderer_host/pepper/pepper_tcp_server_socket_message_filter.h +++ b/content/browser/renderer_host/pepper/pepper_tcp_server_socket_message_filter.h
@@ -8,10 +8,11 @@ #include <stddef.h> #include <stdint.h> +#include <memory> + #include "base/compiler_specific.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "build/build_config.h" #include "content/common/content_export.h" #include "net/base/ip_endpoint.h" @@ -101,7 +102,7 @@ int net_result); void OnFirewallHoleOpened(const ppapi::host::ReplyMessageContext& context, int32_t net_result, - scoped_ptr<chromeos::FirewallHole> hole); + std::unique_ptr<chromeos::FirewallHole> hole); #endif // defined(OS_CHROMEOS) // Following fields are initialized and used only on the IO thread. @@ -112,12 +113,13 @@ PP_Instance instance_; State state_; - scoped_ptr<net::TCPSocket> socket_; - scoped_ptr<net::TCPSocket> accepted_socket_; + std::unique_ptr<net::TCPSocket> socket_; + std::unique_ptr<net::TCPSocket> accepted_socket_; net::IPEndPoint accepted_address_; #if defined(OS_CHROMEOS) - scoped_ptr<chromeos::FirewallHole, content::BrowserThread::DeleteOnUIThread> + std::unique_ptr<chromeos::FirewallHole, + content::BrowserThread::DeleteOnUIThread> firewall_hole_; #endif // defined(OS_CHROMEOS)
diff --git a/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.cc b/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.cc index 661fdc5..648a600 100644 --- a/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.cc +++ b/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.cc
@@ -11,6 +11,7 @@ #include "base/bind.h" #include "base/location.h" #include "base/logging.h" +#include "base/memory/ptr_util.h" #include "base/metrics/histogram_macros.h" #include "base/profiler/scoped_tracker.h" #include "build/build_config.h" @@ -96,7 +97,7 @@ BrowserPpapiHostImpl* host, PP_Instance instance, TCPSocketVersion version, - scoped_ptr<net::TCPSocket> socket) + std::unique_ptr<net::TCPSocket> socket) : version_(version), external_plugin_(host->external_plugin()), render_process_id_(0), @@ -322,8 +323,9 @@ if (socket_->GetPeerAddress(&peer_address) != net::OK) return PP_ERROR_FAILED; - scoped_ptr<net::ClientSocketHandle> handle(new net::ClientSocketHandle()); - handle->SetSocket(make_scoped_ptr<net::StreamSocket>( + std::unique_ptr<net::ClientSocketHandle> handle( + new net::ClientSocketHandle()); + handle->SetSocket(base::WrapUnique<net::StreamSocket>( new net::TCPClientSocket(std::move(socket_), peer_address))); net::ClientSocketFactory* factory = net::ClientSocketFactory::GetDefaultFactory(); @@ -969,7 +971,7 @@ void PepperTCPSocketMessageFilter::OnFirewallHoleOpened( const ppapi::host::ReplyMessageContext& context, int32_t result, - scoped_ptr<chromeos::FirewallHole> hole) { + std::unique_ptr<chromeos::FirewallHole> hole) { LOG_IF(WARNING, !hole.get()) << "Firewall hole could not be opened."; firewall_hole_.reset(hole.release()); @@ -1018,7 +1020,7 @@ // |factory_| is guaranteed to be non-NULL here. Only those instances created // in CONNECTED state have a NULL |factory_|, while getting here requires // LISTENING state. - scoped_ptr<ppapi::host::ResourceHost> host = + std::unique_ptr<ppapi::host::ResourceHost> host = factory_->CreateAcceptedTCPSocket(instance_, version_, std::move(accepted_socket_)); if (!host) {
diff --git a/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.h b/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.h index 8fe42c1b..403ffc72 100644 --- a/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.h +++ b/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.h
@@ -8,13 +8,13 @@ #include <stddef.h> #include <stdint.h> +#include <memory> #include <string> #include <vector> #include "base/compiler_specific.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "build/build_config.h" #include "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h" #include "content/browser/renderer_host/pepper/ssl_context_helper.h" @@ -69,7 +69,7 @@ PepperTCPSocketMessageFilter(BrowserPpapiHostImpl* host, PP_Instance instance, ppapi::TCPSocketVersion version, - scoped_ptr<net::TCPSocket> socket); + std::unique_ptr<net::TCPSocket> socket); static size_t GetNumInstances(); @@ -153,7 +153,7 @@ int32_t pp_result); void OnFirewallHoleOpened(const ppapi::host::ReplyMessageContext& context, int32_t result, - scoped_ptr<chromeos::FirewallHole> hole); + std::unique_ptr<chromeos::FirewallHole> hole); #endif // defined(OS_CHROMEOS) void SendBindReply(const ppapi::host::ReplyMessageContext& context, @@ -215,11 +215,12 @@ PP_NetAddress_Private bind_input_addr_; #if defined(OS_CHROMEOS) - scoped_ptr<chromeos::FirewallHole, content::BrowserThread::DeleteOnUIThread> + std::unique_ptr<chromeos::FirewallHole, + content::BrowserThread::DeleteOnUIThread> firewall_hole_; #endif // defined(OS_CHROMEOS) - scoped_ptr<net::SingleRequestHostResolver> resolver_; + std::unique_ptr<net::SingleRequestHostResolver> resolver_; // Bitwise-or of SocketOption flags. This stores the state about whether // each option is set before Connect() is called. @@ -238,9 +239,9 @@ size_t address_index_; // Non-null unless an SSL connection is requested. - scoped_ptr<net::TCPSocket> socket_; + std::unique_ptr<net::TCPSocket> socket_; // Non-null if an SSL connection is requested. - scoped_ptr<net::SSLClientSocket> ssl_socket_; + std::unique_ptr<net::SSLClientSocket> ssl_socket_; scoped_refptr<net::IOBuffer> read_buffer_; @@ -253,7 +254,7 @@ scoped_refptr<SSLContextHelper> ssl_context_helper_; bool pending_accept_; - scoped_ptr<net::TCPSocket> accepted_socket_; + std::unique_ptr<net::TCPSocket> accepted_socket_; net::IPEndPoint accepted_address_; // If the plugin is throttled, we defer completing socket reads until
diff --git a/content/browser/renderer_host/pepper/pepper_truetype_font_host.h b/content/browser/renderer_host/pepper/pepper_truetype_font_host.h index f574c317..cd1e701 100644 --- a/content/browser/renderer_host/pepper/pepper_truetype_font_host.h +++ b/content/browser/renderer_host/pepper/pepper_truetype_font_host.h
@@ -7,12 +7,12 @@ #include <stdint.h> +#include <memory> #include <string> #include <vector> #include "base/compiler_specific.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/sequenced_task_runner.h" #include "content/browser/renderer_host/pepper/pepper_truetype_font.h"
diff --git a/content/browser/renderer_host/pepper/pepper_truetype_font_linux.cc b/content/browser/renderer_host/pepper/pepper_truetype_font_linux.cc index 4c51d6f2..ac081c2 100644 --- a/content/browser/renderer_host/pepper/pepper_truetype_font_linux.cc +++ b/content/browser/renderer_host/pepper/pepper_truetype_font_linux.cc
@@ -2,17 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/browser/renderer_host/pepper/pepper_truetype_font.h" + #include <stddef.h> #include <stdint.h> +#include <memory> + #include "base/compiler_specific.h" #include "base/files/scoped_file.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/numerics/safe_conversions.h" #include "base/sys_byteorder.h" #include "content/browser/renderer_host/font_utils_linux.h" -#include "content/browser/renderer_host/pepper/pepper_truetype_font.h" #include "content/public/common/child_process_sandbox_support_linux.h" #include "ppapi/c/dev/ppb_truetype_font_dev.h" #include "ppapi/c/pp_errors.h" @@ -102,7 +104,7 @@ static const size_t kFontHeaderSize = 12; static const size_t kTableEntrySize = 16; output_length = num_tables * kTableEntrySize; - scoped_ptr<uint8_t[]> table_entries(new uint8_t[output_length]); + std::unique_ptr<uint8_t[]> table_entries(new uint8_t[output_length]); // Get the table directory entries, which follow the font header. if (!GetFontTable(fd_.get(), 0 /* tag */,
diff --git a/content/browser/renderer_host/pepper/pepper_truetype_font_win.cc b/content/browser/renderer_host/pepper/pepper_truetype_font_win.cc index 194decd8..aa6b837 100644 --- a/content/browser/renderer_host/pepper/pepper_truetype_font_win.cc +++ b/content/browser/renderer_host/pepper/pepper_truetype_font_win.cc
@@ -4,14 +4,15 @@ #include "content/browser/renderer_host/pepper/pepper_truetype_font.h" -#include <windows.h> #include <stdint.h> +#include <windows.h> + #include <algorithm> +#include <memory> #include <set> #include "base/compiler_specific.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/strings/utf_string_conversions.h" #include "base/sys_byteorder.h" #include "base/win/scoped_gdi_object.h" @@ -160,7 +161,7 @@ // The size in bytes of an entry in the table directory. static const DWORD kDirectoryEntrySize = 16; DWORD directory_size = num_tables * kDirectoryEntrySize; - scoped_ptr<uint8_t[]> directory(new uint8_t[directory_size]); + std::unique_ptr<uint8_t[]> directory(new uint8_t[directory_size]); // Get the table directory entries after the font header. if (GetFontData(hdc.Get(), 0 /* tag */, kFontHeaderSize, directory.get(), directory_size) ==
diff --git a/content/browser/renderer_host/pepper/pepper_udp_socket_message_filter.cc b/content/browser/renderer_host/pepper/pepper_udp_socket_message_filter.cc index b5f6e14c..06af4cb 100644 --- a/content/browser/renderer_host/pepper/pepper_udp_socket_message_filter.cc +++ b/content/browser/renderer_host/pepper/pepper_udp_socket_message_filter.cc
@@ -403,9 +403,9 @@ return; } - scoped_ptr<net::UDPSocket> socket(new net::UDPSocket( - net::DatagramSocket::DEFAULT_BIND, net::RandIntCallback(), - NULL, net::NetLog::Source())); + std::unique_ptr<net::UDPSocket> socket( + new net::UDPSocket(net::DatagramSocket::DEFAULT_BIND, + net::RandIntCallback(), NULL, net::NetLog::Source())); std::vector<uint8_t> address; uint16_t port; @@ -511,7 +511,7 @@ } void PepperUDPSocketMessageFilter::OnBindComplete( - scoped_ptr<net::UDPSocket> socket, + std::unique_ptr<net::UDPSocket> socket, const ppapi::host::ReplyMessageContext& context, const PP_NetAddress_Private& net_address) { DCHECK_CURRENTLY_ON(BrowserThread::IO); @@ -535,7 +535,7 @@ void PepperUDPSocketMessageFilter::OnFirewallHoleOpened( base::Closure bind_complete, - scoped_ptr<chromeos::FirewallHole> hole) { + std::unique_ptr<chromeos::FirewallHole> hole) { DCHECK_CURRENTLY_ON(BrowserThread::UI); LOG_IF(WARNING, !hole.get()) << "Firewall hole could not be opened.";
diff --git a/content/browser/renderer_host/pepper/pepper_udp_socket_message_filter.h b/content/browser/renderer_host/pepper/pepper_udp_socket_message_filter.h index 6420581..aef6c2f 100644 --- a/content/browser/renderer_host/pepper/pepper_udp_socket_message_filter.h +++ b/content/browser/renderer_host/pepper/pepper_udp_socket_message_filter.h
@@ -7,6 +7,7 @@ #include <stddef.h> +#include <memory> #include <queue> #include <string> @@ -14,7 +15,6 @@ #include "base/compiler_specific.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "build/build_config.h" #include "content/common/content_export.h" #include "content/public/common/process_type.h" @@ -114,14 +114,14 @@ void DoBind(const ppapi::host::ReplyMessageContext& context, const PP_NetAddress_Private& addr); - void OnBindComplete(scoped_ptr<net::UDPSocket> socket, + void OnBindComplete(std::unique_ptr<net::UDPSocket> socket, const ppapi::host::ReplyMessageContext& context, const PP_NetAddress_Private& net_address); #if defined(OS_CHROMEOS) void OpenFirewallHole(const net::IPEndPoint& local_address, base::Closure bind_complete); void OnFirewallHoleOpened(base::Closure bind_complete, - scoped_ptr<chromeos::FirewallHole> hole); + std::unique_ptr<chromeos::FirewallHole> hole); #endif // defined(OS_CHROMEOS) void DoRecvFrom(); void DoSendTo(const ppapi::host::ReplyMessageContext& context, @@ -164,10 +164,11 @@ int multicast_ttl_; int32_t can_use_multicast_; - scoped_ptr<net::UDPSocket> socket_; + std::unique_ptr<net::UDPSocket> socket_; bool closed_; #if defined(OS_CHROMEOS) - scoped_ptr<chromeos::FirewallHole, content::BrowserThread::DeleteOnUIThread> + std::unique_ptr<chromeos::FirewallHole, + content::BrowserThread::DeleteOnUIThread> firewall_hole_; #endif // defined(OS_CHROMEOS)
diff --git a/content/browser/renderer_host/pepper/quota_reservation.cc b/content/browser/renderer_host/pepper/quota_reservation.cc index 518421a..32eb474 100644 --- a/content/browser/renderer_host/pepper/quota_reservation.cc +++ b/content/browser/renderer_host/pepper/quota_reservation.cc
@@ -4,9 +4,10 @@ #include "content/browser/renderer_host/pepper/quota_reservation.h" +#include <memory> + #include "base/bind.h" #include "base/callback.h" -#include "base/memory/scoped_ptr.h" #include "content/public/browser/browser_thread.h" #include "storage/browser/fileapi/file_system_operation_runner.h" #include "storage/browser/fileapi/quota/open_file_handle.h" @@ -65,7 +66,7 @@ platform_file_path = url.path(); } - scoped_ptr<storage::OpenFileHandle> file_handle = + std::unique_ptr<storage::OpenFileHandle> file_handle = quota_reservation_->GetOpenFileHandle(platform_file_path); std::pair<FileMap::iterator, bool> insert_result = files_.insert(std::make_pair(id, file_handle.get()));
diff --git a/content/browser/renderer_host/pepper/quota_reservation_unittest.cc b/content/browser/renderer_host/pepper/quota_reservation_unittest.cc index 1416587d0..8348f4a 100644 --- a/content/browser/renderer_host/pepper/quota_reservation_unittest.cc +++ b/content/browser/renderer_host/pepper/quota_reservation_unittest.cc
@@ -6,6 +6,8 @@ #include <stdint.h> +#include <memory> + #include "base/bind.h" #include "base/bind_helpers.h" #include "base/files/file.h" @@ -13,7 +15,6 @@ #include "base/files/scoped_temp_dir.h" #include "base/location.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/thread_task_runner_handle.h" @@ -79,7 +80,8 @@ ASSERT_TRUE(work_dir_.CreateUniqueTempDir()); reservation_manager_.reset(new QuotaReservationManager( - scoped_ptr<QuotaReservationManager::QuotaBackend>(new FakeBackend))); + std::unique_ptr<QuotaReservationManager::QuotaBackend>( + new FakeBackend))); } void TearDown() override { @@ -120,7 +122,7 @@ private: base::MessageLoop message_loop_; base::ScopedTempDir work_dir_; - scoped_ptr<storage::QuotaReservationManager> reservation_manager_; + std::unique_ptr<storage::QuotaReservationManager> reservation_manager_; DISALLOW_COPY_AND_ASSIGN(QuotaReservationTest); };
diff --git a/content/browser/renderer_host/pepper/ssl_context_helper.h b/content/browser/renderer_host/pepper/ssl_context_helper.h index f979529..c83afa4 100644 --- a/content/browser/renderer_host/pepper/ssl_context_helper.h +++ b/content/browser/renderer_host/pepper/ssl_context_helper.h
@@ -5,9 +5,10 @@ #ifndef CONTENT_BROWSER_RENDERER_HOST_PEPPER_SSL_CONTEXT_HELPER_H_ #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_SSL_CONTEXT_HELPER_H_ +#include <memory> + #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "net/ssl/ssl_config_service.h" namespace net { @@ -31,10 +32,10 @@ ~SSLContextHelper(); // This is lazily created. Users should use GetCertVerifier to retrieve it. - scoped_ptr<net::CertVerifier> cert_verifier_; + std::unique_ptr<net::CertVerifier> cert_verifier_; // This is lazily created. Users should use GetTransportSecurityState to // retrieve it. - scoped_ptr<net::TransportSecurityState> transport_security_state_; + std::unique_ptr<net::TransportSecurityState> transport_security_state_; // The default SSL configuration settings are used, as opposed to Chrome's SSL // settings.
diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc index 8d5ae8e9..7165bbd 100644 --- a/content/browser/renderer_host/render_message_filter.cc +++ b/content/browser/renderer_host/render_message_filter.cc
@@ -106,7 +106,7 @@ LAZY_INSTANCE_INITIALIZER; #endif -void DownloadUrlOnUIThread(scoped_ptr<DownloadUrlParameters> parameters) { +void DownloadUrlOnUIThread(std::unique_ptr<DownloadUrlParameters> parameters) { DCHECK_CURRENTLY_ON(BrowserThread::UI); RenderProcessHost* render_process_host = @@ -399,7 +399,7 @@ if (!resource_context_) return; - scoped_ptr<DownloadUrlParameters> parameters( + std::unique_ptr<DownloadUrlParameters> parameters( new DownloadUrlParameters(url, render_process_id_, render_view_id, render_frame_id, resource_context_)); parameters->set_content_initiated(true); @@ -604,7 +604,7 @@ void RenderMessageFilter::PostKeygenToWorkerThread( IPC::Message* reply_msg, - scoped_ptr<net::KeygenHandler> keygen_handler) { + std::unique_ptr<net::KeygenHandler> keygen_handler) { VLOG(1) << "Dispatching keygen task to worker pool."; // Dispatch to worker pool, so we do not block the IO thread. if (!base::WorkerPool::PostTask( @@ -621,7 +621,7 @@ } void RenderMessageFilter::OnKeygenOnWorkerThread( - scoped_ptr<net::KeygenHandler> keygen_handler, + std::unique_ptr<net::KeygenHandler> keygen_handler, IPC::Message* reply_msg) { DCHECK(reply_msg); @@ -677,7 +677,7 @@ CauseForGpuLaunch cause_for_gpu_launch, IPC::Message* reply_ptr) { DCHECK_CURRENTLY_ON(BrowserThread::IO); - scoped_ptr<IPC::Message> reply(reply_ptr); + std::unique_ptr<IPC::Message> reply(reply_ptr); #if defined(OS_WIN) && defined(ARCH_CPU_X86_64) // TODO(jbauman): Remove this when we know why renderer processes are @@ -715,14 +715,14 @@ } void RenderMessageFilter::OnHasGpuProcess(IPC::Message* reply_ptr) { - scoped_ptr<IPC::Message> reply(reply_ptr); + std::unique_ptr<IPC::Message> reply(reply_ptr); GpuProcessHost::GetProcessHandles( base::Bind(&RenderMessageFilter::GetGpuProcessHandlesCallback, weak_ptr_factory_.GetWeakPtr(), base::Passed(&reply))); } void RenderMessageFilter::EstablishChannelCallback( - scoped_ptr<IPC::Message> reply, + std::unique_ptr<IPC::Message> reply, const IPC::ChannelHandle& channel, const gpu::GPUInfo& gpu_info) { DCHECK_CURRENTLY_ON(BrowserThread::IO); @@ -733,7 +733,7 @@ } void RenderMessageFilter::GetGpuProcessHandlesCallback( - scoped_ptr<IPC::Message> reply, + std::unique_ptr<IPC::Message> reply, const std::list<base::ProcessHandle>& handles) { bool has_gpu_process = handles.size() > 0; ChildProcessHostMsg_HasGpuProcess::WriteReplyParams(reply.get(),
diff --git a/content/browser/renderer_host/render_message_filter.h b/content/browser/renderer_host/render_message_filter.h index a42690e..92c4d4f 100644 --- a/content/browser/renderer_host/render_message_filter.h +++ b/content/browser/renderer_host/render_message_filter.h
@@ -167,11 +167,11 @@ void OnEstablishGpuChannel(CauseForGpuLaunch, IPC::Message* reply); void OnHasGpuProcess(IPC::Message* reply); // Helper callbacks for the message handlers. - void EstablishChannelCallback(scoped_ptr<IPC::Message> reply, + void EstablishChannelCallback(std::unique_ptr<IPC::Message> reply, const IPC::ChannelHandle& channel, const gpu::GPUInfo& gpu_info); void GetGpuProcessHandlesCallback( - scoped_ptr<IPC::Message> reply, + std::unique_ptr<IPC::Message> reply, const std::list<base::ProcessHandle>& handles); // Used to ask the browser to allocate a block of shared memory for the // renderer to send back data in, since shared memory can't be created @@ -210,10 +210,12 @@ const GURL& url, const GURL& top_origin, IPC::Message* reply_msg); - void PostKeygenToWorkerThread(IPC::Message* reply_msg, - scoped_ptr<net::KeygenHandler> keygen_handler); - void OnKeygenOnWorkerThread(scoped_ptr<net::KeygenHandler> keygen_handler, - IPC::Message* reply_msg); + void PostKeygenToWorkerThread( + IPC::Message* reply_msg, + std::unique_ptr<net::KeygenHandler> keygen_handler); + void OnKeygenOnWorkerThread( + std::unique_ptr<net::KeygenHandler> keygen_handler, + IPC::Message* reply_msg); void OnMediaLogEvents(const std::vector<media::MediaLogEvent>&); bool CheckBenchmarkingEnabled() const;
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index 37f598e5..004b308 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -807,7 +807,7 @@ return true; } -scoped_ptr<IPC::ChannelProxy> RenderProcessHostImpl::CreateChannelProxy( +std::unique_ptr<IPC::ChannelProxy> RenderProcessHostImpl::CreateChannelProxy( const std::string& channel_id) { scoped_refptr<base::SingleThreadTaskRunner> runner = BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); @@ -1123,7 +1123,7 @@ return mojo_application_host_->service_registry(); } -scoped_ptr<base::SharedPersistentMemoryAllocator> +std::unique_ptr<base::SharedPersistentMemoryAllocator> RenderProcessHostImpl::TakeMetricsAllocator() { return std::move(metrics_allocator_); } @@ -2388,7 +2388,7 @@ return; // TODO(bcwhite): Update this with the correct memory size. - scoped_ptr<base::SharedMemory> shm(new base::SharedMemory()); + std::unique_ptr<base::SharedMemory> shm(new base::SharedMemory()); shm->CreateAndMapAnonymous(2 << 20); // 2 MiB metrics_allocator_.reset(new base::SharedPersistentMemoryAllocator( std::move(shm), GetID(), "RendererMetrics", /*readonly=*/false)); @@ -2484,7 +2484,7 @@ size_t RenderProcessHost::GetActiveViewCount() { size_t num_active_views = 0; - scoped_ptr<RenderWidgetHostIterator> widgets( + std::unique_ptr<RenderWidgetHostIterator> widgets( RenderWidgetHost::GetRenderWidgetHosts()); while (RenderWidgetHost* widget = widgets->GetNextHost()) { // Count only RenderWidgetHosts in this process. @@ -2819,7 +2819,7 @@ void RenderProcessHostImpl::RecomputeAndUpdateWebKitPreferences() { // We are updating all widgets including swapped out ones. - scoped_ptr<RenderWidgetHostIterator> widgets( + std::unique_ptr<RenderWidgetHostIterator> widgets( RenderWidgetHostImpl::GetAllRenderWidgetHosts()); while (RenderWidgetHost* widget = widgets->GetNextHost()) { RenderViewHost* rvh = RenderViewHost::From(widget);
diff --git a/content/browser/renderer_host/render_process_host_impl.h b/content/browser/renderer_host/render_process_host_impl.h index 6d83d4b..d1585ac 100644 --- a/content/browser/renderer_host/render_process_host_impl.h +++ b/content/browser/renderer_host/render_process_host_impl.h
@@ -9,12 +9,12 @@ #include <stdint.h> #include <map> +#include <memory> #include <queue> #include <string> #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/observer_list.h" #include "base/process/process.h" #include "base/synchronization/waitable_event.h" @@ -159,7 +159,7 @@ void ResumeDeferredNavigation(const GlobalRequestID& request_id) override; void NotifyTimezoneChange(const std::string& timezone) override; ServiceRegistry* GetServiceRegistry() override; - scoped_ptr<base::SharedPersistentMemoryAllocator> TakeMetricsAllocator() + std::unique_ptr<base::SharedPersistentMemoryAllocator> TakeMetricsAllocator() override; const base::TimeTicks& GetInitTimeForNavigationMetrics() const override; bool SubscribeUniformEnabled() const override; @@ -278,7 +278,7 @@ protected: // A proxy for our IPC::Channel that lives on the IO thread. - scoped_ptr<IPC::ChannelProxy> channel_; + std::unique_ptr<IPC::ChannelProxy> channel_; // True if fast shutdown has been performed on this RPH. bool fast_shutdown_started_; @@ -300,7 +300,7 @@ friend class VisitRelayingRenderProcessHost; friend class ChildProcessLauncherBrowserTest_ChildSpawnFail_Test; - scoped_ptr<IPC::ChannelProxy> CreateChannelProxy( + std::unique_ptr<IPC::ChannelProxy> CreateChannelProxy( const std::string& channel_id); // Creates and adds the IO thread message filters. @@ -372,7 +372,7 @@ // pipe to the shell. std::string shell_pipe_token_; - scoped_ptr<MojoApplicationHost> mojo_application_host_; + std::unique_ptr<MojoApplicationHost> mojo_application_host_; // The registered IPC listener objects. When this list is empty, we should // delete ourselves. @@ -399,7 +399,7 @@ scoped_refptr<NotificationMessageFilter> notification_message_filter_; // Used in single-process mode. - scoped_ptr<base::Thread> in_process_renderer_; + std::unique_ptr<base::Thread> in_process_renderer_; // True after Init() has been called. We can't just check channel_ because we // also reset that in the case of process termination. @@ -410,7 +410,7 @@ base::TimeTicks init_time_; // Used to launch and terminate the process without blocking the UI thread. - scoped_ptr<ChildProcessLauncher> child_process_launcher_; + std::unique_ptr<ChildProcessLauncher> child_process_launcher_; // Messages we queue while waiting for the process handle. We queue them here // instead of in the channel so that we ensure they're sent after init related @@ -502,7 +502,7 @@ // Context shared for each mojom::PermissionService instance created for this // RPH. - scoped_ptr<PermissionServiceContext> permission_service_context_; + std::unique_ptr<PermissionServiceContext> permission_service_context_; // This is a set of all subscription targets valuebuffers in the GPU process // are currently subscribed too. Used to prevent sending unnecessary @@ -519,7 +519,7 @@ bool subscribe_uniform_enabled_; // The memory allocator, if any, in which the renderer will write its metrics. - scoped_ptr<base::SharedPersistentMemoryAllocator> metrics_allocator_; + std::unique_ptr<base::SharedPersistentMemoryAllocator> metrics_allocator_; bool channel_connected_; bool sent_render_process_ready_;
diff --git a/content/browser/renderer_host/render_sandbox_host_linux.h b/content/browser/renderer_host/render_sandbox_host_linux.h index b9fad88..bb3ad6d 100644 --- a/content/browser/renderer_host/render_sandbox_host_linux.h +++ b/content/browser/renderer_host/render_sandbox_host_linux.h
@@ -5,11 +5,11 @@ #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_SANDBOX_HOST_LINUX_H_ #define CONTENT_BROWSER_RENDERER_HOST_RENDER_SANDBOX_HOST_LINUX_H_ +#include <memory> #include <string> #include "base/logging.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/threading/simple_thread.h" #include "content/browser/renderer_host/sandbox_ipc_linux.h" #include "content/common/content_export.h" @@ -49,8 +49,8 @@ int renderer_socket_; int childs_lifeline_fd_; - scoped_ptr<SandboxIPCHandler> ipc_handler_; - scoped_ptr<base::DelegateSimpleThread> ipc_thread_; + std::unique_ptr<SandboxIPCHandler> ipc_handler_; + std::unique_ptr<base::DelegateSimpleThread> ipc_thread_; DISALLOW_COPY_AND_ASSIGN(RenderSandboxHostLinux); };
diff --git a/content/browser/renderer_host/render_view_host_factory.cc b/content/browser/renderer_host/render_view_host_factory.cc index bcd1c9a..73b816d 100644 --- a/content/browser/renderer_host/render_view_host_factory.cc +++ b/content/browser/renderer_host/render_view_host_factory.cc
@@ -4,8 +4,10 @@ #include "content/browser/renderer_host/render_view_host_factory.h" +#include <memory> + #include "base/logging.h" -#include "base/memory/scoped_ptr.h" +#include "base/memory/ptr_util.h" #include "content/browser/renderer_host/render_view_host_impl.h" #include "content/browser/renderer_host/render_widget_host_impl.h" @@ -48,7 +50,7 @@ } return new RenderViewHostImpl( instance, - make_scoped_ptr(new RenderWidgetHostImpl( + base::WrapUnique(new RenderWidgetHostImpl( widget_delegate, instance->GetProcess(), routing_id, hidden)), delegate, main_frame_routing_id, swapped_out, true /* has_initialized_audio_host */);
diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc index f4891f2d..aa4c30e6 100644 --- a/content/browser/renderer_host/render_view_host_impl.cc +++ b/content/browser/renderer_host/render_view_host_impl.cc
@@ -208,12 +208,13 @@ return rvh; } -RenderViewHostImpl::RenderViewHostImpl(SiteInstance* instance, - scoped_ptr<RenderWidgetHostImpl> widget, - RenderViewHostDelegate* delegate, - int32_t main_frame_routing_id, - bool swapped_out, - bool has_initialized_audio_host) +RenderViewHostImpl::RenderViewHostImpl( + SiteInstance* instance, + std::unique_ptr<RenderWidgetHostImpl> widget, + RenderViewHostDelegate* delegate, + int32_t main_frame_routing_id, + bool swapped_out, + bool has_initialized_audio_host) : render_widget_host_(std::move(widget)), frames_ref_count_(0), delegate_(delegate),
diff --git a/content/browser/renderer_host/render_view_host_impl.h b/content/browser/renderer_host/render_view_host_impl.h index 4ec87ca..2e73c243 100644 --- a/content/browser/renderer_host/render_view_host_impl.h +++ b/content/browser/renderer_host/render_view_host_impl.h
@@ -9,6 +9,7 @@ #include <stdint.h> #include <map> +#include <memory> #include <string> #include <vector> @@ -17,7 +18,6 @@ #include "base/gtest_prod_util.h" #include "base/logging.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/process/kill.h" #include "build/build_config.h" #include "content/browser/renderer_host/render_widget_host_impl.h" @@ -79,7 +79,7 @@ static RenderViewHostImpl* From(RenderWidgetHost* rwh); RenderViewHostImpl(SiteInstance* instance, - scoped_ptr<RenderWidgetHostImpl> widget, + std::unique_ptr<RenderWidgetHostImpl> widget, RenderViewHostDelegate* delegate, int32_t main_frame_routing_id, bool swapped_out, @@ -346,7 +346,7 @@ void GrantFileAccessFromPageState(const PageState& validated_state); // The RenderWidgetHost. - scoped_ptr<RenderWidgetHostImpl> render_widget_host_; + std::unique_ptr<RenderWidgetHostImpl> render_widget_host_; // The number of RenderFrameHosts which have a reference to this RVH. int frames_ref_count_; @@ -406,7 +406,7 @@ // This is updated every time UpdateWebkitPreferences is called. That method // is in turn called when any of the settings change that the WebPreferences // values depend on. - scoped_ptr<WebPreferences> web_preferences_; + std::unique_ptr<WebPreferences> web_preferences_; bool updating_web_preferences_;
diff --git a/content/browser/renderer_host/render_view_host_unittest.cc b/content/browser/renderer_host/render_view_host_unittest.cc index fc7d722b..67a507c 100644 --- a/content/browser/renderer_host/render_view_host_unittest.cc +++ b/content/browser/renderer_host/render_view_host_unittest.cc
@@ -84,7 +84,7 @@ // Ensure we do not grant bindings to a process shared with unprivileged views. TEST_F(RenderViewHostTest, DontGrantBindingsToSharedProcess) { // Create another view in the same process. - scoped_ptr<TestWebContents> new_web_contents( + std::unique_ptr<TestWebContents> new_web_contents( TestWebContents::Create(browser_context(), rvh()->GetSiteInstance())); rvh()->AllowBindings(BINDINGS_POLICY_WEB_UI);
diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc index a8ac8a6..b95afaf 100644 --- a/content/browser/renderer_host/render_widget_host_impl.cc +++ b/content/browser/renderer_host/render_widget_host_impl.cc
@@ -5,6 +5,7 @@ #include "content/browser/renderer_host/render_widget_host_impl.h" #include <math.h> + #include <set> #include <utility> @@ -16,6 +17,7 @@ #include "base/lazy_instance.h" #include "base/location.h" #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/metrics/field_trial.h" #include "base/metrics/histogram.h" #include "base/single_thread_task_runner.h" @@ -268,8 +270,9 @@ } // static -scoped_ptr<RenderWidgetHostIterator> RenderWidgetHost::GetRenderWidgetHosts() { - scoped_ptr<RenderWidgetHostIteratorImpl> hosts( +std::unique_ptr<RenderWidgetHostIterator> +RenderWidgetHost::GetRenderWidgetHosts() { + std::unique_ptr<RenderWidgetHostIteratorImpl> hosts( new RenderWidgetHostIteratorImpl()); for (auto& it : g_routing_id_widget_map.Get()) { RenderWidgetHost* widget = it.second; @@ -289,9 +292,9 @@ } // static -scoped_ptr<RenderWidgetHostIterator> +std::unique_ptr<RenderWidgetHostIterator> RenderWidgetHostImpl::GetAllRenderWidgetHosts() { - scoped_ptr<RenderWidgetHostIteratorImpl> hosts( + std::unique_ptr<RenderWidgetHostIteratorImpl> hosts( new RenderWidgetHostIteratorImpl()); for (auto& it : g_routing_id_widget_map.Get()) hosts->Add(it.second); @@ -478,7 +481,7 @@ bool RenderWidgetHostImpl::Send(IPC::Message* msg) { if (IPC_MESSAGE_ID_CLASS(msg->type()) == InputMsgStart) - return input_router_->SendInput(make_scoped_ptr(msg)); + return input_router_->SendInput(base::WrapUnique(msg)); return process_->Send(msg); } @@ -616,7 +619,7 @@ const ResizeParams& resize_params) { resize_ack_pending_ = resize_params.needs_resize_ack; - old_resize_params_ = make_scoped_ptr(new ResizeParams(resize_params)); + old_resize_params_ = base::WrapUnique(new ResizeParams(resize_params)); } void RenderWidgetHostImpl::WasResized() { @@ -629,7 +632,7 @@ return; } - scoped_ptr<ResizeParams> params(new ResizeParams); + std::unique_ptr<ResizeParams> params(new ResizeParams); if (color_profile_out_of_date_) DispatchColorProfile(); if (!GetResizeParams(params.get())) @@ -1165,7 +1168,7 @@ } void RenderWidgetHostImpl::QueueSyntheticGesture( - scoped_ptr<SyntheticGesture> synthetic_gesture, + std::unique_ptr<SyntheticGesture> synthetic_gesture, const base::Callback<void(SyntheticGesture::Result)>& on_complete) { if (!synthetic_gesture_controller_ && view_) { synthetic_gesture_controller_.reset( @@ -1562,7 +1565,7 @@ ViewHostMsg_SwapCompositorFrame::Param param; if (!ViewHostMsg_SwapCompositorFrame::Read(&message, ¶m)) return false; - scoped_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame); + std::unique_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame); uint32_t output_surface_id = base::get<0>(param); base::get<1>(param).AssignTo(frame.get()); std::vector<IPC::Message> messages_to_deliver_with_frame; @@ -1781,7 +1784,7 @@ DCHECK(!rect_pixels.IsEmpty()); DCHECK(!size.IsEmpty()); - scoped_ptr<cc::SharedBitmap> bitmap = + std::unique_ptr<cc::SharedBitmap> bitmap = HostSharedBitmapManager::current()->GetSharedBitmapFromId(size, id); if (!bitmap) { bad_message::ReceivedBadMessage(GetProcess(),
diff --git a/content/browser/renderer_host/render_widget_host_impl.h b/content/browser/renderer_host/render_widget_host_impl.h index 2d6a4d8..43047c2 100644 --- a/content/browser/renderer_host/render_widget_host_impl.h +++ b/content/browser/renderer_host/render_widget_host_impl.h
@@ -10,13 +10,13 @@ #include <list> #include <map> +#include <memory> #include <string> #include <utility> #include <vector> #include "base/callback.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/observer_list.h" #include "base/process/kill.h" @@ -110,7 +110,7 @@ // Returns all RenderWidgetHosts including swapped out ones for // internal use. The public interface // RenderWidgetHost::GetRenderWidgetHosts only returns active ones. - static scoped_ptr<RenderWidgetHostIterator> GetAllRenderWidgetHosts(); + static std::unique_ptr<RenderWidgetHostIterator> GetAllRenderWidgetHosts(); // Use RenderWidgetHostImpl::From(rwh) to downcast a RenderWidgetHost to a // RenderWidgetHostImpl. @@ -320,7 +320,7 @@ // Queues a synthetic gesture for testing purposes. Invokes the on_complete // callback when the gesture is finished running. void QueueSyntheticGesture( - scoped_ptr<SyntheticGesture> synthetic_gesture, + std::unique_ptr<SyntheticGesture> synthetic_gesture, const base::Callback<void(SyntheticGesture::Result)>& on_complete); void CancelUpdateTextDirection(); @@ -685,7 +685,7 @@ gfx::Size current_size_; // Resize information that was previously sent to the renderer. - scoped_ptr<ResizeParams> old_resize_params_; + std::unique_ptr<ResizeParams> old_resize_params_; // The next auto resize to send. gfx::Size new_auto_size_; @@ -771,16 +771,16 @@ bool is_in_touchpad_gesture_scroll_; bool is_in_touchscreen_gesture_scroll_; - scoped_ptr<SyntheticGestureController> synthetic_gesture_controller_; + std::unique_ptr<SyntheticGestureController> synthetic_gesture_controller_; - scoped_ptr<TouchEmulator> touch_emulator_; + std::unique_ptr<TouchEmulator> touch_emulator_; // Receives and handles all input events. - scoped_ptr<InputRouter> input_router_; + std::unique_ptr<InputRouter> input_router_; - scoped_ptr<TimeoutMonitor> hang_monitor_timeout_; + std::unique_ptr<TimeoutMonitor> hang_monitor_timeout_; - scoped_ptr<TimeoutMonitor> new_content_rendering_timeout_; + std::unique_ptr<TimeoutMonitor> new_content_rendering_timeout_; // This boolean is true if RenderWidgetHostImpl receives a compositor frame // from a newly loaded page before StartNewContentRenderingTimeout() is
diff --git a/content/browser/renderer_host/render_widget_host_unittest.cc b/content/browser/renderer_host/render_widget_host_unittest.cc index c460898..4792102 100644 --- a/content/browser/renderer_host/render_widget_host_unittest.cc +++ b/content/browser/renderer_host/render_widget_host_unittest.cc
@@ -5,11 +5,12 @@ #include <stddef.h> #include <stdint.h> +#include <memory> + #include "base/bind.h" #include "base/command_line.h" #include "base/location.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/single_thread_task_runner.h" #include "base/thread_task_runner_handle.h" #include "base/timer/timer.h" @@ -94,7 +95,7 @@ ~MockInputRouter() override {} // InputRouter - bool SendInput(scoped_ptr<IPC::Message> message) override { + bool SendInput(std::unique_ptr<IPC::Message> message) override { send_event_called_ = true; return true; } @@ -432,7 +433,7 @@ bool unresponsive_timer_fired_; - scoped_ptr<TextInputState> text_input_state_; + std::unique_ptr<TextInputState> text_input_state_; }; // RenderWidgetHostTest -------------------------------------------------------- @@ -467,7 +468,7 @@ process_ = new RenderWidgetHostProcess(browser_context_.get()); #if defined(USE_AURA) || defined(OS_MACOSX) ImageTransportFactory::InitializeForUnitTests( - scoped_ptr<ImageTransportFactory>( + std::unique_ptr<ImageTransportFactory>( new NoTransportImageTransportFactory)); #endif #if defined(USE_AURA) @@ -632,12 +633,12 @@ base::MessageLoopForUI message_loop_; - scoped_ptr<TestBrowserContext> browser_context_; + std::unique_ptr<TestBrowserContext> browser_context_; RenderWidgetHostProcess* process_; // Deleted automatically by the widget. - scoped_ptr<MockRenderWidgetHostDelegate> delegate_; - scoped_ptr<MockRenderWidgetHost> host_; - scoped_ptr<TestView> view_; - scoped_ptr<gfx::Screen> screen_; + std::unique_ptr<MockRenderWidgetHostDelegate> delegate_; + std::unique_ptr<MockRenderWidgetHost> host_; + std::unique_ptr<TestView> view_; + std::unique_ptr<gfx::Screen> screen_; bool handle_key_press_event_; bool handle_mouse_event_; double last_simulated_event_time_seconds_; @@ -848,7 +849,7 @@ #if !defined(OS_MACOSX) // Tests setting background transparency. TEST_F(RenderWidgetHostTest, Background) { - scoped_ptr<RenderWidgetHostViewBase> view; + std::unique_ptr<RenderWidgetHostViewBase> view; #if defined(USE_AURA) view.reset(new RenderWidgetHostViewAura(host_.get(), false)); // TODO(derat): Call this on all platforms: http://crbug.com/102450.
diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc index 46113c7..3f5354e9 100644 --- a/content/browser/renderer_host/render_widget_host_view_android.cc +++ b/content/browser/renderer_host/render_widget_host_view_android.cc
@@ -5,6 +5,7 @@ #include "content/browser/renderer_host/render_widget_host_view_android.h" #include <android/bitmap.h> + #include <utility> #include "base/android/build_info.h" @@ -13,6 +14,7 @@ #include "base/command_line.h" #include "base/logging.h" #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/message_loop/message_loop.h" #include "base/metrics/histogram.h" #include "base/strings/utf_string_conversions.h" @@ -133,7 +135,7 @@ void OnContextLost(); scoped_refptr<ContextProviderCommandBuffer> provider_; - scoped_ptr<GLHelper> gl_helper_; + std::unique_ptr<GLHelper> gl_helper_; DISALLOW_COPY_AND_ASSIGN(GLHelperHolder); }; @@ -183,7 +185,7 @@ bool automatic_flushes = true; GURL url("chrome://gpu/RenderWidgetHostViewAndroid"); - scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( + std::unique_ptr<WebGraphicsContext3DCommandBufferImpl> context( new WebGraphicsContext3DCommandBufferImpl( gpu::kNullSurfaceHandle, // offscreen url, gpu_channel_host.get(), attributes, gfx::PreferIntegratedGpu, @@ -227,10 +229,10 @@ void CopyFromCompositingSurfaceFinished( const ReadbackRequestCallback& callback, - scoped_ptr<cc::SingleReleaseCallback> release_callback, - scoped_ptr<SkBitmap> bitmap, + std::unique_ptr<cc::SingleReleaseCallback> release_callback, + std::unique_ptr<SkBitmap> bitmap, const base::TimeTicks& start_time, - scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock, + std::unique_ptr<SkAutoLockPixels> bitmap_pixels_lock, bool result) { TRACE_EVENT0( "cc", "RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceFinished"); @@ -249,7 +251,7 @@ callback.Run(*bitmap, response); } -scoped_ptr<ui::TouchSelectionController> CreateSelectionController( +std::unique_ptr<ui::TouchSelectionController> CreateSelectionController( ui::TouchSelectionControllerClient* client, ContentViewCore* content_view_core) { DCHECK(client); @@ -265,12 +267,12 @@ config.enable_longpress_drag_selection = base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnableLongpressDragSelection); - return make_scoped_ptr(new ui::TouchSelectionController(client, config)); + return base::WrapUnique(new ui::TouchSelectionController(client, config)); } -scoped_ptr<OverscrollControllerAndroid> CreateOverscrollController( +std::unique_ptr<OverscrollControllerAndroid> CreateOverscrollController( ContentViewCoreImpl* content_view_core) { - return make_scoped_ptr(new OverscrollControllerAndroid(content_view_core)); + return base::WrapUnique(new OverscrollControllerAndroid(content_view_core)); } gfx::RectF GetSelectionRect(const ui::TouchSelectionController& controller) { @@ -287,13 +289,13 @@ RenderWidgetHostViewAndroid::LastFrameInfo::LastFrameInfo( uint32_t output_id, - scoped_ptr<cc::CompositorFrame> output_frame) + std::unique_ptr<cc::CompositorFrame> output_frame) : output_surface_id(output_id), frame(std::move(output_frame)) {} RenderWidgetHostViewAndroid::LastFrameInfo::~LastFrameInfo() {} void RenderWidgetHostViewAndroid::OnContextLost() { - scoped_ptr<RenderWidgetHostIterator> widgets( + std::unique_ptr<RenderWidgetHostIterator> widgets( RenderWidgetHostImpl::GetAllRenderWidgetHosts()); while (RenderWidgetHost* widget = widgets->GetNextHost()) { if (widget->GetView()) { @@ -753,7 +755,7 @@ return; } - scoped_ptr<ui::MotionEvent> cancel_event = current_down_event->Cancel(); + std::unique_ptr<ui::MotionEvent> cancel_event = current_down_event->Cancel(); if (gesture_provider_.OnTouchEvent(*cancel_event).succeeded) { bool causes_scrolling = false; host_->ForwardTouchEventWithLatencyInfo( @@ -901,11 +903,10 @@ content_view_core_->GetWindowAndroid()->GetCompositor(); DCHECK(compositor); DCHECK(!surface_id_.is_null()); - scoped_ptr<cc::CopyOutputRequest> request = + std::unique_ptr<cc::CopyOutputRequest> request = cc::CopyOutputRequest::CreateRequest( - base::Bind(&PrepareTextureCopyOutputResult, - dst_size_in_pixel, preferred_color_type, start_time, - callback)); + base::Bind(&PrepareTextureCopyOutputResult, dst_size_in_pixel, + preferred_color_type, start_time, callback)); if (!src_subrect_in_pixel.IsEmpty()) request->set_area(src_subrect_in_pixel); layer_->RequestCopyOfOutput(std::move(request)); @@ -931,10 +932,11 @@ content_view_core_->ShowDisambiguationPopup(rect_pixels, zoomed_bitmap); } -scoped_ptr<SyntheticGestureTarget> +std::unique_ptr<SyntheticGestureTarget> RenderWidgetHostViewAndroid::CreateSyntheticGestureTarget() { - return scoped_ptr<SyntheticGestureTarget>(new SyntheticGestureTargetAndroid( - host_, content_view_core_->CreateMotionEventSynthesizer())); + return std::unique_ptr<SyntheticGestureTarget>( + new SyntheticGestureTargetAndroid( + host_, content_view_core_->CreateMotionEventSynthesizer())); } void RenderWidgetHostViewAndroid::SendDelegatedFrameAck( @@ -996,10 +998,10 @@ } void RenderWidgetHostViewAndroid::SubmitCompositorFrame( - scoped_ptr<cc::CompositorFrame> frame) { + std::unique_ptr<cc::CompositorFrame> frame) { cc::SurfaceManager* manager = CompositorImpl::GetSurfaceManager(); if (!surface_factory_) { - surface_factory_ = make_scoped_ptr(new cc::SurfaceFactory(manager, this)); + surface_factory_ = base::WrapUnique(new cc::SurfaceFactory(manager, this)); } if (surface_id_.is_null() || texture_size_in_layer_ != current_surface_size_ || @@ -1031,7 +1033,7 @@ void RenderWidgetHostViewAndroid::SwapDelegatedFrame( uint32_t output_surface_id, - scoped_ptr<cc::CompositorFrame> frame) { + std::unique_ptr<cc::CompositorFrame> frame) { CheckOutputSurfaceChanged(output_surface_id); bool has_content = !texture_size_in_layer_.IsEmpty(); @@ -1068,7 +1070,7 @@ void RenderWidgetHostViewAndroid::InternalSwapCompositorFrame( uint32_t output_surface_id, - scoped_ptr<cc::CompositorFrame> frame) { + std::unique_ptr<cc::CompositorFrame> frame) { last_scroll_offset_ = frame->metadata.root_scroll_offset; if (!frame->delegated_frame_data) { LOG(ERROR) << "Non-delegated renderer path no longer supported"; @@ -1084,7 +1086,7 @@ if (!CompositorImpl::GetSurfaceManager() && layer_.get() && layer_->layer_tree_host()) { for (size_t i = 0; i < frame->metadata.latency_info.size(); i++) { - scoped_ptr<cc::SwapPromise> swap_promise( + std::unique_ptr<cc::SwapPromise> swap_promise( new cc::LatencyInfoSwapPromise(frame->metadata.latency_info[i])); layer_->layer_tree_host()->QueueSwapPromise(std::move(swap_promise)); } @@ -1108,7 +1110,7 @@ void RenderWidgetHostViewAndroid::OnSwapCompositorFrame( uint32_t output_surface_id, - scoped_ptr<cc::CompositorFrame> frame) { + std::unique_ptr<cc::CompositorFrame> frame) { InternalSwapCompositorFrame(output_surface_id, std::move(frame)); } @@ -1118,7 +1120,7 @@ void RenderWidgetHostViewAndroid::RetainFrame( uint32_t output_surface_id, - scoped_ptr<cc::CompositorFrame> frame) { + std::unique_ptr<cc::CompositorFrame> frame) { DCHECK(locks_on_frame_count_); // Store the incoming frame so that it can be swapped when all the locks have @@ -1217,15 +1219,15 @@ GetSelectionRect(*selection_controller_)); } -scoped_ptr<ui::TouchHandleDrawable> +std::unique_ptr<ui::TouchHandleDrawable> RenderWidgetHostViewAndroid::CreateDrawable() { DCHECK(content_view_core_); if (!using_browser_compositor_) return PopupTouchHandleDrawable::Create(content_view_core_); - return scoped_ptr<ui::TouchHandleDrawable>(new CompositedTouchHandleDrawable( - content_view_core_->GetLayer().get(), - content_view_core_->GetDpiScale(), + return std::unique_ptr< + ui::TouchHandleDrawable>(new CompositedTouchHandleDrawable( + content_view_core_->GetLayer().get(), content_view_core_->GetDpiScale(), // Use the activity context (instead of the application context) to ensure // proper handle theming. content_view_core_->GetContext().obj())); @@ -1927,7 +1929,7 @@ SkColorType color_type, const base::TimeTicks& start_time, const ReadbackRequestCallback& callback, - scoped_ptr<cc::CopyOutputResult> result) { + std::unique_ptr<cc::CopyOutputResult> result) { base::ScopedClosureRunner scoped_callback_runner( base::Bind(callback, SkBitmap(), READBACK_FAILED)); TRACE_EVENT0("cc", @@ -1947,7 +1949,7 @@ return; if (!gl_helper->IsReadbackConfigSupported(color_type)) color_type = kRGBA_8888_SkColorType; - scoped_ptr<SkBitmap> bitmap(new SkBitmap); + std::unique_ptr<SkBitmap> bitmap(new SkBitmap); if (!bitmap->tryAllocPixels(SkImageInfo::Make(output_size_in_pixel.width(), output_size_in_pixel.height(), color_type, @@ -1957,13 +1959,12 @@ return; } - - scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock( + std::unique_ptr<SkAutoLockPixels> bitmap_pixels_lock( new SkAutoLockPixels(*bitmap)); uint8_t* pixels = static_cast<uint8_t*>(bitmap->getPixels()); cc::TextureMailbox texture_mailbox; - scoped_ptr<cc::SingleReleaseCallback> release_callback; + std::unique_ptr<cc::SingleReleaseCallback> release_callback; result->TakeTexture(&texture_mailbox, &release_callback); DCHECK(texture_mailbox.IsTexture()); if (!texture_mailbox.IsTexture())
diff --git a/content/browser/renderer_host/render_widget_host_view_android.h b/content/browser/renderer_host/render_widget_host_view_android.h index 1f3281e..3678520 100644 --- a/content/browser/renderer_host/render_widget_host_view_android.h +++ b/content/browser/renderer_host/render_widget_host_view_android.h
@@ -9,13 +9,13 @@ #include <stdint.h> #include <map> +#include <memory> #include <queue> #include "base/callback.h" #include "base/compiler_specific.h" #include "base/i18n/rtl.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/process/process.h" #include "cc/output/begin_frame_args.h" @@ -150,15 +150,17 @@ BrowserAccessibilityDelegate* delegate, bool for_root_frame) override; bool LockMouse() override; void UnlockMouse() override; - void OnSwapCompositorFrame(uint32_t output_surface_id, - scoped_ptr<cc::CompositorFrame> frame) override; + void OnSwapCompositorFrame( + uint32_t output_surface_id, + std::unique_ptr<cc::CompositorFrame> frame) override; void ClearCompositorFrame() override; void DidOverscroll(const DidOverscrollParams& params) override; void DidStopFlinging() override; uint32_t GetSurfaceIdNamespace() override; void ShowDisambiguationPopup(const gfx::Rect& rect_pixels, const SkBitmap& zoomed_bitmap) override; - scoped_ptr<SyntheticGestureTarget> CreateSyntheticGestureTarget() override; + std::unique_ptr<SyntheticGestureTarget> CreateSyntheticGestureTarget() + override; void LockCompositingSurface() override; void UnlockCompositingSurface() override; void OnTextSurroundingSelectionResponse(const base::string16& content, @@ -206,7 +208,7 @@ void SelectBetweenCoordinates(const gfx::PointF& base, const gfx::PointF& extent) override; void OnSelectionEvent(ui::SelectionEventType event) override; - scoped_ptr<ui::TouchHandleDrawable> CreateDrawable() override; + std::unique_ptr<ui::TouchHandleDrawable> CreateDrawable() override; // Non-virtual methods void SetContentViewCore(ContentViewCoreImpl* content_view_core); @@ -266,9 +268,9 @@ void DestroyDelegatedContent(); void CheckOutputSurfaceChanged(uint32_t output_surface_id); - void SubmitCompositorFrame(scoped_ptr<cc::CompositorFrame> frame_data); + void SubmitCompositorFrame(std::unique_ptr<cc::CompositorFrame> frame_data); void SwapDelegatedFrame(uint32_t output_surface_id, - scoped_ptr<cc::CompositorFrame> frame_data); + std::unique_ptr<cc::CompositorFrame> frame_data); void SendDelegatedFrameAck(uint32_t output_surface_id); void SendReturnedDelegatedResources(uint32_t output_surface_id); @@ -289,7 +291,7 @@ SkColorType color_type, const base::TimeTicks& start_time, const ReadbackRequestCallback& callback, - scoped_ptr<cc::CopyOutputResult> result); + std::unique_ptr<cc::CopyOutputResult> result); // DevTools ScreenCast support for Android WebView. void SynchronousCopyContents(const gfx::Rect& src_subrect_in_pixel, @@ -305,10 +307,10 @@ // Drop any incoming frames from the renderer when there are locks on the // current frame. void RetainFrame(uint32_t output_surface_id, - scoped_ptr<cc::CompositorFrame> frame); + std::unique_ptr<cc::CompositorFrame> frame); void InternalSwapCompositorFrame(uint32_t output_surface_id, - scoped_ptr<cc::CompositorFrame> frame); + std::unique_ptr<cc::CompositorFrame> frame); void OnLostResources(); enum VSyncRequestType { @@ -349,8 +351,8 @@ scoped_refptr<cc::Layer> layer_; - scoped_ptr<cc::SurfaceIdAllocator> id_allocator_; - scoped_ptr<cc::SurfaceFactory> surface_factory_; + std::unique_ptr<cc::SurfaceIdAllocator> id_allocator_; + std::unique_ptr<cc::SurfaceFactory> surface_factory_; cc::SurfaceId surface_id_; gfx::Size current_surface_size_; cc::ReturnedResourceArray surface_returned_resources_; @@ -367,7 +369,7 @@ std::queue<base::Closure> ack_callbacks_; // Used to control and render overscroll-related effects. - scoped_ptr<OverscrollControllerAndroid> overscroll_controller_; + std::unique_ptr<OverscrollControllerAndroid> overscroll_controller_; // Provides gesture synthesis given a stream of touch events (derived from // Android MotionEvent's) and touch event acks. @@ -378,28 +380,28 @@ // Manages selection handle rendering and manipulation. // This will always be NULL if |content_view_core_| is NULL. - scoped_ptr<ui::TouchSelectionController> selection_controller_; + std::unique_ptr<ui::TouchSelectionController> selection_controller_; // Size to use if we have no backing ContentViewCore gfx::Size default_size_; const bool using_browser_compositor_; - scoped_ptr<SynchronousCompositorBase> sync_compositor_; + std::unique_ptr<SynchronousCompositorBase> sync_compositor_; - scoped_ptr<DelegatedFrameEvictor> frame_evictor_; + std::unique_ptr<DelegatedFrameEvictor> frame_evictor_; size_t locks_on_frame_count_; bool observing_root_window_; struct LastFrameInfo { LastFrameInfo(uint32_t output_id, - scoped_ptr<cc::CompositorFrame> output_frame); + std::unique_ptr<cc::CompositorFrame> output_frame); ~LastFrameInfo(); uint32_t output_surface_id; - scoped_ptr<cc::CompositorFrame> frame; + std::unique_ptr<cc::CompositorFrame> frame; }; - scoped_ptr<LastFrameInfo> last_frame_info_; + std::unique_ptr<LastFrameInfo> last_frame_info_; TextSurroundingSelectionCallback text_surrounding_selection_callback_;
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index 29e1eef0..c542b02 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
@@ -1003,7 +1003,7 @@ } void RenderWidgetHostViewAura::BeginFrameSubscription( - scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) { + std::unique_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) { delegated_frame_host_->BeginFrameSubscription(std::move(subscriber)); } @@ -1030,7 +1030,7 @@ void RenderWidgetHostViewAura::OnSwapCompositorFrame( uint32_t output_surface_id, - scoped_ptr<cc::CompositorFrame> frame) { + std::unique_ptr<cc::CompositorFrame> frame) { TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame"); last_scroll_offset_ = frame->metadata.root_scroll_offset; @@ -1181,9 +1181,9 @@ } } -scoped_ptr<SyntheticGestureTarget> +std::unique_ptr<SyntheticGestureTarget> RenderWidgetHostViewAura::CreateSyntheticGestureTarget() { - return scoped_ptr<SyntheticGestureTarget>( + return std::unique_ptr<SyntheticGestureTarget>( new SyntheticGestureTargetAura(host_)); } @@ -2566,7 +2566,7 @@ } void RenderWidgetHostViewAura::SetSelectionControllerClientForTest( - scoped_ptr<TouchSelectionControllerClientAura> client) { + std::unique_ptr<TouchSelectionControllerClientAura> client) { selection_controller_client_.swap(client); CreateSelectionController(); disable_input_event_router_for_testing_ = true; @@ -2774,7 +2774,7 @@ if (!last_context_menu_params_) break; - scoped_ptr<ContextMenuParams> context_menu_params = + std::unique_ptr<ContextMenuParams> context_menu_params = std::move(last_context_menu_params_); // On Windows we want to display the context menu when the long press @@ -2821,7 +2821,7 @@ // Take a copy of |event|, to avoid ConvertLocationToTarget mutating the // event. - scoped_ptr<ui::Event> event_copy = ui::Event::Clone(*event); + std::unique_ptr<ui::Event> event_copy = ui::Event::Clone(*event); ui::MouseEvent* mouse_event = static_cast<ui::MouseEvent*>(event_copy.get()); mouse_event->ConvertLocationToTarget(window_, window_->parent()); window_->parent()->delegate()->OnMouseEvent(mouse_event); @@ -2874,14 +2874,12 @@ #endif } -scoped_ptr<ResizeLock> +std::unique_ptr<ResizeLock> RenderWidgetHostViewAura::DelegatedFrameHostCreateResizeLock( bool defer_compositor_lock) { gfx::Size desired_size = window_->bounds().size(); - return scoped_ptr<ResizeLock>(new CompositorResizeLock( - window_->GetHost(), - desired_size, - defer_compositor_lock, + return std::unique_ptr<ResizeLock>(new CompositorResizeLock( + window_->GetHost(), desired_size, defer_compositor_lock, base::TimeDelta::FromMilliseconds(kResizeLockTimeoutMs))); }
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.h b/content/browser/renderer_host/render_widget_host_view_aura.h index 2518c5224..6738131b 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.h +++ b/content/browser/renderer_host/render_widget_host_view_aura.h
@@ -9,6 +9,7 @@ #include <stdint.h> #include <map> +#include <memory> #include <set> #include <string> #include <vector> @@ -18,7 +19,6 @@ #include "base/macros.h" #include "base/memory/linked_ptr.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "build/build_config.h" #include "content/browser/accessibility/browser_accessibility_manager.h" @@ -160,7 +160,7 @@ const base::Callback<void(const gfx::Rect&, bool)>& callback) override; bool CanCopyToVideoFrame() const override; void BeginFrameSubscription( - scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) override; + std::unique_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) override; void EndFrameSubscription() override; bool HasAcceleratedSurface(const gfx::Size& desired_size) override; void GetScreenInfo(blink::WebScreenInfo* results) override; @@ -172,7 +172,8 @@ InputEventAckState ack_result) override; void ProcessAckedTouchEvent(const TouchEventWithLatencyInfo& touch, InputEventAckState ack_result) override; - scoped_ptr<SyntheticGestureTarget> CreateSyntheticGestureTarget() override; + std::unique_ptr<SyntheticGestureTarget> CreateSyntheticGestureTarget() + override; InputEventAckState FilterInputEvent( const blink::WebInputEvent& input_event) override; BrowserAccessibilityManager* CreateBrowserAccessibilityManager( @@ -183,8 +184,9 @@ const SkBitmap& zoomed_bitmap) override; bool LockMouse() override; void UnlockMouse() override; - void OnSwapCompositorFrame(uint32_t output_surface_id, - scoped_ptr<cc::CompositorFrame> frame) override; + void OnSwapCompositorFrame( + uint32_t output_surface_id, + std::unique_ptr<cc::CompositorFrame> frame) override; void ClearCompositorFrame() override; void DidStopFlinging() override; void OnDidNavigateMainFrameToNewPage() override; @@ -329,7 +331,7 @@ // Used in tests to set a mock client for touch selection controller. It will // create a new touch selection controller for the new client. void SetSelectionControllerClientForTest( - scoped_ptr<TouchSelectionControllerClientAura> client); + std::unique_ptr<TouchSelectionControllerClientAura> client); // Exposed for tests. cc::SurfaceId SurfaceIdForTesting() const override; @@ -442,7 +444,7 @@ bool DelegatedFrameHostIsVisible() const override; gfx::Size DelegatedFrameHostDesiredSizeInDIP() const override; bool DelegatedFrameCanCreateResizeLock() const override; - scoped_ptr<ResizeLock> DelegatedFrameHostCreateResizeLock( + std::unique_ptr<ResizeLock> DelegatedFrameHostCreateResizeLock( bool defer_compositor_lock) override; void DelegatedFrameHostResizeLockWasReleased() override; void DelegatedFrameHostSendCompositorSwapAck( @@ -525,12 +527,12 @@ aura::Window* window_; - scoped_ptr<DelegatedFrameHost> delegated_frame_host_; + std::unique_ptr<DelegatedFrameHost> delegated_frame_host_; - scoped_ptr<WindowObserver> window_observer_; + std::unique_ptr<WindowObserver> window_observer_; // Tracks the ancestors of the RWHVA window for window location changes. - scoped_ptr<WindowAncestorObserver> ancestor_window_observer_; + std::unique_ptr<WindowAncestorObserver> ancestor_window_observer_; // Are we in the process of closing? Tracked so fullscreen views can avoid // sending a second shutdown request to the host when they lose the focus @@ -551,7 +553,7 @@ class EventFilterForPopupExit; friend class EventFilterForPopupExit; - scoped_ptr<ui::EventHandler> event_filter_for_popup_exit_; + std::unique_ptr<ui::EventHandler> event_filter_for_popup_exit_; // True when content is being loaded. Used to show an hourglass cursor. bool is_loading_; @@ -603,7 +605,7 @@ // Used to track the state of the window we're created from. Only used when // created fullscreen. - scoped_ptr<aura::WindowTracker> host_tracker_; + std::unique_ptr<aura::WindowTracker> host_tracker_; // Used to track the last cursor visibility update that was sent to the // renderer via NotifyRendererOfCursorVisibilityState(). @@ -633,15 +635,16 @@ // Contains a copy of the last context menu request parameters. Only set when // we receive a request to show the context menu on a long press. - scoped_ptr<ContextMenuParams> last_context_menu_params_; + std::unique_ptr<ContextMenuParams> last_context_menu_params_; #endif bool has_snapped_to_boundary_; - scoped_ptr<TouchSelectionControllerClientAura> selection_controller_client_; - scoped_ptr<ui::TouchSelectionController> selection_controller_; + std::unique_ptr<TouchSelectionControllerClientAura> + selection_controller_client_; + std::unique_ptr<ui::TouchSelectionController> selection_controller_; - scoped_ptr<OverscrollController> overscroll_controller_; + std::unique_ptr<OverscrollController> overscroll_controller_; // The last scroll offset of the view. gfx::Vector2dF last_scroll_offset_; @@ -650,7 +653,7 @@ std::vector<ui::LatencyInfo> software_latency_info_; - scoped_ptr<aura::client::ScopedTooltipDisabler> tooltip_disabler_; + std::unique_ptr<aura::client::ScopedTooltipDisabler> tooltip_disabler_; // True when this view acts as a platform view hack for a // RenderWidgetHostViewGuest.
diff --git a/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc b/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc index e743f1a..627bce81 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc
@@ -6,10 +6,12 @@ #include <stddef.h> #include <stdint.h> + #include <utility> #include "base/command_line.h" #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/memory/shared_memory.h" #include "base/message_loop/message_loop.h" #include "base/run_loop.h" @@ -181,9 +183,9 @@ } private: - scoped_ptr<NativeWebKeyboardEvent> last_event_; + std::unique_ptr<NativeWebKeyboardEvent> last_event_; RenderWidgetHostImpl* rwh_; - scoped_ptr<TextInputState> text_input_state_; + std::unique_ptr<TextInputState> text_input_state_; DISALLOW_COPY_AND_ASSIGN(MockRenderWidgetHostDelegate); }; @@ -290,16 +292,16 @@ void UseFakeDispatcher() { dispatcher_ = new FakeWindowEventDispatcher(window()->GetHost()); - scoped_ptr<aura::WindowEventDispatcher> dispatcher(dispatcher_); + std::unique_ptr<aura::WindowEventDispatcher> dispatcher(dispatcher_); aura::test::SetHostDispatcher(window()->GetHost(), std::move(dispatcher)); } ~FakeRenderWidgetHostViewAura() override {} - scoped_ptr<ResizeLock> DelegatedFrameHostCreateResizeLock( + std::unique_ptr<ResizeLock> DelegatedFrameHostCreateResizeLock( bool defer_compositor_lock) override { gfx::Size desired_size = window()->bounds().size(); - return scoped_ptr<ResizeLock>( + return std::unique_ptr<ResizeLock>( new FakeResizeLock(desired_size, defer_compositor_lock)); } @@ -312,7 +314,7 @@ window()->GetHost()->compositor()); } - void InterceptCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request) { + void InterceptCopyOfOutput(std::unique_ptr<cc::CopyOutputRequest> request) { last_copy_request_ = std::move(request); if (last_copy_request_->has_texture_mailbox()) { // Give the resulting texture a size. @@ -351,7 +353,7 @@ bool can_create_resize_lock_; gfx::Size last_frame_size_; - scoped_ptr<cc::CopyOutputRequest> last_copy_request_; + std::unique_ptr<cc::CopyOutputRequest> last_copy_request_; FakeWindowEventDispatcher* dispatcher_; }; @@ -410,7 +412,7 @@ void SetUpEnvironment() { ImageTransportFactory::InitializeForUnitTests( - scoped_ptr<ImageTransportFactory>( + std::unique_ptr<ImageTransportFactory>( new NoTransportImageTransportFactory)); aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); aura_test_helper_->SetUp( @@ -424,7 +426,7 @@ sink_ = &process_host_->sink(); int32_t routing_id = process_host_->GetNextRoutingID(); - delegates_.push_back(make_scoped_ptr(new MockRenderWidgetHostDelegate)); + delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); parent_host_ = new RenderWidgetHostImpl(delegates_.back().get(), process_host_, routing_id, false); delegates_.back()->set_widget_host(parent_host_); @@ -436,7 +438,7 @@ gfx::Rect()); routing_id = process_host_->GetNextRoutingID(); - delegates_.push_back(make_scoped_ptr(new MockRenderWidgetHostDelegate)); + delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); widget_host_ = new RenderWidgetHostImpl(delegates_.back().get(), process_host_, routing_id, false); delegates_.back()->set_widget_host(widget_host_); @@ -549,9 +551,9 @@ base::MessageLoopForUI message_loop_; BrowserThreadImpl browser_thread_for_ui_; - scoped_ptr<aura::test::AuraTestHelper> aura_test_helper_; - scoped_ptr<BrowserContext> browser_context_; - std::vector<scoped_ptr<MockRenderWidgetHostDelegate>> delegates_; + std::unique_ptr<aura::test::AuraTestHelper> aura_test_helper_; + std::unique_ptr<BrowserContext> browser_context_; + std::vector<std::unique_ptr<MockRenderWidgetHostDelegate>> delegates_; MockRenderProcessHost* process_host_; // Tests should set these to NULL if they've already triggered their @@ -803,7 +805,7 @@ SyntheticWebTouchEvent touch_event_; - scoped_ptr<TestOverscrollDelegate> overscroll_delegate_; + std::unique_ptr<TestOverscrollDelegate> overscroll_delegate_; private: DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAuraOverscrollTest); @@ -890,10 +892,10 @@ aura::Window* root = parent_view_->GetNativeView()->GetRootWindow(); aura::test::TestWindowDelegate delegate1, delegate2; - scoped_ptr<aura::Window> parent1(new aura::Window(&delegate1)); + std::unique_ptr<aura::Window> parent1(new aura::Window(&delegate1)); parent1->Init(ui::LAYER_TEXTURED); parent1->Show(); - scoped_ptr<aura::Window> parent2(new aura::Window(&delegate2)); + std::unique_ptr<aura::Window> parent2(new aura::Window(&delegate2)); parent2->Init(ui::LAYER_TEXTURED); parent2->Show(); @@ -955,7 +957,7 @@ // destroyed. TestWindowObserver observer(window); aura::test::TestWindowDelegate delegate; - scoped_ptr<aura::Window> sibling(new aura::Window(&delegate)); + std::unique_ptr<aura::Window> sibling(new aura::Window(&delegate)); sibling->Init(ui::LAYER_TEXTURED); sibling->Show(); window->parent()->AddChild(sibling.get()); @@ -1060,7 +1062,7 @@ TestWindowObserver observer(popup_window); aura::test::TestWindowDelegate delegate; - scoped_ptr<aura::Window> dialog_window(new aura::Window(&delegate)); + std::unique_ptr<aura::Window> dialog_window(new aura::Window(&delegate)); dialog_window->Init(ui::LAYER_TEXTURED); aura::client::ParentWindowWithContext( dialog_window.get(), popup_window, gfx::Rect()); @@ -1564,14 +1566,14 @@ EXPECT_EQ(0, cursor_client.calls_to_set_cursor()); } -scoped_ptr<cc::CompositorFrame> MakeDelegatedFrame(float scale_factor, - gfx::Size size, - gfx::Rect damage) { - scoped_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame); +std::unique_ptr<cc::CompositorFrame> MakeDelegatedFrame(float scale_factor, + gfx::Size size, + gfx::Rect damage) { + std::unique_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame); frame->metadata.device_scale_factor = scale_factor; frame->delegated_frame_data.reset(new cc::DelegatedFrameData); - scoped_ptr<cc::RenderPass> pass = cc::RenderPass::Create(); + std::unique_ptr<cc::RenderPass> pass = cc::RenderPass::Create(); pass->SetNew( cc::RenderPassId(1, 1), gfx::Rect(size), damage, gfx::Transform()); frame->delegated_frame_data->render_pass_list.push_back(std::move(pass)); @@ -1683,7 +1685,7 @@ view_->OnSwapCompositorFrame(0, MakeDelegatedFrame(1.f, view_size, view_rect)); - scoped_ptr<ui::LayerTreeOwner> cloned_owner( + std::unique_ptr<ui::LayerTreeOwner> cloned_owner( wm::RecreateLayers(view_->GetNativeView())); cc::SurfaceId id = view_->GetDelegatedFrameHost()->SurfaceIdForTesting(); @@ -1713,7 +1715,7 @@ gfx::Rect()); view_->SetSize(large_size); view_->Show(); - scoped_ptr<cc::CompositorFrame> frame = + std::unique_ptr<cc::CompositorFrame> frame = MakeDelegatedFrame(1.f, small_size, gfx::Rect(small_size)); frame->metadata.root_background_color = SK_ColorRED; view_->OnSwapCompositorFrame(0, std::move(frame)); @@ -2002,15 +2004,15 @@ gfx::Size frame_size = view_rect.size(); DCHECK_EQ(0u, HostSharedBitmapManager::current()->AllocatedBitmapCount()); - scoped_ptr<RenderWidgetHostImpl * []> hosts( - new RenderWidgetHostImpl* [renderer_count]); - scoped_ptr<FakeRenderWidgetHostViewAura * []> views( - new FakeRenderWidgetHostViewAura* [renderer_count]); + std::unique_ptr<RenderWidgetHostImpl* []> hosts( + new RenderWidgetHostImpl*[renderer_count]); + std::unique_ptr<FakeRenderWidgetHostViewAura* []> views( + new FakeRenderWidgetHostViewAura*[renderer_count]); // Create a bunch of renderers. for (size_t i = 0; i < renderer_count; ++i) { int32_t routing_id = process_host_->GetNextRoutingID(); - delegates_.push_back(make_scoped_ptr(new MockRenderWidgetHostDelegate)); + delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); hosts[i] = new RenderWidgetHostImpl(delegates_.back().get(), process_host_, routing_id, false); delegates_.back()->set_widget_host(hosts[i]); @@ -2168,15 +2170,15 @@ gfx::Size frame_size = view_rect.size(); DCHECK_EQ(0u, HostSharedBitmapManager::current()->AllocatedBitmapCount()); - scoped_ptr<RenderWidgetHostImpl * []> hosts( - new RenderWidgetHostImpl* [renderer_count]); - scoped_ptr<FakeRenderWidgetHostViewAura * []> views( - new FakeRenderWidgetHostViewAura* [renderer_count]); + std::unique_ptr<RenderWidgetHostImpl* []> hosts( + new RenderWidgetHostImpl*[renderer_count]); + std::unique_ptr<FakeRenderWidgetHostViewAura* []> views( + new FakeRenderWidgetHostViewAura*[renderer_count]); // Create a bunch of renderers. for (size_t i = 0; i < renderer_count; ++i) { int32_t routing_id = process_host_->GetNextRoutingID(); - delegates_.push_back(make_scoped_ptr(new MockRenderWidgetHostDelegate)); + delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); hosts[i] = new RenderWidgetHostImpl(delegates_.back().get(), process_host_, routing_id, false); delegates_.back()->set_widget_host(hosts[i]); @@ -2239,15 +2241,15 @@ gfx::Size frame_size = view_rect.size(); DCHECK_EQ(0u, HostSharedBitmapManager::current()->AllocatedBitmapCount()); - scoped_ptr<RenderWidgetHostImpl * []> hosts( - new RenderWidgetHostImpl* [renderer_count]); - scoped_ptr<FakeRenderWidgetHostViewAura * []> views( - new FakeRenderWidgetHostViewAura* [renderer_count]); + std::unique_ptr<RenderWidgetHostImpl* []> hosts( + new RenderWidgetHostImpl*[renderer_count]); + std::unique_ptr<FakeRenderWidgetHostViewAura* []> views( + new FakeRenderWidgetHostViewAura*[renderer_count]); // Create a bunch of renderers. for (size_t i = 0; i < renderer_count; ++i) { int32_t routing_id = process_host_->GetNextRoutingID(); - delegates_.push_back(make_scoped_ptr(new MockRenderWidgetHostDelegate)); + delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); hosts[i] = new RenderWidgetHostImpl(delegates_.back().get(), process_host_, routing_id, false); delegates_.back()->set_widget_host(hosts[i]); @@ -2364,7 +2366,7 @@ view_rect_.size(), base::Bind(&RenderWidgetHostViewAuraCopyRequestTest::CallbackMethod, base::Unretained(this))); - view_->BeginFrameSubscription(make_scoped_ptr(frame_subscriber_)); + view_->BeginFrameSubscription(base::WrapUnique(frame_subscriber_)); ASSERT_EQ(0, callback_count_); ASSERT_FALSE(view_->last_copy_request_); } @@ -2372,7 +2374,7 @@ void InstallFakeTickClock() { // Create a fake tick clock and transfer ownership to the frame host. tick_clock_ = new base::SimpleTestTickClock(); - view_->GetDelegatedFrameHost()->tick_clock_ = make_scoped_ptr(tick_clock_); + view_->GetDelegatedFrameHost()->tick_clock_ = base::WrapUnique(tick_clock_); } void OnSwapCompositorFrame() { @@ -2386,10 +2388,10 @@ } void ReleaseSwappedFrame() { - scoped_ptr<cc::CopyOutputRequest> request = + std::unique_ptr<cc::CopyOutputRequest> request = std::move(view_->last_copy_request_); request->SendTextureResult(view_rect_.size(), request->texture_mailbox(), - scoped_ptr<cc::SingleReleaseCallback>()); + std::unique_ptr<cc::SingleReleaseCallback>()); RunLoopUntilCallback(); } @@ -2499,7 +2501,7 @@ OnSwapCompositorFrame(); EXPECT_EQ(1, callback_count_); - scoped_ptr<cc::CopyOutputRequest> request = + std::unique_ptr<cc::CopyOutputRequest> request = std::move(view_->last_copy_request_); // Destroy the RenderWidgetHostViewAura and ImageTransportFactory. @@ -2508,7 +2510,7 @@ // Send the result after-the-fact. It goes nowhere since DelegatedFrameHost // has been destroyed. request->SendTextureResult(view_rect_.size(), request->texture_mailbox(), - scoped_ptr<cc::SingleReleaseCallback>()); + std::unique_ptr<cc::SingleReleaseCallback>()); // Because the copy request callback may be holding state within it, that // state must handle the RWHVA and ImageTransportFactory going away before the @@ -4276,7 +4278,7 @@ // Set up test delegate and window hierarchy. aura::test::EventCountDelegate delegate; - scoped_ptr<aura::Window> parent(new aura::Window(&delegate)); + std::unique_ptr<aura::Window> parent(new aura::Window(&delegate)); parent->Init(ui::LAYER_TEXTURED); root->AddChild(parent.get()); view_->InitAsChild(parent.get()); @@ -4345,7 +4347,7 @@ protected: void SetUp() override { ImageTransportFactory::InitializeForUnitTests( - scoped_ptr<ImageTransportFactory>( + std::unique_ptr<ImageTransportFactory>( new NoTransportImageTransportFactory)); RenderViewHostImplTestHarness::SetUp(); // Delete the current RenderWidgetHostView instance before setting
diff --git a/content/browser/renderer_host/render_widget_host_view_base.cc b/content/browser/renderer_host/render_widget_host_view_base.cc index febe5160..fd58003 100644 --- a/content/browser/renderer_host/render_widget_host_view_base.cc +++ b/content/browser/renderer_host/render_widget_host_view_base.cc
@@ -282,17 +282,17 @@ return weak_factory_.GetWeakPtr(); } -scoped_ptr<SyntheticGestureTarget> +std::unique_ptr<SyntheticGestureTarget> RenderWidgetHostViewBase::CreateSyntheticGestureTarget() { RenderWidgetHostImpl* host = RenderWidgetHostImpl::From(GetRenderWidgetHost()); - return scoped_ptr<SyntheticGestureTarget>( + return std::unique_ptr<SyntheticGestureTarget>( new SyntheticGestureTargetBase(host)); } // Base implementation is unimplemented. void RenderWidgetHostViewBase::BeginFrameSubscription( - scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) { + std::unique_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) { NOTREACHED(); }
diff --git a/content/browser/renderer_host/render_widget_host_view_base.h b/content/browser/renderer_host/render_widget_host_view_base.h index c11775b..ee9e358 100644 --- a/content/browser/renderer_host/render_widget_host_view_base.h +++ b/content/browser/renderer_host/render_widget_host_view_base.h
@@ -8,12 +8,12 @@ #include <stddef.h> #include <stdint.h> +#include <memory> #include <string> #include <vector> #include "base/callback_forward.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/observer_list.h" #include "base/process/kill.h" #include "base/timer/timer.h" @@ -95,7 +95,7 @@ gfx::Size GetVisibleViewportSize() const override; void SetInsets(const gfx::Insets& insets) override; void BeginFrameSubscription( - scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) override; + std::unique_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) override; void EndFrameSubscription() override; // This only needs to be overridden by RenderWidgetHostViewBase subclasses @@ -185,7 +185,8 @@ // Create a platform specific SyntheticGestureTarget implementation that will // be used to inject synthetic input events. - virtual scoped_ptr<SyntheticGestureTarget> CreateSyntheticGestureTarget(); + virtual std::unique_ptr<SyntheticGestureTarget> + CreateSyntheticGestureTarget(); // Create a BrowserAccessibilityManager for a frame in this view. // If |for_root_frame| is true, creates a BrowserAccessibilityManager @@ -202,8 +203,9 @@ // Informs that the focused DOM node has changed. virtual void FocusedNodeChanged(bool is_editable_node) {} - virtual void OnSwapCompositorFrame(uint32_t output_surface_id, - scoped_ptr<cc::CompositorFrame> frame) {} + virtual void OnSwapCompositorFrame( + uint32_t output_surface_id, + std::unique_ptr<cc::CompositorFrame> frame) {} // This method exists to allow removing of displayed graphics, after a new // page has been loaded, to prevent the displayed URL from being out of sync @@ -456,7 +458,7 @@ base::ObserverList<RenderWidgetHostViewBaseObserver> observers_; // The last reported input state by the RenderWidget. - scoped_ptr<TextInputState> text_input_state_; + std::unique_ptr<TextInputState> text_input_state_; base::WeakPtrFactory<RenderWidgetHostViewBase> weak_factory_;
diff --git a/content/browser/renderer_host/render_widget_host_view_browsertest.cc b/content/browser/renderer_host/render_widget_host_view_browsertest.cc index d1f1fba..476e7da 100644 --- a/content/browser/renderer_host/render_widget_host_view_browsertest.cc +++ b/content/browser/renderer_host/render_widget_host_view_browsertest.cc
@@ -343,7 +343,7 @@ RenderWidgetHostViewBase* const view = GetRenderWidgetHostView(); base::RunLoop run_loop; - scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber( + std::unique_ptr<RenderWidgetHostViewFrameSubscriber> subscriber( new FakeFrameSubscriber(base::Bind( &RenderWidgetHostViewBrowserTest::FrameDelivered, base::Unretained(this), base::ThreadTaskRunnerHandle::Get(),
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.h b/content/browser/renderer_host/render_widget_host_view_mac.h index 79b76d6..cd41af5 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.h +++ b/content/browser/renderer_host/render_widget_host_view_mac.h
@@ -9,8 +9,10 @@ #include <IOSurface/IOSurface.h> #include <stddef.h> #include <stdint.h> + #include <list> #include <map> +#include <memory> #include <set> #include <string> #include <utility> @@ -18,7 +20,6 @@ #include "base/mac/scoped_nsobject.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/time/time.h" #include "cc/surfaces/surface_id.h" @@ -66,14 +67,14 @@ RenderWidgetHostViewMacOwner, NSTextInputClient> { @private - scoped_ptr<content::RenderWidgetHostViewMac> renderWidgetHostView_; + std::unique_ptr<content::RenderWidgetHostViewMac> renderWidgetHostView_; // This ivar is the cocoa delegate of the NSResponder. base::scoped_nsobject<NSObject<RenderWidgetHostViewMacDelegate>> responderDelegate_; BOOL canBeKeyView_; BOOL closeOnDeactivate_; BOOL opaque_; - scoped_ptr<content::RenderWidgetHostViewMacEditCommandHelper> + std::unique_ptr<content::RenderWidgetHostViewMacEditCommandHelper> editCommand_helper_; // Is YES if there was a mouse-down as yet unbalanced with a mouse-up. @@ -150,7 +151,7 @@ // the view that some as-yet-undefined gesture is starting. Capture the // information about the gesture's beginning event here. It will be used to // create a specific gesture begin event later. - scoped_ptr<blink::WebGestureEvent> gestureBeginEvent_; + std::unique_ptr<blink::WebGestureEvent> gestureBeginEvent_; // To avoid accidental pinches, require that a certain zoom threshold be // reached before forwarding it to the browser. Use |pinchUnusedAmount_| to @@ -306,10 +307,11 @@ const base::Callback<void(const gfx::Rect&, bool)>& callback) override; bool CanCopyToVideoFrame() const override; void BeginFrameSubscription( - scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) override; + std::unique_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) override; void EndFrameSubscription() override; - void OnSwapCompositorFrame(uint32_t output_surface_id, - scoped_ptr<cc::CompositorFrame> frame) override; + void OnSwapCompositorFrame( + uint32_t output_surface_id, + std::unique_ptr<cc::CompositorFrame> frame) override; void ClearCompositorFrame() override; BrowserAccessibilityManager* CreateBrowserAccessibilityManager( BrowserAccessibilityDelegate* delegate, bool for_root_frame) override; @@ -329,7 +331,8 @@ void GestureEventAck(const blink::WebGestureEvent& event, InputEventAckState ack_result) override; - scoped_ptr<SyntheticGestureTarget> CreateSyntheticGestureTarget() override; + std::unique_ptr<SyntheticGestureTarget> CreateSyntheticGestureTarget() + override; uint32_t GetSurfaceIdNamespace() override; uint32_t SurfaceIdNamespaceAtPoint(cc::SurfaceHittestDelegate* delegate, @@ -441,16 +444,16 @@ BrowserCompositorViewState browser_compositor_state_; // Delegated frame management and compositor. - scoped_ptr<DelegatedFrameHost> delegated_frame_host_; - scoped_ptr<ui::Layer> root_layer_; + std::unique_ptr<DelegatedFrameHost> delegated_frame_host_; + std::unique_ptr<ui::Layer> root_layer_; // Container for ui::Compositor the CALayer tree drawn by it. - scoped_ptr<BrowserCompositorMac> browser_compositor_; + std::unique_ptr<BrowserCompositorMac> browser_compositor_; // Placeholder that is allocated while browser_compositor_ is NULL, // indicating that a BrowserCompositorViewMac may be allocated. This is to // help in recycling the internals of BrowserCompositorViewMac. - scoped_ptr<BrowserCompositorMacPlaceholder> + std::unique_ptr<BrowserCompositorMacPlaceholder> browser_compositor_placeholder_; // Set when the currently-displayed frame is the minimum scale. Used to @@ -486,7 +489,7 @@ bool DelegatedFrameHostIsVisible() const override; gfx::Size DelegatedFrameHostDesiredSizeInDIP() const override; bool DelegatedFrameCanCreateResizeLock() const override; - scoped_ptr<ResizeLock> DelegatedFrameHostCreateResizeLock( + std::unique_ptr<ResizeLock> DelegatedFrameHostCreateResizeLock( bool defer_compositor_lock) override; void DelegatedFrameHostResizeLockWasReleased() override; void DelegatedFrameHostSendCompositorSwapAck(
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm index 09859f1..0ec6ad3 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.mm +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
@@ -446,11 +446,11 @@ return false; } -scoped_ptr<ResizeLock> +std::unique_ptr<ResizeLock> RenderWidgetHostViewMac::DelegatedFrameHostCreateResizeLock( bool defer_compositor_lock) { NOTREACHED(); - return scoped_ptr<ResizeLock>(); + return std::unique_ptr<ResizeLock>(); } void RenderWidgetHostViewMac::DelegatedFrameHostResizeLockWasReleased() { @@ -1242,7 +1242,7 @@ } void RenderWidgetHostViewMac::BeginFrameSubscription( - scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) { + std::unique_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) { DCHECK(delegated_frame_host_); delegated_frame_host_->BeginFrameSubscription(std::move(subscriber)); } @@ -1423,7 +1423,7 @@ void RenderWidgetHostViewMac::OnSwapCompositorFrame( uint32_t output_surface_id, - scoped_ptr<cc::CompositorFrame> frame) { + std::unique_ptr<cc::CompositorFrame> frame) { TRACE_EVENT0("browser", "RenderWidgetHostViewMac::OnSwapCompositorFrame"); last_scroll_offset_ = frame->metadata.root_scroll_offset; @@ -1553,11 +1553,11 @@ } } -scoped_ptr<SyntheticGestureTarget> +std::unique_ptr<SyntheticGestureTarget> RenderWidgetHostViewMac::CreateSyntheticGestureTarget() { RenderWidgetHostImpl* host = RenderWidgetHostImpl::From(GetRenderWidgetHost()); - return scoped_ptr<SyntheticGestureTarget>( + return std::unique_ptr<SyntheticGestureTarget>( new SyntheticGestureTargetMac(host, cocoa_view_)); }
diff --git a/content/browser/renderer_host/render_widget_host_view_mac_editcommand_helper_unittest.mm b/content/browser/renderer_host/render_widget_host_view_mac_editcommand_helper_unittest.mm index dfa92c11..5a8cfef 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac_editcommand_helper_unittest.mm +++ b/content/browser/renderer_host/render_widget_host_view_mac_editcommand_helper_unittest.mm
@@ -105,7 +105,7 @@ protected: void SetUp() override { ImageTransportFactory::InitializeForUnitTests( - scoped_ptr<ImageTransportFactory>( + std::unique_ptr<ImageTransportFactory>( new NoTransportImageTransportFactory)); } void TearDown() override { ImageTransportFactory::Terminate(); }
diff --git a/content/browser/renderer_host/render_widget_host_view_mac_unittest.mm b/content/browser/renderer_host/render_widget_host_view_mac_unittest.mm index c94bcf3..a2860a83 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac_unittest.mm +++ b/content/browser/renderer_host/render_widget_host_view_mac_unittest.mm
@@ -156,7 +156,7 @@ void Paste() override {} void SelectAll() override {} - scoped_ptr<TextInputState> text_input_state_; + std::unique_ptr<TextInputState> text_input_state_; }; class MockRenderWidgetHostImpl : public RenderWidgetHostImpl { @@ -235,7 +235,7 @@ void SetUp() override { RenderViewHostImplTestHarness::SetUp(); ImageTransportFactory::InitializeForUnitTests( - scoped_ptr<ImageTransportFactory>( + std::unique_ptr<ImageTransportFactory>( new NoTransportImageTransportFactory)); // TestRenderViewHost's destruction assumes that its view is a @@ -853,7 +853,7 @@ // Send an ACK for the first wheel event, so that the queue will be flushed. InputEventAck ack(blink::WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_CONSUMED); - scoped_ptr<IPC::Message> response( + std::unique_ptr<IPC::Message> response( new InputHostMsg_HandleInputEvent_ACK(0, ack)); host->OnMessageReceived(*response); @@ -903,7 +903,7 @@ // Indicate that the wheel event was unhandled. InputEventAck unhandled_ack(blink::WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_NOT_CONSUMED); - scoped_ptr<IPC::Message> response1( + std::unique_ptr<IPC::Message> response1( new InputHostMsg_HandleInputEvent_ACK(0, unhandled_ack)); host->OnMessageReceived(*response1); @@ -917,7 +917,7 @@ ASSERT_EQ(1U, process_host->sink().message_count()); // Indicate that the wheel event was also unhandled. - scoped_ptr<IPC::Message> response2( + std::unique_ptr<IPC::Message> response2( new InputHostMsg_HandleInputEvent_ACK(0, unhandled_ack)); host->OnMessageReceived(*response2); @@ -964,7 +964,7 @@ // Indicate that the wheel event was unhandled. InputEventAck unhandled_ack(blink::WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_NOT_CONSUMED); - scoped_ptr<IPC::Message> response1( + std::unique_ptr<IPC::Message> response1( new InputHostMsg_HandleInputEvent_ACK(0, unhandled_ack)); host->OnMessageReceived(*response1); ASSERT_EQ(2U, process_host->sink().message_count()); @@ -972,7 +972,7 @@ InputEventAck unhandled_scroll_ack(blink::WebInputEvent::GestureScrollUpdate, INPUT_EVENT_ACK_STATE_NOT_CONSUMED); - scoped_ptr<IPC::Message> scroll_response1( + std::unique_ptr<IPC::Message> scroll_response1( new InputHostMsg_HandleInputEvent_ACK(0, unhandled_scroll_ack)); host->OnMessageReceived(*scroll_response1); @@ -986,7 +986,7 @@ ASSERT_EQ(2U, process_host->sink().message_count()); // Indicate that the wheel event was also unhandled. - scoped_ptr<IPC::Message> response2( + std::unique_ptr<IPC::Message> response2( new InputHostMsg_HandleInputEvent_ACK(0, unhandled_ack)); host->OnMessageReceived(*response2); @@ -1137,7 +1137,7 @@ // We'll use this IPC message to ack events. InputEventAck ack(blink::WebInputEvent::GesturePinchUpdate, INPUT_EVENT_ACK_STATE_CONSUMED); - scoped_ptr<IPC::Message> response( + std::unique_ptr<IPC::Message> response( new InputHostMsg_HandleInputEvent_ACK(0, ack)); // Do a gesture that crosses the threshold.
diff --git a/content/browser/renderer_host/render_widget_host_view_mus.h b/content/browser/renderer_host/render_widget_host_view_mus.h index bc91820..b97d7c25 100644 --- a/content/browser/renderer_host/render_widget_host_view_mus.h +++ b/content/browser/renderer_host/render_widget_host_view_mus.h
@@ -118,7 +118,7 @@ aura::Window* aura_window_; - scoped_ptr<mus::ScopedWindowPtr> mus_window_; + std::unique_ptr<mus::ScopedWindowPtr> mus_window_; DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMus); };
diff --git a/content/browser/renderer_host/sandbox_ipc_linux.h b/content/browser/renderer_host/sandbox_ipc_linux.h index f1a6bd5..2632b16 100644 --- a/content/browser/renderer_host/sandbox_ipc_linux.h +++ b/content/browser/renderer_host/sandbox_ipc_linux.h
@@ -7,11 +7,11 @@ #ifndef CONTENT_BROWSER_RENDERER_HOST_SANDBOX_IPC_LINUX_H_ #define CONTENT_BROWSER_RENDERER_HOST_SANDBOX_IPC_LINUX_H_ +#include <memory> #include <vector> #include "base/files/scoped_file.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/pickle.h" #include "base/threading/simple_thread.h" #include "skia/ext/skia_utils_base.h"
diff --git a/content/browser/renderer_host/text_input_client_mac_unittest.mm b/content/browser/renderer_host/text_input_client_mac_unittest.mm index 51cb7893..f12bbc2 100644 --- a/content/browser/renderer_host/text_input_client_mac_unittest.mm +++ b/content/browser/renderer_host/text_input_client_mac_unittest.mm
@@ -87,7 +87,7 @@ // Gets deleted when the last RWH in the "process" gets destroyed. MockRenderProcessHostFactory process_factory_; MockRenderWidgetHostDelegate delegate_; - scoped_ptr<RenderWidgetHostImpl> widget_; + std::unique_ptr<RenderWidgetHostImpl> widget_; base::Thread thread_; }; @@ -156,7 +156,7 @@ scoped_refptr<TextInputClientMessageFilter> filter( new TextInputClientMessageFilter(widget()->GetProcess()->GetID())); - scoped_ptr<IPC::Message> message( + std::unique_ptr<IPC::Message> message( new TextInputClientReplyMsg_GotCharacterIndexForPoint( widget()->GetRoutingID(), UINT32_MAX)); // Set |WTF::notFound| to the index |kTaskDelayMs| after the previous
diff --git a/content/browser/renderer_host/websocket_blob_sender.cc b/content/browser/renderer_host/websocket_blob_sender.cc index 8fe56fd..89bb151 100644 --- a/content/browser/renderer_host/websocket_blob_sender.cc +++ b/content/browser/renderer_host/websocket_blob_sender.cc
@@ -58,7 +58,7 @@ return os << kStateStrings[static_cast<int>(state)]; } -WebSocketBlobSender::WebSocketBlobSender(scoped_ptr<Channel> channel) +WebSocketBlobSender::WebSocketBlobSender(std::unique_ptr<Channel> channel) : channel_(std::move(channel)) {} WebSocketBlobSender::~WebSocketBlobSender() {} @@ -74,7 +74,7 @@ DCHECK(context); DCHECK(channel_state); DCHECK(!reader_); - scoped_ptr<storage::BlobDataHandle> data_handle( + std::unique_ptr<storage::BlobDataHandle> data_handle( context->GetBlobDataFromUUID(uuid)); if (!data_handle) return net::ERR_INVALID_HANDLE;
diff --git a/content/browser/renderer_host/websocket_blob_sender.h b/content/browser/renderer_host/websocket_blob_sender.h index 6dcfe732..d8131ad 100644 --- a/content/browser/renderer_host/websocket_blob_sender.h +++ b/content/browser/renderer_host/websocket_blob_sender.h
@@ -7,13 +7,14 @@ #include <stddef.h> #include <stdint.h> + #include <iosfwd> +#include <memory> #include <string> #include <vector> #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "content/common/content_export.h" #include "net/base/completion_callback.h" #include "net/websockets/websocket_event_interface.h" @@ -65,7 +66,7 @@ }; // |channel| will be destroyed when this object is. - explicit WebSocketBlobSender(scoped_ptr<Channel> channel); + explicit WebSocketBlobSender(std::unique_ptr<Channel> channel); ~WebSocketBlobSender(); // Checks that the blob identified by |uuid| exists, has the size @@ -128,8 +129,8 @@ uint64_t bytes_left_ = 0; net::CompletionCallback callback_; scoped_refptr<net::IOBuffer> buffer_; - scoped_ptr<storage::BlobReader> reader_; - const scoped_ptr<Channel> channel_; + std::unique_ptr<storage::BlobReader> reader_; + const std::unique_ptr<Channel> channel_; DISALLOW_COPY_AND_ASSIGN(WebSocketBlobSender); };
diff --git a/content/browser/renderer_host/websocket_blob_sender_unittest.cc b/content/browser/renderer_host/websocket_blob_sender_unittest.cc index fe2f936..3773076c7 100644 --- a/content/browser/renderer_host/websocket_blob_sender_unittest.cc +++ b/content/browser/renderer_host/websocket_blob_sender_unittest.cc
@@ -14,6 +14,7 @@ #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/location.h" +#include "base/memory/ptr_util.h" #include "base/memory/weak_ptr.h" #include "base/message_loop/message_loop.h" #include "base/run_loop.h" @@ -120,7 +121,7 @@ // This method can be overriden to use a different channel implementation. virtual void SetUpSender() { fake_channel_ = new FakeChannel; - sender_.reset(new WebSocketBlobSender(make_scoped_ptr(fake_channel_))); + sender_.reset(new WebSocketBlobSender(base::WrapUnique(fake_channel_))); fake_channel_->set_notify_new_quota(base::Bind( &WebSocketBlobSender::OnNewSendQuota, base::Unretained(sender_.get()))); } @@ -136,8 +137,8 @@ } // |string| is copied. - scoped_ptr<BlobHandle> CreateMemoryBackedBlob(const char* string) { - scoped_ptr<BlobHandle> handle = + std::unique_ptr<BlobHandle> CreateMemoryBackedBlob(const char* string) { + std::unique_ptr<BlobHandle> handle = chrome_blob_storage_context_->CreateMemoryBackedBlob(string, strlen(string)); EXPECT_TRUE(handle); @@ -182,13 +183,13 @@ scoped_refptr<ChromeBlobStorageContext> chrome_blob_storage_context_; // |fake_channel_| is owned by |sender_|. FakeChannel* fake_channel_; - scoped_ptr<WebSocketBlobSender> sender_; + std::unique_ptr<WebSocketBlobSender> sender_; }; TEST_F(WebSocketBlobSenderTest, Construction) {} TEST_F(WebSocketBlobSenderTest, EmptyBlob) { - scoped_ptr<BlobHandle> handle = CreateMemoryBackedBlob(""); + std::unique_ptr<BlobHandle> handle = CreateMemoryBackedBlob(""); // The APIs allow for this to be asynchronous but that is unlikely in // practice. @@ -201,7 +202,7 @@ } TEST_F(WebSocketBlobSenderTest, SmallBlob) { - scoped_ptr<BlobHandle> handle = CreateMemoryBackedBlob(kBanana); + std::unique_ptr<BlobHandle> handle = CreateMemoryBackedBlob(kBanana); EXPECT_EQ(net::OK, Start(handle->GetUUID(), UINT64_C(6), NotCalled())); EXPECT_TRUE(fake_channel_->got_fin()); @@ -210,7 +211,7 @@ } TEST_F(WebSocketBlobSenderTest, SizeMismatch) { - scoped_ptr<BlobHandle> handle = CreateMemoryBackedBlob(kBanana); + std::unique_ptr<BlobHandle> handle = CreateMemoryBackedBlob(kBanana); EXPECT_EQ(net::ERR_UPLOAD_FILE_CHANGED, Start(handle->GetUUID(), UINT64_C(5), NotCalled())); @@ -224,7 +225,7 @@ TEST_F(WebSocketBlobSenderTest, LargeMessage) { std::string message(kInitialQuota + 10, 'a'); - scoped_ptr<BlobHandle> handle = CreateMemoryBackedBlob(message.c_str()); + std::unique_ptr<BlobHandle> handle = CreateMemoryBackedBlob(message.c_str()); base::RunLoop run_loop; int rv = Start(handle->GetUUID(), message.size(), @@ -241,7 +242,7 @@ // A message exactly equal to the available quota should be sent in one frame. TEST_F(WebSocketBlobSenderTest, ExactSizeMessage) { std::string message(kInitialQuota, 'a'); - scoped_ptr<BlobHandle> handle = CreateMemoryBackedBlob(message.c_str()); + std::unique_ptr<BlobHandle> handle = CreateMemoryBackedBlob(message.c_str()); EXPECT_EQ(net::OK, Start(handle->GetUUID(), message.size(), NotCalled())); EXPECT_EQ(1, fake_channel_->frames_sent()); @@ -254,7 +255,7 @@ // object will be destroyed. It needs to handle this case without error. TEST_F(WebSocketBlobSenderTest, AbortedSend) { std::string message(kInitialQuota + 10, 'a'); - scoped_ptr<BlobHandle> handle = CreateMemoryBackedBlob(message.c_str()); + std::unique_ptr<BlobHandle> handle = CreateMemoryBackedBlob(message.c_str()); int rv = Start(handle->GetUUID(), message.size(), NotCalled()); EXPECT_EQ(net::ERR_IO_PENDING, rv); @@ -265,7 +266,7 @@ TEST_F(WebSocketBlobSenderTest, InvalidFileBackedBlob) { base::FilePath path(FILE_PATH_LITERAL( "WebSocketBlobSentTest.InvalidFileBackedBlob.NonExistentFile")); - scoped_ptr<BlobHandle> handle = + std::unique_ptr<BlobHandle> handle = chrome_blob_storage_context_->CreateFileBackedBlob(path, 0u, 32u, base::Time::Now()); EXPECT_TRUE(handle); @@ -294,7 +295,8 @@ ASSERT_TRUE(base::GetFileInfo(path, info)); } - scoped_ptr<BlobHandle> CreateFileBackedBlob(const std::string& contents) { + std::unique_ptr<BlobHandle> CreateFileBackedBlob( + const std::string& contents) { base::FilePath path = temp_dir_.path().AppendASCII("blob.dat"); base::File::Info info; CreateFile(contents, path, &info); @@ -308,7 +310,7 @@ }; TEST_F(WebSocketFileBackedBlobSenderTest, EmptyBlob) { - scoped_ptr<BlobHandle> handle = CreateFileBackedBlob(""); + std::unique_ptr<BlobHandle> handle = CreateFileBackedBlob(""); ASSERT_TRUE(handle); TestCompletionCallback callback; @@ -320,7 +322,7 @@ } TEST_F(WebSocketFileBackedBlobSenderTest, SizeMismatch) { - scoped_ptr<BlobHandle> handle = CreateFileBackedBlob(kBanana); + std::unique_ptr<BlobHandle> handle = CreateFileBackedBlob(kBanana); ASSERT_TRUE(handle); TestCompletionCallback callback; @@ -337,7 +339,7 @@ while (message.size() <= kInitialQuota) { message = message + message; } - scoped_ptr<BlobHandle> handle = CreateFileBackedBlob(message); + std::unique_ptr<BlobHandle> handle = CreateFileBackedBlob(message); ASSERT_TRUE(handle); TestCompletionCallback callback; @@ -350,7 +352,7 @@ // The WebSocketBlobSender needs to handle a connection close while doing file // IO cleanly. TEST_F(WebSocketFileBackedBlobSenderTest, Aborted) { - scoped_ptr<BlobHandle> handle = CreateFileBackedBlob(kBanana); + std::unique_ptr<BlobHandle> handle = CreateFileBackedBlob(kBanana); int rv = Start(handle->GetUUID(), UINT64_C(6), NotCalled()); EXPECT_EQ(net::ERR_IO_PENDING, rv); @@ -360,7 +362,7 @@ class DeletingFakeChannel : public WebSocketBlobSender::Channel { public: explicit DeletingFakeChannel( - scoped_ptr<WebSocketBlobSender>* sender_to_delete) + std::unique_ptr<WebSocketBlobSender>* sender_to_delete) : sender_(sender_to_delete) {} size_t GetSendQuota() const override { return kInitialQuota; } @@ -372,21 +374,21 @@ } private: - scoped_ptr<WebSocketBlobSender>* sender_; + std::unique_ptr<WebSocketBlobSender>* sender_; }; class WebSocketBlobSenderDeletingTest : public WebSocketBlobSenderTest { protected: void SetUpSender() override { sender_.reset(new WebSocketBlobSender( - make_scoped_ptr(new DeletingFakeChannel(&sender_)))); + base::WrapUnique(new DeletingFakeChannel(&sender_)))); } }; // This test only does something useful when run under AddressSanitizer or a // similar tool that can detect use-after-free bugs. TEST_F(WebSocketBlobSenderDeletingTest, SenderDeleted) { - scoped_ptr<BlobHandle> handle = CreateMemoryBackedBlob(kBanana); + std::unique_ptr<BlobHandle> handle = CreateMemoryBackedBlob(kBanana); EXPECT_EQ(net::ERR_CONNECTION_RESET, Start(handle->GetUUID(), UINT64_C(6), NotCalled())); @@ -423,7 +425,7 @@ void SetUpSender() override { synchronous_fake_channel_ = new SynchronousFakeChannel; sender_.reset( - new WebSocketBlobSender(make_scoped_ptr(synchronous_fake_channel_))); + new WebSocketBlobSender(base::WrapUnique(synchronous_fake_channel_))); synchronous_fake_channel_->set_notify_new_quota(base::Bind( &WebSocketBlobSender::OnNewSendQuota, base::Unretained(sender_.get()))); } @@ -433,7 +435,7 @@ TEST_F(WebSocketBlobSenderSynchronousTest, LargeMessage) { std::string message(kInitialQuota + 10, 'a'); - scoped_ptr<BlobHandle> handle = CreateMemoryBackedBlob(message.c_str()); + std::unique_ptr<BlobHandle> handle = CreateMemoryBackedBlob(message.c_str()); int rv = Start(handle->GetUUID(), message.size(), NotCalled()); EXPECT_EQ(net::OK, rv);
diff --git a/content/browser/renderer_host/websocket_host.cc b/content/browser/renderer_host/websocket_host.cc index 88c333a..685599d 100644 --- a/content/browser/renderer_host/websocket_host.cc +++ b/content/browser/renderer_host/websocket_host.cc
@@ -5,6 +5,7 @@ #include "content/browser/renderer_host/websocket_host.h" #include <inttypes.h> + #include <utility> #include "base/bind.h" @@ -12,6 +13,7 @@ #include "base/location.h" #include "base/logging.h" #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/single_thread_task_runner.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" @@ -148,11 +150,12 @@ const std::string& reason) override; ChannelState OnFailChannel(const std::string& message) override; ChannelState OnStartOpeningHandshake( - scoped_ptr<net::WebSocketHandshakeRequestInfo> request) override; + std::unique_ptr<net::WebSocketHandshakeRequestInfo> request) override; ChannelState OnFinishOpeningHandshake( - scoped_ptr<net::WebSocketHandshakeResponseInfo> response) override; + std::unique_ptr<net::WebSocketHandshakeResponseInfo> response) override; ChannelState OnSSLCertificateError( - scoped_ptr<net::WebSocketEventInterface::SSLErrorCallbacks> callbacks, + std::unique_ptr<net::WebSocketEventInterface::SSLErrorCallbacks> + callbacks, const GURL& url, const net::SSLInfo& ssl_info, bool fatal) override; @@ -161,7 +164,8 @@ class SSLErrorHandlerDelegate final : public SSLErrorHandler::Delegate { public: SSLErrorHandlerDelegate( - scoped_ptr<net::WebSocketEventInterface::SSLErrorCallbacks> callbacks); + std::unique_ptr<net::WebSocketEventInterface::SSLErrorCallbacks> + callbacks); ~SSLErrorHandlerDelegate() override; base::WeakPtr<SSLErrorHandler::Delegate> GetWeakPtr(); @@ -171,7 +175,7 @@ void ContinueSSLRequest() override; private: - scoped_ptr<net::WebSocketEventInterface::SSLErrorCallbacks> callbacks_; + std::unique_ptr<net::WebSocketEventInterface::SSLErrorCallbacks> callbacks_; base::WeakPtrFactory<SSLErrorHandlerDelegate> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(SSLErrorHandlerDelegate); @@ -181,7 +185,7 @@ WebSocketHost* const host_; const int routing_id_; const int render_frame_id_; - scoped_ptr<SSLErrorHandlerDelegate> ssl_error_handler_delegate_; + std::unique_ptr<SSLErrorHandlerDelegate> ssl_error_handler_delegate_; DISALLOW_COPY_AND_ASSIGN(WebSocketEventHandler); }; @@ -262,7 +266,7 @@ } ChannelState WebSocketHost::WebSocketEventHandler::OnStartOpeningHandshake( - scoped_ptr<net::WebSocketHandshakeRequestInfo> request) { + std::unique_ptr<net::WebSocketHandshakeRequestInfo> request) { bool should_send = dispatcher_->CanReadRawCookies(); DVLOG(3) << "WebSocketEventHandler::OnStartOpeningHandshake " << "should_send=" << should_send; @@ -286,7 +290,7 @@ } ChannelState WebSocketHost::WebSocketEventHandler::OnFinishOpeningHandshake( - scoped_ptr<net::WebSocketHandshakeResponseInfo> response) { + std::unique_ptr<net::WebSocketHandshakeResponseInfo> response) { bool should_send = dispatcher_->CanReadRawCookies(); DVLOG(3) << "WebSocketEventHandler::OnFinishOpeningHandshake " << "should_send=" << should_send; @@ -312,7 +316,7 @@ } ChannelState WebSocketHost::WebSocketEventHandler::OnSSLCertificateError( - scoped_ptr<net::WebSocketEventInterface::SSLErrorCallbacks> callbacks, + std::unique_ptr<net::WebSocketEventInterface::SSLErrorCallbacks> callbacks, const GURL& url, const net::SSLInfo& ssl_info, bool fatal) { @@ -330,7 +334,8 @@ WebSocketHost::WebSocketEventHandler::SSLErrorHandlerDelegate:: SSLErrorHandlerDelegate( - scoped_ptr<net::WebSocketEventInterface::SSLErrorCallbacks> callbacks) + std::unique_ptr<net::WebSocketEventInterface::SSLErrorCallbacks> + callbacks) : callbacks_(std::move(callbacks)), weak_ptr_factory_(this) {} WebSocketHost::WebSocketEventHandler::SSLErrorHandlerDelegate:: @@ -427,7 +432,7 @@ DCHECK(!channel_); - scoped_ptr<net::WebSocketEventInterface> event_interface( + std::unique_ptr<net::WebSocketEventInterface> event_interface( new WebSocketEventHandler(dispatcher_, this, routing_id_, render_frame_id)); channel_.reset(new net::WebSocketChannel(std::move(event_interface), @@ -463,7 +468,7 @@ return; } blob_sender_.reset(new WebSocketBlobSender( - make_scoped_ptr(new SendChannelImpl(channel_.get())))); + base::WrapUnique(new SendChannelImpl(channel_.get())))); StoragePartition* partition = dispatcher_->storage_partition(); storage::FileSystemContext* file_system_context = partition->GetFileSystemContext(); @@ -545,7 +550,7 @@ // All paths through this method must reset blob_sender_, so take ownership // at the beginning. - scoped_ptr<WebSocketBlobSender> blob_sender(std::move(blob_sender_)); + std::unique_ptr<WebSocketBlobSender> blob_sender(std::move(blob_sender_)); switch (result) { case net::OK: ignore_result(dispatcher_->BlobSendComplete(routing_id_));
diff --git a/content/browser/renderer_host/websocket_host.h b/content/browser/renderer_host/websocket_host.h index e95f65c..626f6be 100644 --- a/content/browser/renderer_host/websocket_host.h +++ b/content/browser/renderer_host/websocket_host.h
@@ -7,11 +7,11 @@ #include <stdint.h> +#include <memory> #include <string> #include <vector> #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/time/time.h" #include "content/common/content_export.h" @@ -89,10 +89,10 @@ void BlobSendComplete(int result); // non-NULL if and only if this object is currently in "blob sending mode". - scoped_ptr<WebSocketBlobSender> blob_sender_; + std::unique_ptr<WebSocketBlobSender> blob_sender_; // The channel we use to send events to the network. - scoped_ptr<net::WebSocketChannel> channel_; + std::unique_ptr<net::WebSocketChannel> channel_; // The WebSocketHostDispatcher that created this object. WebSocketDispatcherHost* const dispatcher_;
diff --git a/content/browser/resolve_proxy_msg_helper_unittest.cc b/content/browser/resolve_proxy_msg_helper_unittest.cc index bc723fe8..43656c2a 100644 --- a/content/browser/resolve_proxy_msg_helper_unittest.cc +++ b/content/browser/resolve_proxy_msg_helper_unittest.cc
@@ -4,6 +4,7 @@ #include "content/browser/resolve_proxy_msg_helper.h" +#include "base/memory/ptr_util.h" #include "content/browser/browser_thread_impl.h" #include "content/common/view_messages.h" #include "ipc/ipc_test_sink.h" @@ -60,8 +61,8 @@ ResolveProxyMsgHelperTest() : resolver_factory_(new net::MockAsyncProxyResolverFactory(false)), service_( - new net::ProxyService(make_scoped_ptr(new MockProxyConfigService), - make_scoped_ptr(resolver_factory_), + new net::ProxyService(base::WrapUnique(new MockProxyConfigService), + base::WrapUnique(resolver_factory_), NULL)), helper_(new TestResolveProxyMsgHelper(service_.get(), this)), io_thread_(BrowserThread::IO, &message_loop_) { @@ -84,9 +85,9 @@ net::MockAsyncProxyResolverFactory* resolver_factory_; net::MockAsyncProxyResolver resolver_; - scoped_ptr<net::ProxyService> service_; + std::unique_ptr<net::ProxyService> service_; scoped_refptr<ResolveProxyMsgHelper> helper_; - scoped_ptr<PendingResult> pending_result_; + std::unique_ptr<PendingResult> pending_result_; private: bool OnMessageReceived(const IPC::Message& msg) override {
diff --git a/content/browser/resource_context_impl.cc b/content/browser/resource_context_impl.cc index 017e08d..efe7f51 100644 --- a/content/browser/resource_context_impl.cc +++ b/content/browser/resource_context_impl.cc
@@ -8,6 +8,7 @@ #include "base/bind.h" #include "base/logging.h" +#include "base/memory/ptr_util.h" #include "content/browser/fileapi/chrome_blob_storage_context.h" #include "content/browser/loader/resource_dispatcher_host_impl.h" #include "content/browser/loader/resource_request_info_impl.h" @@ -62,16 +63,16 @@ return base::Bind(&ReturnEmptySalt); } -scoped_ptr<net::ClientCertStore> ResourceContext::CreateClientCertStore() { - return scoped_ptr<net::ClientCertStore>(); +std::unique_ptr<net::ClientCertStore> ResourceContext::CreateClientCertStore() { + return std::unique_ptr<net::ClientCertStore>(); } void ResourceContext::CreateKeygenHandler( uint32_t key_size_in_bits, const std::string& challenge_string, const GURL& url, - const base::Callback<void(scoped_ptr<net::KeygenHandler>)>& callback) { - callback.Run(make_scoped_ptr( + const base::Callback<void(std::unique_ptr<net::KeygenHandler>)>& callback) { + callback.Run(base::WrapUnique( new net::KeygenHandler(key_size_in_bits, challenge_string, url))); }
diff --git a/content/browser/screen_orientation/screen_orientation_dispatcher_host_impl.h b/content/browser/screen_orientation/screen_orientation_dispatcher_host_impl.h index 972a42d4..823afda 100644 --- a/content/browser/screen_orientation/screen_orientation_dispatcher_host_impl.h +++ b/content/browser/screen_orientation/screen_orientation_dispatcher_host_impl.h
@@ -54,7 +54,7 @@ RenderFrameHost* render_frame_host, blink::WebLockOrientationError error); - scoped_ptr<ScreenOrientationProvider> provider_; + std::unique_ptr<ScreenOrientationProvider> provider_; struct LockInformation { LockInformation(int request_id, int process_id, int routing_id);
diff --git a/content/browser/service_worker/embedded_worker_instance.cc b/content/browser/service_worker/embedded_worker_instance.cc index f30a79d..49b9b913 100644 --- a/content/browser/service_worker/embedded_worker_instance.cc +++ b/content/browser/service_worker/embedded_worker_instance.cc
@@ -8,6 +8,7 @@ #include "base/bind_helpers.h" #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/metrics/histogram_macros.h" #include "base/threading/non_thread_safe.h" #include "base/trace_event/trace_event.h" @@ -225,7 +226,7 @@ // TODO(nhiroki): Reconsider this bizarre layering. } - void Start(scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params, + void Start(std::unique_ptr<EmbeddedWorkerMsg_StartWorker_Params> params, const StatusCallback& callback) { DCHECK_CURRENTLY_ON(BrowserThread::IO); state_ = ProcessAllocationState::ALLOCATING; @@ -264,7 +265,7 @@ private: void OnProcessAllocated( - scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params, + std::unique_ptr<EmbeddedWorkerMsg_StartWorker_Params> params, ServiceWorkerStatusCode status, int process_id, bool is_new_process, @@ -299,7 +300,7 @@ // Notify the instance that a process is allocated. state_ = ProcessAllocationState::ALLOCATED; - instance_->OnProcessAllocated(make_scoped_ptr(new WorkerProcessHandle( + instance_->OnProcessAllocated(base::WrapUnique(new WorkerProcessHandle( instance_->context_, instance_->embedded_worker_id(), process_id, is_new_process))); @@ -322,7 +323,7 @@ } void OnRegisteredToDevToolsManager( - scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params, + std::unique_ptr<EmbeddedWorkerMsg_StartWorker_Params> params, bool is_new_process, int worker_devtools_agent_route_id, bool wait_for_debugger) { @@ -341,7 +342,7 @@ } void SendStartWorker( - scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params) { + std::unique_ptr<EmbeddedWorkerMsg_StartWorker_Params> params) { DCHECK_CURRENTLY_ON(BrowserThread::IO); ServiceWorkerStatusCode status = instance_->registry_->SendStartWorker( std::move(params), instance_->process_id()); @@ -390,7 +391,7 @@ } void EmbeddedWorkerInstance::Start( - scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params, + std::unique_ptr<EmbeddedWorkerMsg_StartWorker_Params> params, const StatusCallback& callback) { if (!context_) { callback.Run(SERVICE_WORKER_ERROR_ABORT); @@ -484,7 +485,7 @@ weak_factory_(this) {} void EmbeddedWorkerInstance::OnProcessAllocated( - scoped_ptr<WorkerProcessHandle> handle) { + std::unique_ptr<WorkerProcessHandle> handle) { DCHECK_EQ(STARTING, status_); DCHECK(!process_handle_);
diff --git a/content/browser/service_worker/embedded_worker_instance.h b/content/browser/service_worker/embedded_worker_instance.h index 0c9b67e..ff67bc1 100644 --- a/content/browser/service_worker/embedded_worker_instance.h +++ b/content/browser/service_worker/embedded_worker_instance.h
@@ -7,6 +7,7 @@ #include <stdint.h> +#include <memory> #include <string> #include "base/callback.h" @@ -15,7 +16,6 @@ #include "base/logging.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/observer_list.h" #include "base/strings/string16.h" @@ -112,7 +112,7 @@ // started and evaluated, or when an error occurs. // |params| should be populated with service worker version info needed // to start the worker. - void Start(scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params, + void Start(std::unique_ptr<EmbeddedWorkerMsg_StartWorker_Params> params, const StatusCallback& callback); // Stops the worker. It is invalid to call this when the worker is @@ -197,7 +197,7 @@ int embedded_worker_id); // Called back from StartTask after a process is allocated on the UI thread. - void OnProcessAllocated(scoped_ptr<WorkerProcessHandle> handle); + void OnProcessAllocated(std::unique_ptr<WorkerProcessHandle> handle); // Called back from StartTask after the worker is registered to // WorkerDevToolsManager. @@ -282,9 +282,9 @@ StartingPhase starting_phase_; // Current running information. - scoped_ptr<EmbeddedWorkerInstance::WorkerProcessHandle> process_handle_; + std::unique_ptr<EmbeddedWorkerInstance::WorkerProcessHandle> process_handle_; int thread_id_; - scoped_ptr<ServiceRegistryImpl> service_registry_; + std::unique_ptr<ServiceRegistryImpl> service_registry_; // Whether devtools is attached or not. bool devtools_attached_; @@ -294,9 +294,9 @@ bool network_accessed_for_script_; ListenerList listener_list_; - scoped_ptr<DevToolsProxy> devtools_proxy_; + std::unique_ptr<DevToolsProxy> devtools_proxy_; - scoped_ptr<StartTask> inflight_start_task_; + std::unique_ptr<StartTask> inflight_start_task_; // Used for UMA. The start time of the current start sequence step. base::TimeTicks step_time_;
diff --git a/content/browser/service_worker/embedded_worker_instance_unittest.cc b/content/browser/service_worker/embedded_worker_instance_unittest.cc index 1db995a..62e1ce6 100644 --- a/content/browser/service_worker/embedded_worker_instance_unittest.cc +++ b/content/browser/service_worker/embedded_worker_instance_unittest.cc
@@ -32,9 +32,9 @@ callback.Run(); } -scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> +std::unique_ptr<EmbeddedWorkerMsg_StartWorker_Params> CreateStartParams(int version_id, const GURL& scope, const GURL& script_url) { - scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params( + std::unique_ptr<EmbeddedWorkerMsg_StartWorker_Params> params( new EmbeddedWorkerMsg_StartWorker_Params); params->service_worker_version_id = version_id; params->scope = scope; @@ -96,7 +96,7 @@ const GURL& url) { ServiceWorkerStatusCode status; base::RunLoop run_loop; - scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params = + std::unique_ptr<EmbeddedWorkerMsg_StartWorker_Params> params = CreateStartParams(id, pattern, url); worker->Start(std::move(params), base::Bind(&SaveStatusAndCall, &status, run_loop.QuitClosure())); @@ -114,7 +114,7 @@ IPC::TestSink* ipc_sink() { return helper_->ipc_sink(); } TestBrowserThreadBundle thread_bundle_; - scoped_ptr<EmbeddedWorkerTestHelper> helper_; + std::unique_ptr<EmbeddedWorkerTestHelper> helper_; std::vector<EventLog> events_; private: @@ -162,7 +162,7 @@ }; TEST_F(EmbeddedWorkerInstanceTest, StartAndStop) { - scoped_ptr<EmbeddedWorkerInstance> worker = + std::unique_ptr<EmbeddedWorkerInstance> worker = embedded_worker_registry()->CreateWorker(); EXPECT_EQ(EmbeddedWorkerInstance::STOPPED, worker->status()); @@ -177,7 +177,7 @@ // Start should succeed. ServiceWorkerStatusCode status; base::RunLoop run_loop; - scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params = + std::unique_ptr<EmbeddedWorkerMsg_StartWorker_Params> params = CreateStartParams(service_worker_version_id, pattern, url); worker->Start(std::move(params), base::Bind(&SaveStatusAndCall, &status, run_loop.QuitClosure())); @@ -209,7 +209,7 @@ // Test that a worker that failed twice will use a new render process // on the next attempt. TEST_F(EmbeddedWorkerInstanceTest, ForceNewProcess) { - scoped_ptr<EmbeddedWorkerInstance> worker = + std::unique_ptr<EmbeddedWorkerInstance> worker = embedded_worker_registry()->CreateWorker(); EXPECT_EQ(EmbeddedWorkerInstance::STOPPED, worker->status()); @@ -232,7 +232,7 @@ // Start once normally. ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_MAX_VALUE; base::RunLoop run_loop; - scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params( + std::unique_ptr<EmbeddedWorkerMsg_StartWorker_Params> params( CreateStartParams(service_worker_version_id, pattern, url)); worker->Start(std::move(params), base::Bind(&SaveStatusAndCall, &status, run_loop.QuitClosure())); @@ -256,7 +256,7 @@ // Start again. ServiceWorkerStatusCode status; base::RunLoop run_loop; - scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params( + std::unique_ptr<EmbeddedWorkerMsg_StartWorker_Params> params( CreateStartParams(service_worker_version_id, pattern, url)); worker->Start(std::move(params), base::Bind(&SaveStatusAndCall, &status, run_loop.QuitClosure())); @@ -273,7 +273,7 @@ } TEST_F(EmbeddedWorkerInstanceTest, StopWhenDevToolsAttached) { - scoped_ptr<EmbeddedWorkerInstance> worker = + std::unique_ptr<EmbeddedWorkerInstance> worker = embedded_worker_registry()->CreateWorker(); EXPECT_EQ(EmbeddedWorkerInstance::STOPPED, worker->status()); @@ -320,9 +320,9 @@ // Test that the removal of a worker from the registry doesn't remove // other workers in the same process. TEST_F(EmbeddedWorkerInstanceTest, RemoveWorkerInSharedProcess) { - scoped_ptr<EmbeddedWorkerInstance> worker1 = + std::unique_ptr<EmbeddedWorkerInstance> worker1 = embedded_worker_registry()->CreateWorker(); - scoped_ptr<EmbeddedWorkerInstance> worker2 = + std::unique_ptr<EmbeddedWorkerInstance> worker2 = embedded_worker_registry()->CreateWorker(); const int64_t version_id1 = 55L; @@ -336,7 +336,7 @@ // Start worker1. ServiceWorkerStatusCode status; base::RunLoop run_loop; - scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params( + std::unique_ptr<EmbeddedWorkerMsg_StartWorker_Params> params( CreateStartParams(version_id1, pattern, url)); worker1->Start(std::move(params), base::Bind(&SaveStatusAndCall, &status, run_loop.QuitClosure())); @@ -348,7 +348,7 @@ // Start worker2. ServiceWorkerStatusCode status; base::RunLoop run_loop; - scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params( + std::unique_ptr<EmbeddedWorkerMsg_StartWorker_Params> params( CreateStartParams(version_id2, pattern, url)); worker2->Start(std::move(params), base::Bind(&SaveStatusAndCall, &status, run_loop.QuitClosure())); @@ -379,13 +379,13 @@ const GURL scope("http://example.com/"); const GURL url("http://example.com/worker.js"); - scoped_ptr<EmbeddedWorkerInstance> worker = + std::unique_ptr<EmbeddedWorkerInstance> worker = embedded_worker_registry()->CreateWorker(); worker->AddListener(this); // Run the start worker sequence and detach during process allocation. ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_MAX_VALUE; - scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params( + std::unique_ptr<EmbeddedWorkerMsg_StartWorker_Params> params( CreateStartParams(version_id, scope, url)); worker->Start(std::move(params), base::Bind(&SaveStatusAndCall, &status, base::Bind(&base::DoNothing))); @@ -411,13 +411,13 @@ const GURL url("http://example.com/worker.js"); helper_.reset(new StalledInStartWorkerHelper()); - scoped_ptr<EmbeddedWorkerInstance> worker = + std::unique_ptr<EmbeddedWorkerInstance> worker = embedded_worker_registry()->CreateWorker(); worker->AddListener(this); // Run the start worker sequence until a start worker message is sent. ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_MAX_VALUE; - scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params( + std::unique_ptr<EmbeddedWorkerMsg_StartWorker_Params> params( CreateStartParams(version_id, scope, url)); worker->Start(std::move(params), base::Bind(&SaveStatusAndCall, &status, base::Bind(&base::DoNothing))); @@ -449,14 +449,14 @@ const GURL scope("http://example.com/"); const GURL url("http://example.com/worker.js"); - scoped_ptr<EmbeddedWorkerInstance> worker = + std::unique_ptr<EmbeddedWorkerInstance> worker = embedded_worker_registry()->CreateWorker(); worker->AddListener(this); // Stop the start worker sequence before a process is allocated. ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_MAX_VALUE; - scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params( + std::unique_ptr<EmbeddedWorkerMsg_StartWorker_Params> params( CreateStartParams(version_id, scope, url)); worker->Start(std::move(params), base::Bind(&SaveStatusAndCall, &status, base::Bind(&base::DoNothing))); @@ -478,7 +478,7 @@ // Restart the worker. status = SERVICE_WORKER_ERROR_MAX_VALUE; - scoped_ptr<base::RunLoop> run_loop(new base::RunLoop); + std::unique_ptr<base::RunLoop> run_loop(new base::RunLoop); params = CreateStartParams(version_id, scope, url); worker->Start(std::move(params), base::Bind(&SaveStatusAndCall, &status, run_loop->QuitClosure())); @@ -499,14 +499,14 @@ const GURL scope("http://example.com/"); const GURL url("http://example.com/worker.js"); - scoped_ptr<EmbeddedWorkerInstance> worker = + std::unique_ptr<EmbeddedWorkerInstance> worker = embedded_worker_registry()->CreateWorker(); worker->AddListener(this); // Run the start worker sequence until pause after download. ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_MAX_VALUE; - scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params( + std::unique_ptr<EmbeddedWorkerMsg_StartWorker_Params> params( CreateStartParams(version_id, scope, url)); params->pause_after_download = true; worker->Start(std::move(params), base::Bind(&SaveStatusAndCall, &status, @@ -531,13 +531,13 @@ const GURL url("http://example.com/worker.js"); helper_.reset(new StalledInStartWorkerHelper); - scoped_ptr<EmbeddedWorkerInstance> worker = + std::unique_ptr<EmbeddedWorkerInstance> worker = embedded_worker_registry()->CreateWorker(); worker->AddListener(this); // Run the start worker sequence until a start worker message is sent. ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_MAX_VALUE; - scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params( + std::unique_ptr<EmbeddedWorkerMsg_StartWorker_Params> params( CreateStartParams(version_id, scope, url)); worker->Start(std::move(params), base::Bind(&SaveStatusAndCall, &status, base::Bind(&base::DoNothing))); @@ -568,7 +568,7 @@ static_cast<StalledInStartWorkerHelper*>(helper_.get()) ->set_force_stall_in_start(false); status = SERVICE_WORKER_ERROR_MAX_VALUE; - scoped_ptr<base::RunLoop> run_loop(new base::RunLoop); + std::unique_ptr<base::RunLoop> run_loop(new base::RunLoop); params = CreateStartParams(version_id, scope, url); worker->Start(std::move(params), base::Bind(&SaveStatusAndCall, &status, @@ -590,7 +590,7 @@ const int64_t version_id = 55L; const GURL pattern("http://example.com/"); const GURL url("http://example.com/worker.js"); - scoped_ptr<EmbeddedWorkerInstance> worker = + std::unique_ptr<EmbeddedWorkerInstance> worker = embedded_worker_registry()->CreateWorker(); helper_->SimulateAddProcessToPattern(pattern, helper_->mock_render_process_id()); @@ -599,7 +599,7 @@ // Start the worker. base::RunLoop run_loop; - scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params( + std::unique_ptr<EmbeddedWorkerMsg_StartWorker_Params> params( CreateStartParams(version_id, pattern, url)); worker->Start(std::move(params), base::Bind(&SaveStatusAndCall, &status, run_loop.QuitClosure())); @@ -625,7 +625,7 @@ const GURL pattern("http://example.com/"); const GURL url("http://example.com/worker.js"); - scoped_ptr<EmbeddedWorkerInstance> worker = + std::unique_ptr<EmbeddedWorkerInstance> worker = embedded_worker_registry()->CreateWorker(); helper_->SimulateAddProcessToPattern(pattern, helper_->mock_render_process_id()); @@ -634,7 +634,7 @@ // Attempt to start the worker. base::RunLoop run_loop; - scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params( + std::unique_ptr<EmbeddedWorkerMsg_StartWorker_Params> params( CreateStartParams(version_id, pattern, url)); worker->Start(std::move(params), base::Bind(&SaveStatusAndCall, &status, run_loop.QuitClosure()));
diff --git a/content/browser/service_worker/embedded_worker_registry.cc b/content/browser/service_worker/embedded_worker_registry.cc index 73eb49f..70f2d9e 100644 --- a/content/browser/service_worker/embedded_worker_registry.cc +++ b/content/browser/service_worker/embedded_worker_registry.cc
@@ -36,8 +36,8 @@ return registry; } -scoped_ptr<EmbeddedWorkerInstance> EmbeddedWorkerRegistry::CreateWorker() { - scoped_ptr<EmbeddedWorkerInstance> worker( +std::unique_ptr<EmbeddedWorkerInstance> EmbeddedWorkerRegistry::CreateWorker() { + std::unique_ptr<EmbeddedWorkerInstance> worker( new EmbeddedWorkerInstance(context_, next_embedded_worker_id_)); worker_map_[next_embedded_worker_id_++] = worker.get(); return worker; @@ -238,7 +238,7 @@ } ServiceWorkerStatusCode EmbeddedWorkerRegistry::SendStartWorker( - scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params, + std::unique_ptr<EmbeddedWorkerMsg_StartWorker_Params> params, int process_id) { if (!context_) return SERVICE_WORKER_ERROR_ABORT; @@ -265,7 +265,7 @@ ServiceWorkerStatusCode EmbeddedWorkerRegistry::Send( int process_id, IPC::Message* message_ptr) { - scoped_ptr<IPC::Message> message(message_ptr); + std::unique_ptr<IPC::Message> message(message_ptr); if (!context_) return SERVICE_WORKER_ERROR_ABORT; ProcessToSenderMap::iterator found = process_sender_map_.find(process_id);
diff --git a/content/browser/service_worker/embedded_worker_registry.h b/content/browser/service_worker/embedded_worker_registry.h index c9cea03..8e83b1d 100644 --- a/content/browser/service_worker/embedded_worker_registry.h +++ b/content/browser/service_worker/embedded_worker_registry.h
@@ -6,13 +6,13 @@ #define CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_REGISTRY_H_ #include <map> +#include <memory> #include <set> #include <vector> #include "base/gtest_prod_util.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/strings/string16.h" #include "content/common/content_export.h" @@ -55,11 +55,11 @@ // Creates and removes a new worker instance entry for bookkeeping. // This doesn't actually start or stop the worker. - scoped_ptr<EmbeddedWorkerInstance> CreateWorker(); + std::unique_ptr<EmbeddedWorkerInstance> CreateWorker(); // Called from EmbeddedWorkerInstance, relayed to the child process. ServiceWorkerStatusCode SendStartWorker( - scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params, + std::unique_ptr<EmbeddedWorkerMsg_StartWorker_Params> params, int process_id); ServiceWorkerStatusCode StopWorker(int process_id, int embedded_worker_id);
diff --git a/content/browser/service_worker/embedded_worker_test_helper.cc b/content/browser/service_worker/embedded_worker_test_helper.cc index 25fcbd5..3be53735 100644 --- a/content/browser/service_worker/embedded_worker_test_helper.cc +++ b/content/browser/service_worker/embedded_worker_test_helper.cc
@@ -87,7 +87,7 @@ next_thread_id_(0), mock_render_process_id_(render_process_host_->GetID()), weak_factory_(this) { - scoped_ptr<MockServiceWorkerDatabaseTaskManager> database_task_manager( + std::unique_ptr<MockServiceWorkerDatabaseTaskManager> database_task_manager( new MockServiceWorkerDatabaseTaskManager( base::ThreadTaskRunnerHandle::Get())); wrapper_->InitInternal(user_data_directory, std::move(database_task_manager), @@ -98,7 +98,7 @@ NewMessagePortMessageFilter()); // Setup process level mojo service registry pair. - scoped_ptr<ServiceRegistryImpl> host_service_registry( + std::unique_ptr<ServiceRegistryImpl> host_service_registry( new ServiceRegistryImpl); render_process_service_registry_.ServiceRegistry::AddService( base::Bind(&MockEmbeddedWorkerSetup::Create, weak_factory_.GetWeakPtr())); @@ -423,7 +423,7 @@ int thread_id, mojo::shell::mojom::InterfaceProviderRequest services, mojo::shell::mojom::InterfaceProviderPtr exposed_services) { - scoped_ptr<ServiceRegistryImpl> new_registry(new ServiceRegistryImpl); + std::unique_ptr<ServiceRegistryImpl> new_registry(new ServiceRegistryImpl); new_registry->Bind(std::move(services)); new_registry->BindRemoteServiceProvider(std::move(exposed_services)); OnSetupMojo(new_registry.get());
diff --git a/content/browser/service_worker/embedded_worker_test_helper.h b/content/browser/service_worker/embedded_worker_test_helper.h index a9d34b5..fe30d6c 100644 --- a/content/browser/service_worker/embedded_worker_test_helper.h +++ b/content/browser/service_worker/embedded_worker_test_helper.h
@@ -169,8 +169,8 @@ MessagePortMessageFilter* NewMessagePortMessageFilter(); - scoped_ptr<TestBrowserContext> browser_context_; - scoped_ptr<MockRenderProcessHost> render_process_host_; + std::unique_ptr<TestBrowserContext> browser_context_; + std::unique_ptr<MockRenderProcessHost> render_process_host_; scoped_refptr<ServiceWorkerContextWrapper> wrapper_; @@ -186,7 +186,7 @@ // Stores the ServiceRegistries that are associated with each individual // service worker. - base::ScopedPtrHashMap<int, scoped_ptr<ServiceRegistryImpl>> + base::ScopedPtrHashMap<int, std::unique_ptr<ServiceRegistryImpl>> thread_id_service_registry_map_; // Updated each time MessageToWorker message is received.
diff --git a/content/browser/service_worker/foreign_fetch_request_handler.cc b/content/browser/service_worker/foreign_fetch_request_handler.cc index ec4d5cd..ee9aa4b 100644 --- a/content/browser/service_worker/foreign_fetch_request_handler.cc +++ b/content/browser/service_worker/foreign_fetch_request_handler.cc
@@ -69,10 +69,11 @@ // Any more precise checks to see if the request should be intercepted are // asynchronous, so just create our handler in all cases. - scoped_ptr<ForeignFetchRequestHandler> handler(new ForeignFetchRequestHandler( - context_wrapper, blob_storage_context->AsWeakPtr(), request_mode, - credentials_mode, redirect_mode, resource_type, request_context_type, - frame_type, body)); + std::unique_ptr<ForeignFetchRequestHandler> handler( + new ForeignFetchRequestHandler( + context_wrapper, blob_storage_context->AsWeakPtr(), request_mode, + credentials_mode, redirect_mode, resource_type, request_context_type, + frame_type, body)); request->SetUserData(&kUserDataKey, handler.release()); } @@ -82,10 +83,10 @@ request->GetUserData(&kUserDataKey)); } -scoped_ptr<net::URLRequestInterceptor> +std::unique_ptr<net::URLRequestInterceptor> ForeignFetchRequestHandler::CreateInterceptor( ResourceContext* resource_context) { - return scoped_ptr<net::URLRequestInterceptor>( + return std::unique_ptr<net::URLRequestInterceptor>( new ForeignFetchRequestInterceptor(resource_context)); }
diff --git a/content/browser/service_worker/foreign_fetch_request_handler.h b/content/browser/service_worker/foreign_fetch_request_handler.h index 9bbf4ea..6d0aee0 100644 --- a/content/browser/service_worker/foreign_fetch_request_handler.h +++ b/content/browser/service_worker/foreign_fetch_request_handler.h
@@ -68,7 +68,7 @@ static ForeignFetchRequestHandler* GetHandler(net::URLRequest* request); // Creates a protocol interceptor for foreign fetch. - static scoped_ptr<net::URLRequestInterceptor> CreateInterceptor( + static std::unique_ptr<net::URLRequestInterceptor> CreateInterceptor( ResourceContext* resource_context); ~ForeignFetchRequestHandler() override;
diff --git a/content/browser/service_worker/link_header_support_unittest.cc b/content/browser/service_worker/link_header_support_unittest.cc index ae293fe7..1012702 100644 --- a/content/browser/service_worker/link_header_support_unittest.cc +++ b/content/browser/service_worker/link_header_support_unittest.cc
@@ -261,7 +261,7 @@ void ProcessLinkHeader(const GURL& request_url, const std::string& link_header) { - scoped_ptr<net::URLRequest> request = request_context_.CreateRequest( + std::unique_ptr<net::URLRequest> request = request_context_.CreateRequest( request_url, net::DEFAULT_PRIORITY, &request_delegate_); ResourceRequestInfo::AllocateForTesting( request.get(), RESOURCE_TYPE_SCRIPT, &resource_context_, @@ -286,7 +286,7 @@ private: TestBrowserThreadBundle thread_bundle_; - scoped_ptr<EmbeddedWorkerTestHelper> helper_; + std::unique_ptr<EmbeddedWorkerTestHelper> helper_; net::TestURLRequestContext request_context_; net::TestDelegate request_delegate_; MockResourceContext resource_context_;
diff --git a/content/browser/service_worker/service_worker_browsertest.cc b/content/browser/service_worker/service_worker_browsertest.cc index b8f99a4..0344a0de 100644 --- a/content/browser/service_worker/service_worker_browsertest.cc +++ b/content/browser/service_worker/service_worker_browsertest.cc
@@ -4,15 +4,17 @@ #include <stddef.h> #include <stdint.h> + #include <map> +#include <memory> #include <utility> #include "base/bind.h" #include "base/callback.h" #include "base/command_line.h" #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/strings/string16.h" @@ -73,7 +75,7 @@ ServiceWorkerStatusCode status; ServiceWorkerFetchEventResult result; ServiceWorkerResponse response; - scoped_ptr<storage::BlobDataHandle> blob_data_handle; + std::unique_ptr<storage::BlobDataHandle> blob_data_handle; }; void RunAndQuit(const base::Closure& closure, @@ -142,7 +144,7 @@ void ReadResponseBody(std::string* body, storage::BlobDataHandle* blob_data_handle) { ASSERT_TRUE(blob_data_handle); - scoped_ptr<storage::BlobDataSnapshot> data = + std::unique_ptr<storage::BlobDataSnapshot> data = blob_data_handle->CreateSnapshot(); ASSERT_EQ(1U, data->items().size()); *body = std::string(data->items()[0]->bytes(), data->items()[0]->length()); @@ -189,39 +191,40 @@ DISALLOW_COPY_AND_ASSIGN(WorkerActivatedObserver); }; -scoped_ptr<net::test_server::HttpResponse> VerifyServiceWorkerHeaderInRequest( +std::unique_ptr<net::test_server::HttpResponse> +VerifyServiceWorkerHeaderInRequest( const net::test_server::HttpRequest& request) { EXPECT_EQ(request.relative_url, "/service_worker/generated_sw.js"); auto it = request.headers.find("Service-Worker"); EXPECT_TRUE(it != request.headers.end()); EXPECT_EQ("script", it->second); - scoped_ptr<net::test_server::BasicHttpResponse> http_response( + std::unique_ptr<net::test_server::BasicHttpResponse> http_response( new net::test_server::BasicHttpResponse()); http_response->set_content_type("text/javascript"); return std::move(http_response); } -scoped_ptr<net::test_server::HttpResponse> VerifySaveDataHeaderInRequest( +std::unique_ptr<net::test_server::HttpResponse> VerifySaveDataHeaderInRequest( const net::test_server::HttpRequest& request) { auto it = request.headers.find("Save-Data"); EXPECT_NE(request.headers.end(), it); EXPECT_EQ("on", it->second); - scoped_ptr<net::test_server::BasicHttpResponse> http_response( + std::unique_ptr<net::test_server::BasicHttpResponse> http_response( new net::test_server::BasicHttpResponse()); http_response->set_content_type("text/javascript"); return std::move(http_response); } -scoped_ptr<net::test_server::HttpResponse> VerifySaveDataHeaderNotInRequest( - const net::test_server::HttpRequest& request) { +std::unique_ptr<net::test_server::HttpResponse> +VerifySaveDataHeaderNotInRequest(const net::test_server::HttpRequest& request) { auto it = request.headers.find("Save-Data"); EXPECT_EQ(request.headers.end(), it); - return make_scoped_ptr(new net::test_server::BasicHttpResponse()); + return base::WrapUnique(new net::test_server::BasicHttpResponse()); } -scoped_ptr<net::test_server::HttpResponse> +std::unique_ptr<net::test_server::HttpResponse> VerifySaveDataNotInAccessControlRequestHeader( const net::test_server::HttpRequest& request) { // Save-Data should be present. @@ -229,7 +232,7 @@ EXPECT_NE(request.headers.end(), it); EXPECT_EQ("on", it->second); - scoped_ptr<net::test_server::BasicHttpResponse> http_response( + std::unique_ptr<net::test_server::BasicHttpResponse> http_response( new net::test_server::BasicHttpResponse()); if (request.method == net::test_server::METHOD_OPTIONS) { // Access-Control-Request-Headers should contain 'X-Custom-Header' and not @@ -282,7 +285,7 @@ void CreateLongLivedResourceInterceptors( const GURL& worker_url, const GURL& import_url) { ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); - scoped_ptr<net::URLRequestInterceptor> interceptor; + std::unique_ptr<net::URLRequestInterceptor> interceptor; interceptor.reset(new LongLivedResourceInterceptor( "importScripts('long_lived_import.js');")); @@ -457,7 +460,7 @@ void FetchOnRegisteredWorker( ServiceWorkerFetchEventResult* result, ServiceWorkerResponse* response, - scoped_ptr<storage::BlobDataHandle>* blob_data_handle) { + std::unique_ptr<storage::BlobDataHandle>* blob_data_handle) { blob_context_ = ChromeBlobStorageContext::GetFor( shell()->web_contents()->GetBrowserContext()); bool prepare_result = false; @@ -479,10 +482,11 @@ ASSERT_EQ(SERVICE_WORKER_OK, fetch_result.status); } - void FetchTestHelper(const std::string& worker_url, - ServiceWorkerFetchEventResult* result, - ServiceWorkerResponse* response, - scoped_ptr<storage::BlobDataHandle>* blob_data_handle) { + void FetchTestHelper( + const std::string& worker_url, + ServiceWorkerFetchEventResult* result, + ServiceWorkerResponse* response, + std::unique_ptr<storage::BlobDataHandle>* blob_data_handle) { RunOnIOThread( base::Bind(&self::SetUpRegistrationOnIOThread, this, worker_url)); FetchOnRegisteredWorker(result, response, blob_data_handle); @@ -519,11 +523,12 @@ void AddControlleeOnIOThread() { ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); - scoped_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( - 33 /* dummy render process id */, - MSG_ROUTING_NONE /* render_frame_id */, 1 /* dummy provider_id */, - SERVICE_WORKER_PROVIDER_FOR_WINDOW, wrapper()->context()->AsWeakPtr(), - NULL)); + std::unique_ptr<ServiceWorkerProviderHost> host( + new ServiceWorkerProviderHost(33 /* dummy render process id */, + MSG_ROUTING_NONE /* render_frame_id */, + 1 /* dummy provider_id */, + SERVICE_WORKER_PROVIDER_FOR_WINDOW, + wrapper()->context()->AsWeakPtr(), NULL)); host->SetDocumentUrl( embedded_test_server()->GetURL("/service_worker/host")); host->AssociateRegistration(registration_.get(), @@ -682,9 +687,10 @@ bool* prepare_result, FetchResult* result) { ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); - scoped_ptr<ServiceWorkerFetchRequest> request(new ServiceWorkerFetchRequest( - embedded_test_server()->GetURL("/service_worker/empty.html"), "GET", - ServiceWorkerHeaderMap(), Referrer(), false)); + std::unique_ptr<ServiceWorkerFetchRequest> request( + new ServiceWorkerFetchRequest( + embedded_test_server()->GetURL("/service_worker/empty.html"), "GET", + ServiceWorkerHeaderMap(), Referrer(), false)); version_->SetStatus(ServiceWorkerVersion::ACTIVATED); fetch_dispatcher_.reset(new ServiceWorkerFetchDispatcher( std::move(request), version_.get(), RESOURCE_TYPE_MAIN_FRAME, @@ -737,7 +743,7 @@ scoped_refptr<ServiceWorkerRegistration> registration_; scoped_refptr<ServiceWorkerVersion> version_; scoped_refptr<ChromeBlobStorageContext> blob_context_; - scoped_ptr<ServiceWorkerFetchDispatcher> fetch_dispatcher_; + std::unique_ptr<ServiceWorkerFetchDispatcher> fetch_dispatcher_; }; IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, StartAndStop) { @@ -984,7 +990,7 @@ IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, FetchEvent_Response) { ServiceWorkerFetchEventResult result; ServiceWorkerResponse response; - scoped_ptr<storage::BlobDataHandle> blob_data_handle; + std::unique_ptr<storage::BlobDataHandle> blob_data_handle; FetchTestHelper("/service_worker/fetch_event.js", &result, &response, &blob_data_handle); ASSERT_EQ(SERVICE_WORKER_FETCH_EVENT_RESULT_RESPONSE, result); @@ -1007,7 +1013,7 @@ ServiceWorkerFetchEventResult result; ServiceWorkerResponse response1; ServiceWorkerResponse response2; - scoped_ptr<storage::BlobDataHandle> blob_data_handle; + std::unique_ptr<storage::BlobDataHandle> blob_data_handle; const base::Time start_time(base::Time::Now()); RunOnIOThread( @@ -1035,7 +1041,7 @@ FetchEvent_respondWithRejection) { ServiceWorkerFetchEventResult result; ServiceWorkerResponse response; - scoped_ptr<storage::BlobDataHandle> blob_data_handle; + std::unique_ptr<storage::BlobDataHandle> blob_data_handle; RunOnIOThread(base::Bind(&self::SetUpRegistrationOnIOThread, this, "/service_worker/fetch_event_rejected.js"));
diff --git a/content/browser/service_worker/service_worker_cache_writer.cc b/content/browser/service_worker/service_worker_cache_writer.cc index b3fabeb9..288e43d 100644 --- a/content/browser/service_worker/service_worker_cache_writer.cc +++ b/content/browser/service_worker/service_worker_cache_writer.cc
@@ -115,9 +115,9 @@ } ServiceWorkerCacheWriter::ServiceWorkerCacheWriter( - scoped_ptr<ServiceWorkerResponseReader> compare_reader, - scoped_ptr<ServiceWorkerResponseReader> copy_reader, - scoped_ptr<ServiceWorkerResponseWriter> writer) + std::unique_ptr<ServiceWorkerResponseReader> compare_reader, + std::unique_ptr<ServiceWorkerResponseReader> copy_reader, + std::unique_ptr<ServiceWorkerResponseWriter> writer) : state_(STATE_START), io_pending_(false), comparing_(false), @@ -428,7 +428,7 @@ // asynchronous completions. int ServiceWorkerCacheWriter::ReadInfoHelper( - const scoped_ptr<ServiceWorkerResponseReader>& reader, + const std::unique_ptr<ServiceWorkerResponseReader>& reader, HttpResponseInfoIOBuffer* buf) { net::CompletionCallback run_callback = base::Bind( &ServiceWorkerCacheWriter::AsyncDoLoop, weak_factory_.GetWeakPtr()); @@ -442,7 +442,7 @@ } int ServiceWorkerCacheWriter::ReadDataHelper( - const scoped_ptr<ServiceWorkerResponseReader>& reader, + const std::unique_ptr<ServiceWorkerResponseReader>& reader, net::IOBuffer* buf, int buf_len) { net::CompletionCallback run_callback = base::Bind( @@ -458,7 +458,7 @@ } int ServiceWorkerCacheWriter::WriteInfoHelper( - const scoped_ptr<ServiceWorkerResponseWriter>& writer, + const std::unique_ptr<ServiceWorkerResponseWriter>& writer, HttpResponseInfoIOBuffer* buf) { did_replace_ = true; net::CompletionCallback run_callback = base::Bind( @@ -473,7 +473,7 @@ } int ServiceWorkerCacheWriter::WriteDataHelper( - const scoped_ptr<ServiceWorkerResponseWriter>& writer, + const std::unique_ptr<ServiceWorkerResponseWriter>& writer, net::IOBuffer* buf, int buf_len) { net::CompletionCallback run_callback = base::Bind(
diff --git a/content/browser/service_worker/service_worker_cache_writer.h b/content/browser/service_worker/service_worker_cache_writer.h index 116eb58b..e32c24d 100644 --- a/content/browser/service_worker/service_worker_cache_writer.h +++ b/content/browser/service_worker/service_worker_cache_writer.h
@@ -8,10 +8,10 @@ #include <stddef.h> #include <map> +#include <memory> #include <set> #include "base/callback.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "content/common/content_export.h" #include "net/base/io_buffer.h" @@ -45,9 +45,9 @@ // unconditionally write back data supplied to |MaybeWriteHeaders| and // |MaybeWriteData|. ServiceWorkerCacheWriter( - scoped_ptr<ServiceWorkerResponseReader> compare_reader, - scoped_ptr<ServiceWorkerResponseReader> copy_reader, - scoped_ptr<ServiceWorkerResponseWriter> writer); + std::unique_ptr<ServiceWorkerResponseReader> compare_reader, + std::unique_ptr<ServiceWorkerResponseReader> copy_reader, + std::unique_ptr<ServiceWorkerResponseWriter> writer); ~ServiceWorkerCacheWriter(); @@ -167,16 +167,18 @@ // a) Return ERR_IO_PENDING, and schedule a callback to run the state // machine's Run() later, or // b) Return some other value and do not schedule a callback. - int ReadInfoHelper(const scoped_ptr<ServiceWorkerResponseReader>& reader, + int ReadInfoHelper(const std::unique_ptr<ServiceWorkerResponseReader>& reader, HttpResponseInfoIOBuffer* buf); - int ReadDataHelper(const scoped_ptr<ServiceWorkerResponseReader>& reader, + int ReadDataHelper(const std::unique_ptr<ServiceWorkerResponseReader>& reader, net::IOBuffer* buf, int buf_len); - int WriteInfoHelper(const scoped_ptr<ServiceWorkerResponseWriter>& writer, - HttpResponseInfoIOBuffer* buf); - int WriteDataHelper(const scoped_ptr<ServiceWorkerResponseWriter>& writer, - net::IOBuffer* buf, - int buf_len); + int WriteInfoHelper( + const std::unique_ptr<ServiceWorkerResponseWriter>& writer, + HttpResponseInfoIOBuffer* buf); + int WriteDataHelper( + const std::unique_ptr<ServiceWorkerResponseWriter>& writer, + net::IOBuffer* buf, + int buf_len); // Callback used by the above helpers for their IO operations. This is only // run when those IO operations complete asynchronously, in which case it @@ -210,9 +212,9 @@ size_t compare_offset_; - scoped_ptr<ServiceWorkerResponseReader> compare_reader_; - scoped_ptr<ServiceWorkerResponseReader> copy_reader_; - scoped_ptr<ServiceWorkerResponseWriter> writer_; + std::unique_ptr<ServiceWorkerResponseReader> compare_reader_; + std::unique_ptr<ServiceWorkerResponseReader> copy_reader_; + std::unique_ptr<ServiceWorkerResponseWriter> writer_; base::WeakPtrFactory<ServiceWorkerCacheWriter> weak_factory_; };
diff --git a/content/browser/service_worker/service_worker_cache_writer_unittest.cc b/content/browser/service_worker/service_worker_cache_writer_unittest.cc index 8c88982..d6f37306 100644 --- a/content/browser/service_worker/service_worker_cache_writer_unittest.cc +++ b/content/browser/service_worker/service_worker_cache_writer_unittest.cc
@@ -11,6 +11,7 @@ #include <string> #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "content/browser/service_worker/service_worker_disk_cache.h" #include "testing/gtest/include/gtest/gtest.h" @@ -323,7 +324,7 @@ ~ServiceWorkerCacheWriterTest() override {} MockServiceWorkerResponseReader* ExpectReader() { - scoped_ptr<MockServiceWorkerResponseReader> reader( + std::unique_ptr<MockServiceWorkerResponseReader> reader( new MockServiceWorkerResponseReader); MockServiceWorkerResponseReader* borrowed_reader = reader.get(); readers_.push_back(std::move(reader)); @@ -331,7 +332,7 @@ } MockServiceWorkerResponseWriter* ExpectWriter() { - scoped_ptr<MockServiceWorkerResponseWriter> writer( + std::unique_ptr<MockServiceWorkerResponseWriter> writer( new MockServiceWorkerResponseWriter); MockServiceWorkerResponseWriter* borrowed_writer = writer.get(); writers_.push_back(std::move(writer)); @@ -340,32 +341,34 @@ // This should be called after ExpectReader() and ExpectWriter(). void Initialize() { - scoped_ptr<ServiceWorkerResponseReader> compare_reader(CreateReader()); - scoped_ptr<ServiceWorkerResponseReader> copy_reader(CreateReader()); - scoped_ptr<ServiceWorkerResponseWriter> writer(CreateWriter()); + std::unique_ptr<ServiceWorkerResponseReader> compare_reader(CreateReader()); + std::unique_ptr<ServiceWorkerResponseReader> copy_reader(CreateReader()); + std::unique_ptr<ServiceWorkerResponseWriter> writer(CreateWriter()); cache_writer_.reset(new ServiceWorkerCacheWriter( std::move(compare_reader), std::move(copy_reader), std::move(writer))); } protected: - std::list<scoped_ptr<MockServiceWorkerResponseReader>> readers_; - std::list<scoped_ptr<MockServiceWorkerResponseWriter>> writers_; - scoped_ptr<ServiceWorkerCacheWriter> cache_writer_; + std::list<std::unique_ptr<MockServiceWorkerResponseReader>> readers_; + std::list<std::unique_ptr<MockServiceWorkerResponseWriter>> writers_; + std::unique_ptr<ServiceWorkerCacheWriter> cache_writer_; bool write_complete_ = false; net::Error last_error_; - scoped_ptr<ServiceWorkerResponseReader> CreateReader() { + std::unique_ptr<ServiceWorkerResponseReader> CreateReader() { if (readers_.empty()) - return make_scoped_ptr<ServiceWorkerResponseReader>(nullptr); - scoped_ptr<ServiceWorkerResponseReader> reader(std::move(readers_.front())); + return base::WrapUnique<ServiceWorkerResponseReader>(nullptr); + std::unique_ptr<ServiceWorkerResponseReader> reader( + std::move(readers_.front())); readers_.pop_front(); return reader; } - scoped_ptr<ServiceWorkerResponseWriter> CreateWriter() { + std::unique_ptr<ServiceWorkerResponseWriter> CreateWriter() { if (writers_.empty()) - return make_scoped_ptr<ServiceWorkerResponseWriter>(nullptr); - scoped_ptr<ServiceWorkerResponseWriter> writer(std::move(writers_.front())); + return base::WrapUnique<ServiceWorkerResponseWriter>(nullptr); + std::unique_ptr<ServiceWorkerResponseWriter> writer( + std::move(writers_.front())); writers_.pop_front(); return writer; }
diff --git a/content/browser/service_worker/service_worker_client_utils.cc b/content/browser/service_worker/service_worker_client_utils.cc index 93fe0f3..2c7c127 100644 --- a/content/browser/service_worker/service_worker_client_utils.cc +++ b/content/browser/service_worker/service_worker_client_utils.cc
@@ -7,6 +7,7 @@ #include <algorithm> #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "content/browser/frame_host/frame_tree_node.h" #include "content/browser/frame_host/render_frame_host_impl.h" #include "content/browser/service_worker/service_worker_context_core.h" @@ -34,7 +35,7 @@ using OpenURLCallback = base::Callback<void(int, int)>; using GetWindowClientsCallback = - base::Callback<void(scoped_ptr<ServiceWorkerClients>)>; + base::Callback<void(std::unique_ptr<ServiceWorkerClients>)>; // The OpenURLObserver class is a WebContentsObserver that will wait for a // WebContents to be initialized, run the |callback| passed to its constructor @@ -242,7 +243,7 @@ return; } - for (scoped_ptr<ServiceWorkerContextCore::ProviderHostIterator> it = + for (std::unique_ptr<ServiceWorkerContextCore::ProviderHostIterator> it = context->GetClientProviderHostIterator(origin); !it->IsAtEnd(); it->Advance()) { ServiceWorkerProviderHost* provider_host = it->GetProviderHost(); @@ -299,7 +300,7 @@ const GetWindowClientsCallback& callback) { DCHECK_CURRENTLY_ON(BrowserThread::UI); - scoped_ptr<ServiceWorkerClients> clients(new ServiceWorkerClients); + std::unique_ptr<ServiceWorkerClients> clients(new ServiceWorkerClients); for (const auto& it : clients_info) { ServiceWorkerClientInfo info = GetWindowClientInfoOnUI( base::get<0>(it), base::get<1>(it), base::get<2>(it)); @@ -360,7 +361,7 @@ void DidGetWindowClients(const base::WeakPtr<ServiceWorkerVersion>& controller, const ServiceWorkerClientQueryOptions& options, const ClientsCallback& callback, - scoped_ptr<ServiceWorkerClients> clients) { + std::unique_ptr<ServiceWorkerClients> clients) { DCHECK_CURRENTLY_ON(BrowserThread::IO); if (options.client_type == blink::WebServiceWorkerClientTypeAll) GetNonWindowClients(controller, options, clients.get()); @@ -388,7 +389,7 @@ if (clients_info.empty()) { DidGetWindowClients(controller, options, callback, - make_scoped_ptr(new ServiceWorkerClients)); + base::WrapUnique(new ServiceWorkerClients)); return; }
diff --git a/content/browser/service_worker/service_worker_context_core.cc b/content/browser/service_worker/service_worker_context_core.cc index 1bf5d3e..56bae6d 100644 --- a/content/browser/service_worker/service_worker_context_core.cc +++ b/content/browser/service_worker/service_worker_context_core.cc
@@ -14,6 +14,7 @@ #include "base/files/file_path.h" #include "base/location.h" #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/single_thread_task_runner.h" #include "base/strings/string_util.h" #include "base/thread_task_runner_handle.h" @@ -74,7 +75,7 @@ // Returns true if any of the frames specified by |frames| is a top-level frame. // |frames| is a vector of (render process id, frame id) pairs. bool FrameListContainsMainFrameOnUI( - scoped_ptr<std::vector<std::pair<int, int>>> frames) { + std::unique_ptr<std::vector<std::pair<int, int>>> frames) { DCHECK_CURRENTLY_ON(BrowserThread::UI); for (const auto& frame : *frames) { @@ -211,7 +212,7 @@ ServiceWorkerContextCore::ServiceWorkerContextCore( const base::FilePath& path, - scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager, + std::unique_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager, const scoped_refptr<base::SingleThreadTaskRunner>& disk_cache_thread, storage::QuotaManagerProxy* quota_manager_proxy, storage::SpecialStoragePolicy* special_storage_policy, @@ -275,7 +276,7 @@ } void ServiceWorkerContextCore::AddProviderHost( - scoped_ptr<ServiceWorkerProviderHost> host) { + std::unique_ptr<ServiceWorkerProviderHost> host) { ServiceWorkerProviderHost* host_ptr = host.release(); // we take ownership ProviderMap* map = GetProviderMapForProcess(host_ptr->process_id()); if (!map) { @@ -298,15 +299,15 @@ providers_->Remove(process_id); } -scoped_ptr<ServiceWorkerContextCore::ProviderHostIterator> +std::unique_ptr<ServiceWorkerContextCore::ProviderHostIterator> ServiceWorkerContextCore::GetProviderHostIterator() { - return make_scoped_ptr(new ProviderHostIterator( + return base::WrapUnique(new ProviderHostIterator( providers_.get(), ProviderHostIterator::ProviderHostPredicate())); } -scoped_ptr<ServiceWorkerContextCore::ProviderHostIterator> +std::unique_ptr<ServiceWorkerContextCore::ProviderHostIterator> ServiceWorkerContextCore::GetClientProviderHostIterator(const GURL& origin) { - return make_scoped_ptr(new ProviderHostIterator( + return base::WrapUnique(new ProviderHostIterator( providers_.get(), base::Bind(IsSameOriginClientProviderHost, origin))); } @@ -323,7 +324,7 @@ return; } - scoped_ptr<std::vector<std::pair<int, int>>> render_frames( + std::unique_ptr<std::vector<std::pair<int, int>>> render_frames( new std::vector<std::pair<int, int>>()); while (!provider_host_iterator.IsAtEnd()) { @@ -625,9 +626,9 @@ storage_->DeleteAndStartOver(callback); } -scoped_ptr<ServiceWorkerProviderHost> -ServiceWorkerContextCore::TransferProviderHostOut( - int process_id, int provider_id) { +std::unique_ptr<ServiceWorkerProviderHost> +ServiceWorkerContextCore::TransferProviderHostOut(int process_id, + int provider_id) { ProviderMap* map = GetProviderMapForProcess(process_id); ServiceWorkerProviderHost* transferee = map->Lookup(provider_id); ServiceWorkerProviderHost* replacement = @@ -639,12 +640,13 @@ transferee->dispatcher_host()); map->Replace(provider_id, replacement); transferee->PrepareForCrossSiteTransfer(); - return make_scoped_ptr(transferee); + return base::WrapUnique(transferee); } void ServiceWorkerContextCore::TransferProviderHostIn( - int new_process_id, int new_provider_id, - scoped_ptr<ServiceWorkerProviderHost> transferee) { + int new_process_id, + int new_provider_id, + std::unique_ptr<ServiceWorkerProviderHost> transferee) { ProviderMap* map = GetProviderMapForProcess(new_process_id); ServiceWorkerProviderHost* temp = map->Lookup(new_provider_id); if (!temp)
diff --git a/content/browser/service_worker/service_worker_context_core.h b/content/browser/service_worker/service_worker_context_core.h index 2551336..a4b994f 100644 --- a/content/browser/service_worker/service_worker_context_core.h +++ b/content/browser/service_worker/service_worker_context_core.h
@@ -8,6 +8,7 @@ #include <stdint.h> #include <map> +#include <memory> #include <string> #include <vector> @@ -15,7 +16,6 @@ #include "base/files/file_path.h" #include "base/id_map.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/observer_list_threadsafe.h" #include "content/browser/service_worker/service_worker_info.h" @@ -98,8 +98,8 @@ ProcessToProviderMap* map_; ProviderHostPredicate predicate_; - scoped_ptr<ProcessToProviderMap::iterator> process_iterator_; - scoped_ptr<ProviderMap::iterator> provider_host_iterator_; + std::unique_ptr<ProcessToProviderMap::iterator> process_iterator_; + std::unique_ptr<ProviderMap::iterator> provider_host_iterator_; DISALLOW_COPY_AND_ASSIGN(ProviderHostIterator); }; @@ -112,7 +112,8 @@ // be called on the thread which called AddObserver() of |observer_list|. ServiceWorkerContextCore( const base::FilePath& user_data_directory, - scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_runner_manager, + std::unique_ptr<ServiceWorkerDatabaseTaskManager> + database_task_runner_manager, const scoped_refptr<base::SingleThreadTaskRunner>& disk_cache_thread, storage::QuotaManagerProxy* quota_manager_proxy, storage::SpecialStoragePolicy* special_storage_policy, @@ -155,15 +156,16 @@ // The context class owns the set of ProviderHosts. ServiceWorkerProviderHost* GetProviderHost(int process_id, int provider_id); - void AddProviderHost(scoped_ptr<ServiceWorkerProviderHost> provider_host); + void AddProviderHost( + std::unique_ptr<ServiceWorkerProviderHost> provider_host); void RemoveProviderHost(int process_id, int provider_id); void RemoveAllProviderHostsForProcess(int process_id); - scoped_ptr<ProviderHostIterator> GetProviderHostIterator(); + std::unique_ptr<ProviderHostIterator> GetProviderHostIterator(); // Returns a ProviderHost iterator for all ServiceWorker clients for // the |origin|. This only returns ProviderHosts that are of CONTROLLEE // and belong to the |origin|. - scoped_ptr<ProviderHostIterator> GetClientProviderHostIterator( + std::unique_ptr<ProviderHostIterator> GetClientProviderHostIterator( const GURL& origin); // Runs the callback with true if there is a ProviderHost for |origin| of type @@ -261,13 +263,13 @@ void DeleteAndStartOver(const StatusCallback& callback); // Methods to support cross site navigations. - scoped_ptr<ServiceWorkerProviderHost> TransferProviderHostOut( + std::unique_ptr<ServiceWorkerProviderHost> TransferProviderHostOut( int process_id, int provider_id); void TransferProviderHostIn( int new_process_id, int new_host_id, - scoped_ptr<ServiceWorkerProviderHost> provider_host); + std::unique_ptr<ServiceWorkerProviderHost> provider_host); void ClearAllServiceWorkersForTest(const base::Closure& callback); @@ -332,11 +334,11 @@ // because the Wrapper::Shutdown call that hops threads to destroy |this| uses // Bind() to hold a reference to |wrapper_| until |this| is fully destroyed. ServiceWorkerContextWrapper* wrapper_; - scoped_ptr<ProcessToProviderMap> providers_; - scoped_ptr<ProviderByClientUUIDMap> provider_by_uuid_; - scoped_ptr<ServiceWorkerStorage> storage_; + std::unique_ptr<ProcessToProviderMap> providers_; + std::unique_ptr<ProviderByClientUUIDMap> provider_by_uuid_; + std::unique_ptr<ServiceWorkerStorage> storage_; scoped_refptr<EmbeddedWorkerRegistry> embedded_worker_registry_; - scoped_ptr<ServiceWorkerJobCoordinator> job_coordinator_; + std::unique_ptr<ServiceWorkerJobCoordinator> job_coordinator_; std::map<int64_t, ServiceWorkerRegistration*> live_registrations_; std::map<int64_t, ServiceWorkerVersion*> live_versions_; std::map<int64_t, scoped_refptr<ServiceWorkerVersion>> protected_versions_;
diff --git a/content/browser/service_worker/service_worker_context_request_handler_unittest.cc b/content/browser/service_worker/service_worker_context_request_handler_unittest.cc index 260fd9d..22296bc 100644 --- a/content/browser/service_worker/service_worker_context_request_handler_unittest.cc +++ b/content/browser/service_worker/service_worker_context_request_handler_unittest.cc
@@ -48,10 +48,12 @@ registration_.get(), script_url_, 1L, context()->AsWeakPtr()); // An empty host. - scoped_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( - helper_->mock_render_process_id(), - MSG_ROUTING_NONE /* render_frame_id */, 1 /* provider_id */, - SERVICE_WORKER_PROVIDER_FOR_WINDOW, context()->AsWeakPtr(), nullptr)); + std::unique_ptr<ServiceWorkerProviderHost> host( + new ServiceWorkerProviderHost(helper_->mock_render_process_id(), + MSG_ROUTING_NONE /* render_frame_id */, + 1 /* provider_id */, + SERVICE_WORKER_PROVIDER_FOR_WINDOW, + context()->AsWeakPtr(), nullptr)); provider_host_ = host->AsWeakPtr(); context()->AddProviderHost(std::move(host)); @@ -69,7 +71,7 @@ protected: TestBrowserThreadBundle browser_thread_bundle_; - scoped_ptr<EmbeddedWorkerTestHelper> helper_; + std::unique_ptr<EmbeddedWorkerTestHelper> helper_; scoped_refptr<ServiceWorkerRegistration> registration_; scoped_refptr<ServiceWorkerVersion> version_; base::WeakPtr<ServiceWorkerProviderHost> provider_host_; @@ -88,15 +90,14 @@ // Conduct a resource fetch for the main script. const GURL kScriptUrl("http://host/script.js"); - scoped_ptr<net::URLRequest> request = url_request_context_.CreateRequest( + std::unique_ptr<net::URLRequest> request = url_request_context_.CreateRequest( kScriptUrl, net::DEFAULT_PRIORITY, &url_request_delegate_); - scoped_ptr<ServiceWorkerContextRequestHandler> handler( + std::unique_ptr<ServiceWorkerContextRequestHandler> handler( new ServiceWorkerContextRequestHandler( - context()->AsWeakPtr(), - provider_host_, + context()->AsWeakPtr(), provider_host_, base::WeakPtr<storage::BlobStorageContext>(), RESOURCE_TYPE_SERVICE_WORKER)); - scoped_ptr<net::URLRequestJob> job( + std::unique_ptr<net::URLRequestJob> job( handler->MaybeCreateJob(request.get(), nullptr, nullptr)); ASSERT_TRUE(job.get()); ServiceWorkerWriteToCacheJob* sw_job = @@ -116,15 +117,14 @@ // Conduct a resource fetch for the main script. const GURL kScriptUrl("http://host/script.js"); - scoped_ptr<net::URLRequest> request = url_request_context_.CreateRequest( + std::unique_ptr<net::URLRequest> request = url_request_context_.CreateRequest( kScriptUrl, net::DEFAULT_PRIORITY, &url_request_delegate_); - scoped_ptr<ServiceWorkerContextRequestHandler> handler( + std::unique_ptr<ServiceWorkerContextRequestHandler> handler( new ServiceWorkerContextRequestHandler( - context()->AsWeakPtr(), - provider_host_, + context()->AsWeakPtr(), provider_host_, base::WeakPtr<storage::BlobStorageContext>(), RESOURCE_TYPE_SERVICE_WORKER)); - scoped_ptr<net::URLRequestJob> job( + std::unique_ptr<net::URLRequestJob> job( handler->MaybeCreateJob(request.get(), nullptr, nullptr)); ASSERT_TRUE(job.get()); ServiceWorkerWriteToCacheJob* sw_job = @@ -144,14 +144,14 @@ // Conduct a resource fetch for the main script. const GURL kScriptUrl("http://host/script.js"); - scoped_ptr<net::URLRequest> request = url_request_context_.CreateRequest( + std::unique_ptr<net::URLRequest> request = url_request_context_.CreateRequest( kScriptUrl, net::DEFAULT_PRIORITY, &url_request_delegate_); - scoped_ptr<ServiceWorkerContextRequestHandler> handler( + std::unique_ptr<ServiceWorkerContextRequestHandler> handler( new ServiceWorkerContextRequestHandler( context()->AsWeakPtr(), provider_host_, base::WeakPtr<storage::BlobStorageContext>(), RESOURCE_TYPE_SERVICE_WORKER)); - scoped_ptr<net::URLRequestJob> job( + std::unique_ptr<net::URLRequestJob> job( handler->MaybeCreateJob(request.get(), nullptr, nullptr)); ASSERT_TRUE(job.get()); ServiceWorkerWriteToCacheJob* sw_job = @@ -168,14 +168,14 @@ // Conduct a resource fetch for the main script. const GURL kScriptUrl("http://host/script.js"); - scoped_ptr<net::URLRequest> request = url_request_context_.CreateRequest( + std::unique_ptr<net::URLRequest> request = url_request_context_.CreateRequest( kScriptUrl, net::DEFAULT_PRIORITY, &url_request_delegate_); - scoped_ptr<ServiceWorkerContextRequestHandler> handler( + std::unique_ptr<ServiceWorkerContextRequestHandler> handler( new ServiceWorkerContextRequestHandler( context()->AsWeakPtr(), provider_host_, base::WeakPtr<storage::BlobStorageContext>(), RESOURCE_TYPE_SERVICE_WORKER)); - scoped_ptr<net::URLRequestJob> job( + std::unique_ptr<net::URLRequestJob> job( handler->MaybeCreateJob(request.get(), nullptr, nullptr)); ASSERT_TRUE(job.get()); ServiceWorkerWriteToCacheJob* sw_job =
diff --git a/content/browser/service_worker/service_worker_context_unittest.cc b/content/browser/service_worker/service_worker_context_unittest.cc index a9c89847..b1f9f95 100644 --- a/content/browser/service_worker/service_worker_context_unittest.cc +++ b/content/browser/service_worker/service_worker_context_unittest.cc
@@ -8,6 +8,7 @@ #include "base/files/scoped_temp_dir.h" #include "base/logging.h" +#include "base/memory/ptr_util.h" #include "base/message_loop/message_loop.h" #include "content/browser/browser_thread_impl.h" #include "content/browser/service_worker/embedded_worker_registry.h" @@ -157,7 +158,7 @@ protected: TestBrowserThreadBundle browser_thread_bundle_; - scoped_ptr<EmbeddedWorkerTestHelper> helper_; + std::unique_ptr<EmbeddedWorkerTestHelper> helper_; std::vector<NotificationLog> notifications_; }; @@ -553,10 +554,10 @@ SERVICE_WORKER_PROVIDER_FOR_CONTROLLER, context()->AsWeakPtr(), nullptr)); host4->SetDocumentUrl(kOrigin2); - context()->AddProviderHost(make_scoped_ptr(host1)); - context()->AddProviderHost(make_scoped_ptr(host2)); - context()->AddProviderHost(make_scoped_ptr(host3)); - context()->AddProviderHost(make_scoped_ptr(host4)); + context()->AddProviderHost(base::WrapUnique(host1)); + context()->AddProviderHost(base::WrapUnique(host2)); + context()->AddProviderHost(base::WrapUnique(host3)); + context()->AddProviderHost(base::WrapUnique(host4)); // Iterate over all provider hosts. std::set<ServiceWorkerProviderHost*> results;
diff --git a/content/browser/service_worker/service_worker_context_watcher.cc b/content/browser/service_worker/service_worker_context_watcher.cc index 55ed1ec..d599d3d 100644 --- a/content/browser/service_worker/service_worker_context_watcher.cc +++ b/content/browser/service_worker/service_worker_context_watcher.cc
@@ -66,7 +66,8 @@ DCHECK_CURRENTLY_ON(BrowserThread::IO); context_->AddObserver(this); - base::ScopedPtrHashMap<int64_t, scoped_ptr<ServiceWorkerRegistrationInfo>> + base::ScopedPtrHashMap<int64_t, + std::unique_ptr<ServiceWorkerRegistrationInfo>> registration_info_map; for (const auto& registration : stored_registrations) StoreRegistrationInfo(registration, ®istration_info_map); @@ -108,13 +109,14 @@ void ServiceWorkerContextWatcher::StoreRegistrationInfo( const ServiceWorkerRegistrationInfo& registration_info, - base::ScopedPtrHashMap<int64_t, scoped_ptr<ServiceWorkerRegistrationInfo>>* + base::ScopedPtrHashMap<int64_t, + std::unique_ptr<ServiceWorkerRegistrationInfo>>* info_map) { DCHECK_CURRENTLY_ON(BrowserThread::IO); if (registration_info.registration_id == kInvalidServiceWorkerRegistrationId) return; info_map->set(registration_info.registration_id, - scoped_ptr<ServiceWorkerRegistrationInfo>( + std::unique_ptr<ServiceWorkerRegistrationInfo>( new ServiceWorkerRegistrationInfo(registration_info))); StoreVersionInfo(registration_info.active_version); StoreVersionInfo(registration_info.waiting_version); @@ -127,7 +129,7 @@ if (version_info.version_id == kInvalidServiceWorkerVersionId) return; version_info_map_.set(version_info.version_id, - scoped_ptr<ServiceWorkerVersionInfo>( + std::unique_ptr<ServiceWorkerVersionInfo>( new ServiceWorkerVersionInfo(version_info))); } @@ -172,7 +174,8 @@ return; } - scoped_ptr<ServiceWorkerVersionInfo> version(new ServiceWorkerVersionInfo()); + std::unique_ptr<ServiceWorkerVersionInfo> version( + new ServiceWorkerVersionInfo()); version->version_id = version_id; version->registration_id = registration_id; version->script_url = script_url;
diff --git a/content/browser/service_worker/service_worker_context_watcher.h b/content/browser/service_worker/service_worker_context_watcher.h index 0ba5a53..aae387d 100644 --- a/content/browser/service_worker/service_worker_context_watcher.h +++ b/content/browser/service_worker/service_worker_context_watcher.h
@@ -54,7 +54,7 @@ void StoreRegistrationInfo( const ServiceWorkerRegistrationInfo& registration, base::ScopedPtrHashMap<int64_t, - scoped_ptr<ServiceWorkerRegistrationInfo>>* + std::unique_ptr<ServiceWorkerRegistrationInfo>>* info_map); void StoreVersionInfo(const ServiceWorkerVersionInfo& version); @@ -100,7 +100,7 @@ void OnRegistrationDeleted(int64_t registration_id, const GURL& pattern) override; - base::ScopedPtrHashMap<int64_t, scoped_ptr<ServiceWorkerVersionInfo>> + base::ScopedPtrHashMap<int64_t, std::unique_ptr<ServiceWorkerVersionInfo>> version_info_map_; scoped_refptr<ServiceWorkerContextWrapper> context_; WorkerRegistrationUpdatedCallback registration_callback_;
diff --git a/content/browser/service_worker/service_worker_context_wrapper.cc b/content/browser/service_worker/service_worker_context_wrapper.cc index d513a693..c326aa5d 100644 --- a/content/browser/service_worker/service_worker_context_wrapper.cc +++ b/content/browser/service_worker/service_worker_context_wrapper.cc
@@ -114,7 +114,7 @@ is_incognito_ = user_data_directory.empty(); base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); - scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager( + std::unique_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager( new ServiceWorkerDatabaseTaskManagerImpl(pool)); scoped_refptr<base::SingleThreadTaskRunner> disk_cache_thread = BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE); @@ -666,7 +666,7 @@ void ServiceWorkerContextWrapper::InitInternal( const base::FilePath& user_data_directory, - scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager, + std::unique_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager, const scoped_refptr<base::SingleThreadTaskRunner>& disk_cache_thread, storage::QuotaManagerProxy* quota_manager_proxy, storage::SpecialStoragePolicy* special_storage_policy) {
diff --git a/content/browser/service_worker/service_worker_context_wrapper.h b/content/browser/service_worker/service_worker_context_wrapper.h index 4009d3ce..fec09d0 100644 --- a/content/browser/service_worker/service_worker_context_wrapper.h +++ b/content/browser/service_worker/service_worker_context_wrapper.h
@@ -7,13 +7,13 @@ #include <stdint.h> +#include <memory> #include <string> #include <vector> #include "base/files/file_path.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/service_worker/service_worker_context_core.h" #include "content/common/content_export.h" #include "content/public/browser/service_worker_context.h" @@ -200,7 +200,7 @@ void InitInternal( const base::FilePath& user_data_directory, - scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager, + std::unique_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager, const scoped_refptr<base::SingleThreadTaskRunner>& disk_cache_thread, storage::QuotaManagerProxy* quota_manager_proxy, storage::SpecialStoragePolicy* special_storage_policy); @@ -235,9 +235,9 @@ const scoped_refptr<base::ObserverListThreadSafe< ServiceWorkerContextObserver>> observer_list_; - const scoped_ptr<ServiceWorkerProcessManager> process_manager_; + const std::unique_ptr<ServiceWorkerProcessManager> process_manager_; // Cleared in ShutdownOnIO(): - scoped_ptr<ServiceWorkerContextCore> context_core_; + std::unique_ptr<ServiceWorkerContextCore> context_core_; // Initialized in Init(); true if the user data directory is empty. bool is_incognito_;
diff --git a/content/browser/service_worker/service_worker_controllee_request_handler.cc b/content/browser/service_worker/service_worker_controllee_request_handler.cc index 88cc1b9..7708f7bd 100644 --- a/content/browser/service_worker/service_worker_controllee_request_handler.cc +++ b/content/browser/service_worker/service_worker_controllee_request_handler.cc
@@ -4,9 +4,9 @@ #include "content/browser/service_worker/service_worker_controllee_request_handler.h" +#include <memory> #include <string> -#include "base/memory/scoped_ptr.h" #include "base/trace_event/trace_event.h" #include "content/browser/service_worker/service_worker_context_core.h" #include "content/browser/service_worker/service_worker_metrics.h" @@ -100,11 +100,13 @@ } // It's for original request (A) or redirect case (B-a or B-b). - scoped_ptr<ServiceWorkerURLRequestJob> job(new ServiceWorkerURLRequestJob( - request, network_delegate, provider_host_->client_uuid(), - blob_storage_context_, resource_context, request_mode_, credentials_mode_, - redirect_mode_, resource_type_, request_context_type_, frame_type_, body_, - ServiceWorkerFetchType::FETCH, this)); + std::unique_ptr<ServiceWorkerURLRequestJob> job( + new ServiceWorkerURLRequestJob( + request, network_delegate, provider_host_->client_uuid(), + blob_storage_context_, resource_context, request_mode_, + credentials_mode_, redirect_mode_, resource_type_, + request_context_type_, frame_type_, body_, + ServiceWorkerFetchType::FETCH, this)); job_ = job->GetWeakPtr(); resource_context_ = resource_context;
diff --git a/content/browser/service_worker/service_worker_controllee_request_handler_unittest.cc b/content/browser/service_worker/service_worker_controllee_request_handler_unittest.cc index dd522e0..3733015 100644 --- a/content/browser/service_worker/service_worker_controllee_request_handler_unittest.cc +++ b/content/browser/service_worker/service_worker_controllee_request_handler_unittest.cc
@@ -79,9 +79,11 @@ version_->script_cache_map()->SetResources(records); // An empty host. - scoped_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( - helper_->mock_render_process_id(), MSG_ROUTING_NONE, kMockProviderId, - SERVICE_WORKER_PROVIDER_FOR_WINDOW, context()->AsWeakPtr(), NULL)); + std::unique_ptr<ServiceWorkerProviderHost> host( + new ServiceWorkerProviderHost(helper_->mock_render_process_id(), + MSG_ROUTING_NONE, kMockProviderId, + SERVICE_WORKER_PROVIDER_FOR_WINDOW, + context()->AsWeakPtr(), NULL)); provider_host_ = host->AsWeakPtr(); context()->AddProviderHost(std::move(host)); @@ -99,7 +101,7 @@ protected: TestBrowserThreadBundle browser_thread_bundle_; - scoped_ptr<EmbeddedWorkerTestHelper> helper_; + std::unique_ptr<EmbeddedWorkerTestHelper> helper_; scoped_refptr<ServiceWorkerRegistration> registration_; scoped_refptr<ServiceWorkerVersion> version_; base::WeakPtr<ServiceWorkerProviderHost> provider_host_; @@ -138,9 +140,9 @@ // Conduct a main resource load. const GURL kDocUrl("http://host/scope/doc"); - scoped_ptr<net::URLRequest> request = url_request_context_.CreateRequest( + std::unique_ptr<net::URLRequest> request = url_request_context_.CreateRequest( kDocUrl, net::DEFAULT_PRIORITY, &url_request_delegate_); - scoped_ptr<ServiceWorkerControlleeRequestHandler> handler( + std::unique_ptr<ServiceWorkerControlleeRequestHandler> handler( new ServiceWorkerControlleeRequestHandler( context()->AsWeakPtr(), provider_host_, base::WeakPtr<storage::BlobStorageContext>(), @@ -148,7 +150,7 @@ FetchRedirectMode::FOLLOW_MODE, RESOURCE_TYPE_MAIN_FRAME, REQUEST_CONTEXT_TYPE_HYPERLINK, REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL, scoped_refptr<ResourceRequestBody>())); - scoped_ptr<net::URLRequestJob> job( + std::unique_ptr<net::URLRequestJob> job( handler->MaybeCreateJob(request.get(), nullptr, &mock_resource_context_)); ServiceWorkerURLRequestJob* sw_job = static_cast<ServiceWorkerURLRequestJob*>(job.get()); @@ -178,9 +180,9 @@ // Conduct a main resource load. const GURL kDocUrl("http://host/scope/doc"); - scoped_ptr<net::URLRequest> request = url_request_context_.CreateRequest( + std::unique_ptr<net::URLRequest> request = url_request_context_.CreateRequest( kDocUrl, net::DEFAULT_PRIORITY, &url_request_delegate_); - scoped_ptr<ServiceWorkerControlleeRequestHandler> handler( + std::unique_ptr<ServiceWorkerControlleeRequestHandler> handler( new ServiceWorkerControlleeRequestHandler( context()->AsWeakPtr(), provider_host_, base::WeakPtr<storage::BlobStorageContext>(), @@ -188,7 +190,7 @@ FetchRedirectMode::FOLLOW_MODE, RESOURCE_TYPE_MAIN_FRAME, REQUEST_CONTEXT_TYPE_HYPERLINK, REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL, scoped_refptr<ResourceRequestBody>())); - scoped_ptr<net::URLRequestJob> job( + std::unique_ptr<net::URLRequestJob> job( handler->MaybeCreateJob(request.get(), nullptr, &mock_resource_context_)); ServiceWorkerURLRequestJob* sw_job = static_cast<ServiceWorkerURLRequestJob*>(job.get()); @@ -219,9 +221,9 @@ // Conduct a main resource load. const GURL kDocUrl("http://host/scope/doc"); - scoped_ptr<net::URLRequest> request = url_request_context_.CreateRequest( + std::unique_ptr<net::URLRequest> request = url_request_context_.CreateRequest( kDocUrl, net::DEFAULT_PRIORITY, &url_request_delegate_); - scoped_ptr<ServiceWorkerControlleeRequestHandler> handler( + std::unique_ptr<ServiceWorkerControlleeRequestHandler> handler( new ServiceWorkerControlleeRequestHandler( context()->AsWeakPtr(), provider_host_, base::WeakPtr<storage::BlobStorageContext>(), @@ -229,7 +231,7 @@ FetchRedirectMode::FOLLOW_MODE, RESOURCE_TYPE_MAIN_FRAME, REQUEST_CONTEXT_TYPE_HYPERLINK, REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL, scoped_refptr<ResourceRequestBody>())); - scoped_ptr<net::URLRequestJob> job( + std::unique_ptr<net::URLRequestJob> job( handler->MaybeCreateJob(request.get(), nullptr, &mock_resource_context_)); base::RunLoop().RunUntilIdle(); @@ -259,9 +261,9 @@ // Conduct a main resource load. const GURL kDocUrl("http://host/scope/doc"); - scoped_ptr<net::URLRequest> request = url_request_context_.CreateRequest( + std::unique_ptr<net::URLRequest> request = url_request_context_.CreateRequest( kDocUrl, net::DEFAULT_PRIORITY, &url_request_delegate_); - scoped_ptr<ServiceWorkerControlleeRequestHandler> handler( + std::unique_ptr<ServiceWorkerControlleeRequestHandler> handler( new ServiceWorkerControlleeRequestHandler( context()->AsWeakPtr(), provider_host_, base::WeakPtr<storage::BlobStorageContext>(), @@ -269,7 +271,7 @@ FetchRedirectMode::FOLLOW_MODE, RESOURCE_TYPE_MAIN_FRAME, REQUEST_CONTEXT_TYPE_HYPERLINK, REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL, scoped_refptr<ResourceRequestBody>())); - scoped_ptr<net::URLRequestJob> job( + std::unique_ptr<net::URLRequestJob> job( handler->MaybeCreateJob(request.get(), nullptr, &mock_resource_context_)); ServiceWorkerURLRequestJob* sw_job = static_cast<ServiceWorkerURLRequestJob*>(job.get());
diff --git a/content/browser/service_worker/service_worker_database.cc b/content/browser/service_worker/service_worker_database.cc index 5254e87..e057c99 100644 --- a/content/browser/service_worker/service_worker_database.cc +++ b/content/browser/service_worker/service_worker_database.cc
@@ -351,7 +351,8 @@ return status; { - scoped_ptr<leveldb::Iterator> itr(db_->NewIterator(leveldb::ReadOptions())); + std::unique_ptr<leveldb::Iterator> itr( + db_->NewIterator(leveldb::ReadOptions())); for (itr->Seek(kUniqueOriginKey); itr->Valid(); itr->Next()) { status = LevelDBStatusToStatus(itr->status()); if (status != STATUS_OK) { @@ -391,7 +392,8 @@ return status; { - scoped_ptr<leveldb::Iterator> itr(db_->NewIterator(leveldb::ReadOptions())); + std::unique_ptr<leveldb::Iterator> itr( + db_->NewIterator(leveldb::ReadOptions())); for (itr->Seek(kForeignFetchOriginKey); itr->Valid(); itr->Next()) { status = LevelDBStatusToStatus(itr->status()); if (status != STATUS_OK) { @@ -434,7 +436,8 @@ std::string prefix = CreateRegistrationKeyPrefix(origin); { - scoped_ptr<leveldb::Iterator> itr(db_->NewIterator(leveldb::ReadOptions())); + std::unique_ptr<leveldb::Iterator> itr( + db_->NewIterator(leveldb::ReadOptions())); for (itr->Seek(prefix); itr->Valid(); itr->Next()) { status = LevelDBStatusToStatus(itr->status()); if (status != STATUS_OK) { @@ -486,7 +489,8 @@ return status; { - scoped_ptr<leveldb::Iterator> itr(db_->NewIterator(leveldb::ReadOptions())); + std::unique_ptr<leveldb::Iterator> itr( + db_->NewIterator(leveldb::ReadOptions())); for (itr->Seek(kRegKeyPrefix); itr->Valid(); itr->Next()) { status = LevelDBStatusToStatus(itr->status()); if (status != STATUS_OK) { @@ -881,7 +885,8 @@ std::string key_prefix = CreateHasUserDataKeyPrefix(user_data_name); { - scoped_ptr<leveldb::Iterator> itr(db_->NewIterator(leveldb::ReadOptions())); + std::unique_ptr<leveldb::Iterator> itr( + db_->NewIterator(leveldb::ReadOptions())); for (itr->Seek(key_prefix); itr->Valid(); itr->Next()) { status = LevelDBStatusToStatus(itr->status()); if (status != STATUS_OK) { @@ -1256,7 +1261,8 @@ const std::string prefix = CreateResourceRecordKeyPrefix(version_id); { - scoped_ptr<leveldb::Iterator> itr(db_->NewIterator(leveldb::ReadOptions())); + std::unique_ptr<leveldb::Iterator> itr( + db_->NewIterator(leveldb::ReadOptions())); for (itr->Seek(prefix); itr->Valid(); itr->Next()) { Status status = LevelDBStatusToStatus(itr->status()); if (status != STATUS_OK) { @@ -1344,7 +1350,8 @@ const std::string prefix = CreateResourceRecordKeyPrefix(version_id); { - scoped_ptr<leveldb::Iterator> itr(db_->NewIterator(leveldb::ReadOptions())); + std::unique_ptr<leveldb::Iterator> itr( + db_->NewIterator(leveldb::ReadOptions())); for (itr->Seek(prefix); itr->Valid(); itr->Next()) { status = LevelDBStatusToStatus(itr->status()); if (status != STATUS_OK) @@ -1388,7 +1395,8 @@ return status; { - scoped_ptr<leveldb::Iterator> itr(db_->NewIterator(leveldb::ReadOptions())); + std::unique_ptr<leveldb::Iterator> itr( + db_->NewIterator(leveldb::ReadOptions())); for (itr->Seek(id_key_prefix); itr->Valid(); itr->Next()) { status = LevelDBStatusToStatus(itr->status()); if (status != STATUS_OK) { @@ -1466,7 +1474,8 @@ const std::string prefix = CreateUserDataKeyPrefix(registration_id); { - scoped_ptr<leveldb::Iterator> itr(db_->NewIterator(leveldb::ReadOptions())); + std::unique_ptr<leveldb::Iterator> itr( + db_->NewIterator(leveldb::ReadOptions())); for (itr->Seek(prefix); itr->Valid(); itr->Next()) { status = LevelDBStatusToStatus(itr->status()); if (status != STATUS_OK)
diff --git a/content/browser/service_worker/service_worker_database.h b/content/browser/service_worker/service_worker_database.h index a32e60af..0ef955d 100644 --- a/content/browser/service_worker/service_worker_database.h +++ b/content/browser/service_worker/service_worker_database.h
@@ -8,6 +8,7 @@ #include <stdint.h> #include <map> +#include <memory> #include <set> #include <string> #include <vector> @@ -15,7 +16,6 @@ #include "base/files/file_path.h" #include "base/gtest_prod_util.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/sequence_checker.h" #include "base/time/time.h" #include "content/common/content_export.h" @@ -347,8 +347,8 @@ Status status); const base::FilePath path_; - scoped_ptr<leveldb::Env> env_; - scoped_ptr<leveldb::DB> db_; + std::unique_ptr<leveldb::Env> env_; + std::unique_ptr<leveldb::DB> db_; int64_t next_avail_registration_id_; int64_t next_avail_resource_id_;
diff --git a/content/browser/service_worker/service_worker_database_task_manager.cc b/content/browser/service_worker/service_worker_database_task_manager.cc index be7f4d0e..804941b 100644 --- a/content/browser/service_worker/service_worker_database_task_manager.cc +++ b/content/browser/service_worker/service_worker_database_task_manager.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 "base/sequenced_task_runner.h" -#include "base/threading/sequenced_worker_pool.h" #include "content/browser/service_worker/service_worker_database_task_manager.h" +#include "base/memory/ptr_util.h" +#include "base/sequenced_task_runner.h" + namespace content { ServiceWorkerDatabaseTaskManagerImpl::ServiceWorkerDatabaseTaskManagerImpl( @@ -20,9 +21,9 @@ ServiceWorkerDatabaseTaskManagerImpl::~ServiceWorkerDatabaseTaskManagerImpl() { } -scoped_ptr<ServiceWorkerDatabaseTaskManager> +std::unique_ptr<ServiceWorkerDatabaseTaskManager> ServiceWorkerDatabaseTaskManagerImpl::Clone() { - return make_scoped_ptr(new ServiceWorkerDatabaseTaskManagerImpl( + return base::WrapUnique(new ServiceWorkerDatabaseTaskManagerImpl( task_runner_, shutdown_blocking_task_runner_)); } @@ -52,9 +53,9 @@ MockServiceWorkerDatabaseTaskManager::~MockServiceWorkerDatabaseTaskManager() { } -scoped_ptr<ServiceWorkerDatabaseTaskManager> +std::unique_ptr<ServiceWorkerDatabaseTaskManager> MockServiceWorkerDatabaseTaskManager::Clone() { - return make_scoped_ptr( + return base::WrapUnique( new MockServiceWorkerDatabaseTaskManager(task_runner_)); }
diff --git a/content/browser/service_worker/service_worker_database_task_manager.h b/content/browser/service_worker/service_worker_database_task_manager.h index f13472a5..5f2e816 100644 --- a/content/browser/service_worker/service_worker_database_task_manager.h +++ b/content/browser/service_worker/service_worker_database_task_manager.h
@@ -5,9 +5,11 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_TASK_MANAGER_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_TASK_MANAGER_H_ +#include <memory> + #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" +#include "base/threading/sequenced_worker_pool.h" #include "content/common/content_export.h" namespace base { @@ -23,8 +25,8 @@ // behaviors. class ServiceWorkerDatabaseTaskManager { public: - virtual ~ServiceWorkerDatabaseTaskManager(){}; - virtual scoped_ptr<ServiceWorkerDatabaseTaskManager> Clone() = 0; + virtual ~ServiceWorkerDatabaseTaskManager() {} + virtual std::unique_ptr<ServiceWorkerDatabaseTaskManager> Clone() = 0; virtual base::SequencedTaskRunner* GetTaskRunner() = 0; virtual base::SequencedTaskRunner* GetShutdownBlockingTaskRunner() = 0; }; @@ -37,7 +39,7 @@ ~ServiceWorkerDatabaseTaskManagerImpl() override; protected: - scoped_ptr<ServiceWorkerDatabaseTaskManager> Clone() override; + std::unique_ptr<ServiceWorkerDatabaseTaskManager> Clone() override; base::SequencedTaskRunner* GetTaskRunner() override; base::SequencedTaskRunner* GetShutdownBlockingTaskRunner() override; @@ -62,7 +64,7 @@ ~MockServiceWorkerDatabaseTaskManager() override; protected: - scoped_ptr<ServiceWorkerDatabaseTaskManager> Clone() override; + std::unique_ptr<ServiceWorkerDatabaseTaskManager> Clone() override; base::SequencedTaskRunner* GetTaskRunner() override; base::SequencedTaskRunner* GetShutdownBlockingTaskRunner() override;
diff --git a/content/browser/service_worker/service_worker_database_unittest.cc b/content/browser/service_worker/service_worker_database_unittest.cc index 9cdbae6..e7f5197 100644 --- a/content/browser/service_worker/service_worker_database_unittest.cc +++ b/content/browser/service_worker/service_worker_database_unittest.cc
@@ -89,7 +89,7 @@ TEST(ServiceWorkerDatabaseTest, OpenDatabase) { base::ScopedTempDir database_dir; ASSERT_TRUE(database_dir.CreateUniqueTempDir()); - scoped_ptr<ServiceWorkerDatabase> database( + std::unique_ptr<ServiceWorkerDatabase> database( CreateDatabase(database_dir.path())); // Should be false because the database does not exist at the path. @@ -103,7 +103,7 @@ } TEST(ServiceWorkerDatabaseTest, OpenDatabase_InMemory) { - scoped_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); + std::unique_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); // Should be false because the database does not exist in memory. EXPECT_EQ(ServiceWorkerDatabase::STATUS_ERROR_NOT_FOUND, @@ -119,7 +119,7 @@ TEST(ServiceWorkerDatabaseTest, DatabaseVersion_ValidSchemaVersion) { GURL origin("http://example.com"); - scoped_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); + std::unique_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK, database->LazyOpen(true)); // Opening a new database does not write anything, so its schema version @@ -149,7 +149,7 @@ TEST(ServiceWorkerDatabaseTest, DatabaseVersion_ObsoleteSchemaVersion) { base::ScopedTempDir database_dir; ASSERT_TRUE(database_dir.CreateUniqueTempDir()); - scoped_ptr<ServiceWorkerDatabase> database( + std::unique_ptr<ServiceWorkerDatabase> database( CreateDatabase(database_dir.path())); EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK, database->LazyOpen(true)); @@ -189,7 +189,7 @@ TEST(ServiceWorkerDatabaseTest, DatabaseVersion_CorruptedSchemaVersion) { base::ScopedTempDir database_dir; ASSERT_TRUE(database_dir.CreateUniqueTempDir()); - scoped_ptr<ServiceWorkerDatabase> database( + std::unique_ptr<ServiceWorkerDatabase> database( CreateDatabase(database_dir.path())); EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK, database->LazyOpen(true)); @@ -228,7 +228,7 @@ TEST(ServiceWorkerDatabaseTest, GetNextAvailableIds) { base::ScopedTempDir database_dir; ASSERT_TRUE(database_dir.CreateUniqueTempDir()); - scoped_ptr<ServiceWorkerDatabase> database( + std::unique_ptr<ServiceWorkerDatabase> database( CreateDatabase(database_dir.path())); GURL origin("http://example.com"); @@ -327,7 +327,7 @@ } TEST(ServiceWorkerDatabaseTest, GetOriginsWithRegistrations) { - scoped_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); + std::unique_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); std::set<GURL> origins; EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK, @@ -431,7 +431,7 @@ } TEST(ServiceWorkerDatabaseTest, GetRegistrationsForOrigin) { - scoped_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); + std::unique_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); GURL origin1("http://example.com"); GURL origin2("https://www.example.com"); @@ -540,7 +540,7 @@ } TEST(ServiceWorkerDatabaseTest, GetAllRegistrations) { - scoped_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); + std::unique_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); std::vector<RegistrationData> registrations; EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK, @@ -613,7 +613,7 @@ } TEST(ServiceWorkerDatabaseTest, Registration_Basic) { - scoped_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); + std::unique_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); GURL origin("http://example.com"); RegistrationData data; @@ -700,7 +700,7 @@ } TEST(ServiceWorkerDatabaseTest, DeleteNonExistentRegistration) { - scoped_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); + std::unique_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); GURL origin("http://example.com"); RegistrationData data; @@ -750,7 +750,7 @@ } TEST(ServiceWorkerDatabaseTest, Registration_Overwrite) { - scoped_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); + std::unique_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); GURL origin("http://example.com"); RegistrationData data; @@ -824,7 +824,7 @@ } TEST(ServiceWorkerDatabaseTest, Registration_Multiple) { - scoped_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); + std::unique_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); GURL origin("http://example.com"); ServiceWorkerDatabase::RegistrationData deleted_version; @@ -929,7 +929,7 @@ } TEST(ServiceWorkerDatabaseTest, Registration_UninitializedDatabase) { - scoped_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); + std::unique_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); const GURL origin("http://example.com"); // Should be failed because the database does not exist. @@ -975,7 +975,7 @@ } TEST(ServiceWorkerDatabaseTest, UserData_Basic) { - scoped_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); + std::unique_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); const GURL kOrigin("http://example.com"); // Add a registration. @@ -1043,7 +1043,7 @@ } TEST(ServiceWorkerDatabaseTest, UserData_DataIsolation) { - scoped_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); + std::unique_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); const GURL kOrigin("http://example.com"); // Add registration 1. @@ -1134,7 +1134,7 @@ } TEST(ServiceWorkerDatabaseTest, UserData_DeleteRegistration) { - scoped_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); + std::unique_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); const GURL kOrigin("http://example.com"); // Add registration 1. @@ -1211,7 +1211,7 @@ } TEST(ServiceWorkerDatabaseTest, UserData_UninitializedDatabase) { - scoped_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); + std::unique_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); const GURL kOrigin("http://example.com"); // Should be failed because the database does not exist. @@ -1243,7 +1243,7 @@ } TEST(ServiceWorkerDatabaseTest, UpdateVersionToActive) { - scoped_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); + std::unique_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); GURL origin("http://example.com"); ServiceWorkerDatabase::RegistrationData deleted_version; @@ -1304,7 +1304,7 @@ } TEST(ServiceWorkerDatabaseTest, UpdateLastCheckTime) { - scoped_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); + std::unique_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); GURL origin("http://example.com"); ServiceWorkerDatabase::RegistrationData deleted_version; std::vector<int64_t> newly_purgeable_resources; @@ -1367,7 +1367,7 @@ } TEST(ServiceWorkerDatabaseTest, UncommittedAndPurgeableResourceIds) { - scoped_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); + std::unique_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); // Write {1, 2, 3} into the uncommitted list. std::set<int64_t> ids1; @@ -1420,7 +1420,7 @@ } TEST(ServiceWorkerDatabaseTest, DeleteAllDataForOrigin) { - scoped_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); + std::unique_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); ServiceWorkerDatabase::RegistrationData deleted_version; std::vector<int64_t> newly_purgeable_resources; @@ -1583,7 +1583,7 @@ TEST(ServiceWorkerDatabaseTest, DestroyDatabase) { base::ScopedTempDir database_dir; ASSERT_TRUE(database_dir.CreateUniqueTempDir()); - scoped_ptr<ServiceWorkerDatabase> database( + std::unique_ptr<ServiceWorkerDatabase> database( CreateDatabase(database_dir.path())); EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK, database->LazyOpen(true)); @@ -1594,7 +1594,7 @@ } TEST(ServiceWorkerDatabaseTest, GetOriginsWithForeignFetchRegistrations) { - scoped_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); + std::unique_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); std::set<GURL> origins; EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK,
diff --git a/content/browser/service_worker/service_worker_dispatcher_host.cc b/content/browser/service_worker/service_worker_dispatcher_host.cc index d15732d4..e8d7039a 100644 --- a/content/browser/service_worker/service_worker_dispatcher_host.cc +++ b/content/browser/service_worker/service_worker_dispatcher_host.cc
@@ -8,6 +8,7 @@ #include "base/logging.h" #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/profiler/scoped_tracker.h" #include "base/strings/utf_string_conversions.h" #include "base/thread_task_runner_handle.h" @@ -126,7 +127,7 @@ TRACE_EVENT0("ServiceWorker", "ServiceWorkerDispatcherHost::OnFilterAdded"); channel_ready_ = true; - std::vector<scoped_ptr<IPC::Message>> messages; + std::vector<std::unique_ptr<IPC::Message>> messages; messages.swap(pending_messages_); for (auto& message : messages) { BrowserMessageFilter::Send(message.release()); @@ -222,18 +223,18 @@ return true; } - pending_messages_.push_back(make_scoped_ptr(message)); + pending_messages_.push_back(base::WrapUnique(message)); return true; } void ServiceWorkerDispatcherHost::RegisterServiceWorkerHandle( - scoped_ptr<ServiceWorkerHandle> handle) { + std::unique_ptr<ServiceWorkerHandle> handle) { int handle_id = handle->handle_id(); handles_.AddWithID(handle.release(), handle_id); } void ServiceWorkerDispatcherHost::RegisterServiceWorkerRegistrationHandle( - scoped_ptr<ServiceWorkerRegistrationHandle> handle) { + std::unique_ptr<ServiceWorkerRegistrationHandle> handle) { int handle_id = handle->handle_id(); registration_handles_.AddWithID(handle.release(), handle_id); } @@ -266,7 +267,7 @@ return existing_handle; } - scoped_ptr<ServiceWorkerRegistrationHandle> new_handle( + std::unique_ptr<ServiceWorkerRegistrationHandle> new_handle( new ServiceWorkerRegistrationHandle(GetContext()->AsWeakPtr(), provider_host, registration)); ServiceWorkerRegistrationHandle* new_handle_ptr = new_handle.get(); @@ -781,7 +782,7 @@ return; } - scoped_ptr<ServiceWorkerProviderHost> provider_host; + std::unique_ptr<ServiceWorkerProviderHost> provider_host; if (IsBrowserSideNavigationEnabled() && ServiceWorkerUtils::IsBrowserAssignedProviderId(provider_id)) { // PlzNavigate @@ -804,10 +805,10 @@ this, bad_message::SWDH_PROVIDER_CREATED_NO_HOST); return; } - provider_host = - scoped_ptr<ServiceWorkerProviderHost>(new ServiceWorkerProviderHost( - render_process_id_, route_id, provider_id, provider_type, - GetContext()->AsWeakPtr(), this)); + provider_host = std::unique_ptr<ServiceWorkerProviderHost>( + new ServiceWorkerProviderHost(render_process_id_, route_id, provider_id, + provider_type, GetContext()->AsWeakPtr(), + this)); } GetContext()->AddProviderHost(std::move(provider_host)); }
diff --git a/content/browser/service_worker/service_worker_dispatcher_host.h b/content/browser/service_worker/service_worker_dispatcher_host.h index b0287ffba..b7f9ed19 100644 --- a/content/browser/service_worker/service_worker_dispatcher_host.h +++ b/content/browser/service_worker/service_worker_dispatcher_host.h
@@ -7,11 +7,11 @@ #include <stdint.h> +#include <memory> #include <vector> #include "base/id_map.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/strings/string16.h" #include "content/browser/service_worker/service_worker_registration_status.h" @@ -65,9 +65,9 @@ // be destroyed. bool Send(IPC::Message* message) override; - void RegisterServiceWorkerHandle(scoped_ptr<ServiceWorkerHandle> handle); + void RegisterServiceWorkerHandle(std::unique_ptr<ServiceWorkerHandle> handle); void RegisterServiceWorkerRegistrationHandle( - scoped_ptr<ServiceWorkerRegistrationHandle> handle); + std::unique_ptr<ServiceWorkerRegistrationHandle> handle); ServiceWorkerHandle* FindServiceWorkerHandle(int provider_id, int64_t version_id); @@ -247,7 +247,7 @@ RegistrationHandleMap registration_handles_; bool channel_ready_; // True after BrowserMessageFilter::sender_ != NULL. - std::vector<scoped_ptr<IPC::Message>> pending_messages_; + std::vector<std::unique_ptr<IPC::Message>> pending_messages_; DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcherHost); };
diff --git a/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc b/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc index 7c9ad083..4613162 100644 --- a/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc +++ b/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc
@@ -5,10 +5,12 @@ #include "content/browser/service_worker/service_worker_dispatcher_host.h" #include <stdint.h> + #include <utility> #include "base/command_line.h" #include "base/files/file_path.h" +#include "base/memory/ptr_util.h" #include "base/run_loop.h" #include "content/browser/browser_thread_impl.h" #include "content/browser/message_port_service.h" @@ -96,7 +98,8 @@ : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) {} void SetUp() override { - Initialize(make_scoped_ptr(new EmbeddedWorkerTestHelper(base::FilePath()))); + Initialize( + base::WrapUnique(new EmbeddedWorkerTestHelper(base::FilePath()))); } void TearDown() override { @@ -110,7 +113,7 @@ return helper_->context_wrapper(); } - void Initialize(scoped_ptr<EmbeddedWorkerTestHelper> helper) { + void Initialize(std::unique_ptr<EmbeddedWorkerTestHelper> helper) { helper_.reset(helper.release()); dispatcher_host_ = new TestingServiceWorkerDispatcherHost( helper_->mock_render_process_id(), context_wrapper(), @@ -239,7 +242,7 @@ TestBrowserThreadBundle browser_thread_bundle_; content::MockResourceContext resource_context_; - scoped_ptr<EmbeddedWorkerTestHelper> helper_; + std::unique_ptr<EmbeddedWorkerTestHelper> helper_; scoped_refptr<TestingServiceWorkerDispatcherHost> dispatcher_host_; scoped_refptr<ServiceWorkerRegistration> registration_; scoped_refptr<ServiceWorkerVersion> version_; @@ -265,7 +268,7 @@ SetBrowserClientForTesting(&test_browser_client); const int64_t kProviderId = 99; // Dummy value - scoped_ptr<ServiceWorkerProviderHost> host( + std::unique_ptr<ServiceWorkerProviderHost> host( CreateServiceWorkerProviderHost(kProviderId)); host->SetDocumentUrl(GURL("https://www.example.com/foo")); context()->AddProviderHost(std::move(host)); @@ -294,7 +297,7 @@ TEST_F(ServiceWorkerDispatcherHostTest, Register_HTTPS) { const int64_t kProviderId = 99; // Dummy value - scoped_ptr<ServiceWorkerProviderHost> host( + std::unique_ptr<ServiceWorkerProviderHost> host( CreateServiceWorkerProviderHost(kProviderId)); host->SetDocumentUrl(GURL("https://www.example.com/foo")); context()->AddProviderHost(std::move(host)); @@ -307,7 +310,7 @@ TEST_F(ServiceWorkerDispatcherHostTest, Register_NonSecureTransportLocalhost) { const int64_t kProviderId = 99; // Dummy value - scoped_ptr<ServiceWorkerProviderHost> host( + std::unique_ptr<ServiceWorkerProviderHost> host( CreateServiceWorkerProviderHost(kProviderId)); host->SetDocumentUrl(GURL("http://127.0.0.3:81/foo")); context()->AddProviderHost(std::move(host)); @@ -320,7 +323,7 @@ TEST_F(ServiceWorkerDispatcherHostTest, Register_InvalidScopeShouldFail) { const int64_t kProviderId = 99; // Dummy value - scoped_ptr<ServiceWorkerProviderHost> host( + std::unique_ptr<ServiceWorkerProviderHost> host( CreateServiceWorkerProviderHost(kProviderId)); host->SetDocumentUrl(GURL("https://www.example.com/foo")); context()->AddProviderHost(std::move(host)); @@ -332,7 +335,7 @@ TEST_F(ServiceWorkerDispatcherHostTest, Register_InvalidScriptShouldFail) { const int64_t kProviderId = 99; // Dummy value - scoped_ptr<ServiceWorkerProviderHost> host( + std::unique_ptr<ServiceWorkerProviderHost> host( CreateServiceWorkerProviderHost(kProviderId)); host->SetDocumentUrl(GURL("https://www.example.com/foo")); context()->AddProviderHost(std::move(host)); @@ -343,7 +346,7 @@ TEST_F(ServiceWorkerDispatcherHostTest, Register_NonSecureOriginShouldFail) { const int64_t kProviderId = 99; // Dummy value - scoped_ptr<ServiceWorkerProviderHost> host( + std::unique_ptr<ServiceWorkerProviderHost> host( CreateServiceWorkerProviderHost(kProviderId)); host->SetDocumentUrl(GURL("http://www.example.com/foo")); context()->AddProviderHost(std::move(host)); @@ -356,7 +359,7 @@ TEST_F(ServiceWorkerDispatcherHostTest, Register_CrossOriginShouldFail) { const int64_t kProviderId = 99; // Dummy value - scoped_ptr<ServiceWorkerProviderHost> host( + std::unique_ptr<ServiceWorkerProviderHost> host( CreateServiceWorkerProviderHost(kProviderId)); host->SetDocumentUrl(GURL("https://www.example.com/foo")); context()->AddProviderHost(std::move(host)); @@ -400,7 +403,7 @@ TEST_F(ServiceWorkerDispatcherHostTest, Register_BadCharactersShouldFail) { const int64_t kProviderId = 99; // Dummy value - scoped_ptr<ServiceWorkerProviderHost> host( + std::unique_ptr<ServiceWorkerProviderHost> host( CreateServiceWorkerProviderHost(kProviderId)); host->SetDocumentUrl(GURL("https://www.example.com/")); context()->AddProviderHost(std::move(host)); @@ -433,7 +436,7 @@ TEST_F(ServiceWorkerDispatcherHostTest, Register_FileSystemDocumentShouldFail) { const int64_t kProviderId = 99; // Dummy value - scoped_ptr<ServiceWorkerProviderHost> host( + std::unique_ptr<ServiceWorkerProviderHost> host( CreateServiceWorkerProviderHost(kProviderId)); host->SetDocumentUrl(GURL("filesystem:https://www.example.com/temporary/a")); context()->AddProviderHost(std::move(host)); @@ -457,7 +460,7 @@ TEST_F(ServiceWorkerDispatcherHostTest, Register_FileSystemScriptOrScopeShouldFail) { const int64_t kProviderId = 99; // Dummy value - scoped_ptr<ServiceWorkerProviderHost> host( + std::unique_ptr<ServiceWorkerProviderHost> host( CreateServiceWorkerProviderHost(kProviderId)); host->SetDocumentUrl(GURL("https://www.example.com/temporary/")); context()->AddProviderHost(std::move(host)); @@ -524,7 +527,7 @@ TEST_F(ServiceWorkerDispatcherHostTest, GetRegistration_SameOrigin) { const int64_t kProviderId = 99; // Dummy value - scoped_ptr<ServiceWorkerProviderHost> host( + std::unique_ptr<ServiceWorkerProviderHost> host( CreateServiceWorkerProviderHost(kProviderId)); host->SetDocumentUrl(GURL("https://www.example.com/foo")); context()->AddProviderHost(std::move(host)); @@ -536,7 +539,7 @@ TEST_F(ServiceWorkerDispatcherHostTest, GetRegistration_CrossOriginShouldFail) { const int64_t kProviderId = 99; // Dummy value - scoped_ptr<ServiceWorkerProviderHost> host( + std::unique_ptr<ServiceWorkerProviderHost> host( CreateServiceWorkerProviderHost(kProviderId)); host->SetDocumentUrl(GURL("https://www.example.com/foo")); context()->AddProviderHost(std::move(host)); @@ -548,7 +551,7 @@ TEST_F(ServiceWorkerDispatcherHostTest, GetRegistration_InvalidScopeShouldFail) { const int64_t kProviderId = 99; // Dummy value - scoped_ptr<ServiceWorkerProviderHost> host( + std::unique_ptr<ServiceWorkerProviderHost> host( CreateServiceWorkerProviderHost(kProviderId)); host->SetDocumentUrl(GURL("https://www.example.com/foo")); context()->AddProviderHost(std::move(host)); @@ -560,7 +563,7 @@ TEST_F(ServiceWorkerDispatcherHostTest, GetRegistration_NonSecureOriginShouldFail) { const int64_t kProviderId = 99; // Dummy value - scoped_ptr<ServiceWorkerProviderHost> host( + std::unique_ptr<ServiceWorkerProviderHost> host( CreateServiceWorkerProviderHost(kProviderId)); host->SetDocumentUrl(GURL("http://www.example.com/foo")); context()->AddProviderHost(std::move(host)); @@ -582,7 +585,7 @@ TEST_F(ServiceWorkerDispatcherHostTest, GetRegistrations_SecureOrigin) { const int64_t kProviderId = 99; // Dummy value - scoped_ptr<ServiceWorkerProviderHost> host( + std::unique_ptr<ServiceWorkerProviderHost> host( CreateServiceWorkerProviderHost(kProviderId)); host->SetDocumentUrl(GURL("https://www.example.com/foo")); context()->AddProviderHost(std::move(host)); @@ -593,7 +596,7 @@ TEST_F(ServiceWorkerDispatcherHostTest, GetRegistrations_NonSecureOriginShouldFail) { const int64_t kProviderId = 99; // Dummy value - scoped_ptr<ServiceWorkerProviderHost> host( + std::unique_ptr<ServiceWorkerProviderHost> host( CreateServiceWorkerProviderHost(kProviderId)); host->SetDocumentUrl(GURL("http://www.example.com/foo")); context()->AddProviderHost(std::move(host)); @@ -699,7 +702,7 @@ GURL pattern = GURL("http://www.example.com/"); GURL script_url = GURL("http://www.example.com/service_worker.js"); - Initialize(make_scoped_ptr(new FailToStartWorkerTestHelper)); + Initialize(base::WrapUnique(new FailToStartWorkerTestHelper)); SendProviderCreated(SERVICE_WORKER_PROVIDER_FOR_CONTROLLER, pattern); SetUpRegistration(pattern, script_url); @@ -740,7 +743,7 @@ GURL pattern = GURL("http://www.example.com/"); GURL script_url = GURL("http://www.example.com/service_worker.js"); - Initialize(make_scoped_ptr(new FailToStartWorkerTestHelper)); + Initialize(base::WrapUnique(new FailToStartWorkerTestHelper)); SendProviderCreated(SERVICE_WORKER_PROVIDER_FOR_CONTROLLER, pattern); SetUpRegistration(pattern, script_url);
diff --git a/content/browser/service_worker/service_worker_fetch_dispatcher.cc b/content/browser/service_worker/service_worker_fetch_dispatcher.cc index dfcce9a..dad6fba 100644 --- a/content/browser/service_worker/service_worker_fetch_dispatcher.cc +++ b/content/browser/service_worker/service_worker_fetch_dispatcher.cc
@@ -34,7 +34,7 @@ } // namespace ServiceWorkerFetchDispatcher::ServiceWorkerFetchDispatcher( - scoped_ptr<ServiceWorkerFetchRequest> request, + std::unique_ptr<ServiceWorkerFetchRequest> request, ServiceWorkerVersion* version, ResourceType resource_type, const base::Closure& prepare_callback,
diff --git a/content/browser/service_worker/service_worker_fetch_dispatcher.h b/content/browser/service_worker/service_worker_fetch_dispatcher.h index 82a4a2d5..31d0bc1 100644 --- a/content/browser/service_worker/service_worker_fetch_dispatcher.h +++ b/content/browser/service_worker/service_worker_fetch_dispatcher.h
@@ -27,11 +27,12 @@ const scoped_refptr<ServiceWorkerVersion>&)> FetchCallback; - ServiceWorkerFetchDispatcher(scoped_ptr<ServiceWorkerFetchRequest> request, - ServiceWorkerVersion* version, - ResourceType resource_type, - const base::Closure& prepare_callback, - const FetchCallback& fetch_callback); + ServiceWorkerFetchDispatcher( + std::unique_ptr<ServiceWorkerFetchRequest> request, + ServiceWorkerVersion* version, + ResourceType resource_type, + const base::Closure& prepare_callback, + const FetchCallback& fetch_callback); ~ServiceWorkerFetchDispatcher(); // Dispatches a fetch event to the |version| given in ctor, and fires @@ -53,7 +54,7 @@ scoped_refptr<ServiceWorkerVersion> version_; base::Closure prepare_callback_; FetchCallback fetch_callback_; - scoped_ptr<ServiceWorkerFetchRequest> request_; + std::unique_ptr<ServiceWorkerFetchRequest> request_; ResourceType resource_type_; base::WeakPtrFactory<ServiceWorkerFetchDispatcher> weak_factory_;
diff --git a/content/browser/service_worker/service_worker_handle.cc b/content/browser/service_worker/service_worker_handle.cc index 086135b..8a69a0292 100644 --- a/content/browser/service_worker/service_worker_handle.cc +++ b/content/browser/service_worker/service_worker_handle.cc
@@ -4,6 +4,7 @@ #include "content/browser/service_worker/service_worker_handle.h" +#include "base/memory/ptr_util.h" #include "content/browser/service_worker/service_worker_context_core.h" #include "content/browser/service_worker/service_worker_registration.h" #include "content/common/service_worker/service_worker_messages.h" @@ -36,15 +37,15 @@ } // namespace -scoped_ptr<ServiceWorkerHandle> ServiceWorkerHandle::Create( +std::unique_ptr<ServiceWorkerHandle> ServiceWorkerHandle::Create( base::WeakPtr<ServiceWorkerContextCore> context, base::WeakPtr<ServiceWorkerProviderHost> provider_host, ServiceWorkerVersion* version) { if (!context || !provider_host || !version) - return scoped_ptr<ServiceWorkerHandle>(); + return std::unique_ptr<ServiceWorkerHandle>(); DCHECK(context->GetLiveRegistration(version->registration_id())); - return make_scoped_ptr(new ServiceWorkerHandle( - context, provider_host, version)); + return base::WrapUnique( + new ServiceWorkerHandle(context, provider_host, version)); } ServiceWorkerHandle::ServiceWorkerHandle(
diff --git a/content/browser/service_worker/service_worker_handle.h b/content/browser/service_worker/service_worker_handle.h index 4d8651a..6a519ea 100644 --- a/content/browser/service_worker/service_worker_handle.h +++ b/content/browser/service_worker/service_worker_handle.h
@@ -5,9 +5,10 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_HANDLE_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_HANDLE_H_ +#include <memory> + #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "content/browser/service_worker/service_worker_version.h" #include "content/common/content_export.h" @@ -35,7 +36,7 @@ public: // Creates a handle for a live version. This may return nullptr if any of // |context|, |provider_host| and |version| is nullptr. - static scoped_ptr<ServiceWorkerHandle> Create( + static std::unique_ptr<ServiceWorkerHandle> Create( base::WeakPtr<ServiceWorkerContextCore> context, base::WeakPtr<ServiceWorkerProviderHost> provider_host, ServiceWorkerVersion* version);
diff --git a/content/browser/service_worker/service_worker_handle_unittest.cc b/content/browser/service_worker/service_worker_handle_unittest.cc index ae15a98e..f4ac08773 100644 --- a/content/browser/service_worker/service_worker_handle_unittest.cc +++ b/content/browser/service_worker/service_worker_handle_unittest.cc
@@ -126,8 +126,8 @@ TestBrowserThreadBundle browser_thread_bundle_; MockResourceContext resource_context_; - scoped_ptr<EmbeddedWorkerTestHelper> helper_; - scoped_ptr<ServiceWorkerProviderHost> provider_host_; + std::unique_ptr<EmbeddedWorkerTestHelper> helper_; + std::unique_ptr<ServiceWorkerProviderHost> provider_host_; scoped_refptr<ServiceWorkerRegistration> registration_; scoped_refptr<ServiceWorkerVersion> version_; scoped_refptr<TestingServiceWorkerDispatcherHost> dispatcher_host_; @@ -137,10 +137,9 @@ }; TEST_F(ServiceWorkerHandleTest, OnVersionStateChanged) { - scoped_ptr<ServiceWorkerHandle> handle = + std::unique_ptr<ServiceWorkerHandle> handle = ServiceWorkerHandle::Create(helper_->context()->AsWeakPtr(), - provider_host_->AsWeakPtr(), - version_.get()); + provider_host_->AsWeakPtr(), version_.get()); // Start the worker, and then... ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED;
diff --git a/content/browser/service_worker/service_worker_internals_ui.cc b/content/browser/service_worker/service_worker_internals_ui.cc index 61eaffb..5b410ef 100644 --- a/content/browser/service_worker/service_worker_internals_ui.cc +++ b/content/browser/service_worker/service_worker_internals_ui.cc
@@ -277,7 +277,7 @@ args.push_back(new StringValue(base::Int64ToString(version_id))); args.push_back(new FundamentalValue(process_id)); args.push_back(new FundamentalValue(thread_id)); - scoped_ptr<DictionaryValue> value(new DictionaryValue()); + std::unique_ptr<DictionaryValue> value(new DictionaryValue()); value->SetString("message", info.error_message); value->SetInteger("lineNumber", info.line_number); value->SetInteger("columnNumber", info.column_number); @@ -296,7 +296,7 @@ args.push_back(new StringValue(base::Int64ToString(version_id))); args.push_back(new FundamentalValue(process_id)); args.push_back(new FundamentalValue(thread_id)); - scoped_ptr<DictionaryValue> value(new DictionaryValue()); + std::unique_ptr<DictionaryValue> value(new DictionaryValue()); value->SetInteger("sourceIdentifier", message.source_identifier); value->SetInteger("message_level", message.message_level); value->SetString("message", message.message); @@ -423,7 +423,7 @@ partition_id = observer->partition_id(); } else { partition_id = next_partition_id_++; - scoped_ptr<PartitionObserver> new_observer( + std::unique_ptr<PartitionObserver> new_observer( new PartitionObserver(partition_id, web_ui())); context->AddObserver(new_observer.get()); observers_.set(reinterpret_cast<uintptr_t>(partition), @@ -440,7 +440,7 @@ void ServiceWorkerInternalsUI::RemoveObserverFromStoragePartition( StoragePartition* partition) { - scoped_ptr<PartitionObserver> observer( + std::unique_ptr<PartitionObserver> observer( observers_.take_and_erase(reinterpret_cast<uintptr_t>(partition))); if (!observer.get()) return;
diff --git a/content/browser/service_worker/service_worker_internals_ui.h b/content/browser/service_worker/service_worker_internals_ui.h index b04df03..21fdc6f9 100644 --- a/content/browser/service_worker/service_worker_internals_ui.h +++ b/content/browser/service_worker/service_worker_internals_ui.h
@@ -5,12 +5,12 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_INTERNALS_UI_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_INTERNALS_UI_H_ +#include <memory> #include <set> #include "base/containers/scoped_ptr_hash_map.h" #include "base/files/file_path.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "content/browser/service_worker/service_worker_context_observer.h" #include "content/common/service_worker/service_worker_status_code.h" @@ -67,7 +67,8 @@ const GURL& scope, const StatusCallback& callback) const; - base::ScopedPtrHashMap<uintptr_t, scoped_ptr<PartitionObserver>> observers_; + base::ScopedPtrHashMap<uintptr_t, std::unique_ptr<PartitionObserver>> + observers_; int next_partition_id_; };
diff --git a/content/browser/service_worker/service_worker_job_coordinator.cc b/content/browser/service_worker/service_worker_job_coordinator.cc index 9dd023e..54542b2 100644 --- a/content/browser/service_worker/service_worker_job_coordinator.cc +++ b/content/browser/service_worker/service_worker_job_coordinator.cc
@@ -5,9 +5,11 @@ #include "content/browser/service_worker/service_worker_job_coordinator.h" #include <stddef.h> + +#include <memory> #include <utility> -#include "base/memory/scoped_ptr.h" +#include "base/memory/ptr_util.h" #include "base/stl_util.h" #include "content/browser/service_worker/service_worker_register_job_base.h" @@ -33,7 +35,7 @@ } ServiceWorkerRegisterJobBase* ServiceWorkerJobCoordinator::JobQueue::Push( - scoped_ptr<ServiceWorkerRegisterJobBase> job) { + std::unique_ptr<ServiceWorkerRegisterJobBase> job) { if (jobs_.empty()) { jobs_.push_back(job.release()); StartOneJob(); @@ -109,7 +111,7 @@ const GURL& script_url, ServiceWorkerProviderHost* provider_host, const ServiceWorkerRegisterJob::RegistrationCallback& callback) { - scoped_ptr<ServiceWorkerRegisterJobBase> job( + std::unique_ptr<ServiceWorkerRegisterJobBase> job( new ServiceWorkerRegisterJob(context_, pattern, script_url)); ServiceWorkerRegisterJob* queued_job = static_cast<ServiceWorkerRegisterJob*>( job_queues_[pattern].Push(std::move(job))); @@ -119,7 +121,7 @@ void ServiceWorkerJobCoordinator::Unregister( const GURL& pattern, const ServiceWorkerUnregisterJob::UnregistrationCallback& callback) { - scoped_ptr<ServiceWorkerRegisterJobBase> job( + std::unique_ptr<ServiceWorkerRegisterJobBase> job( new ServiceWorkerUnregisterJob(context_, pattern)); ServiceWorkerUnregisterJob* queued_job = static_cast<ServiceWorkerUnregisterJob*>( @@ -133,7 +135,7 @@ DCHECK(registration); DCHECK(registration->GetNewestVersion()); job_queues_[registration->pattern()].Push( - make_scoped_ptr<ServiceWorkerRegisterJobBase>( + base::WrapUnique<ServiceWorkerRegisterJobBase>( new ServiceWorkerRegisterJob(context_, registration, force_bypass_cache, false /* skip_script_comparison */))); @@ -149,7 +151,7 @@ DCHECK(registration->GetNewestVersion()); ServiceWorkerRegisterJob* queued_job = static_cast<ServiceWorkerRegisterJob*>( job_queues_[registration->pattern()].Push( - make_scoped_ptr<ServiceWorkerRegisterJobBase>( + base::WrapUnique<ServiceWorkerRegisterJobBase>( new ServiceWorkerRegisterJob(context_, registration, force_bypass_cache, skip_script_comparison))));
diff --git a/content/browser/service_worker/service_worker_job_coordinator.h b/content/browser/service_worker/service_worker_job_coordinator.h index 5b4c1f19..23e48ab 100644 --- a/content/browser/service_worker/service_worker_job_coordinator.h +++ b/content/browser/service_worker/service_worker_job_coordinator.h
@@ -63,7 +63,7 @@ // queue, no new job is added. Returns the job in the queue, regardless of // whether it was newly added. ServiceWorkerRegisterJobBase* Push( - scoped_ptr<ServiceWorkerRegisterJobBase> job); + std::unique_ptr<ServiceWorkerRegisterJobBase> job); // Dooms the installing worker of the running register/update job if a // register/update job is scheduled to run after it. This corresponds to
diff --git a/content/browser/service_worker/service_worker_job_unittest.cc b/content/browser/service_worker/service_worker_job_unittest.cc index f1175b2..b52b542 100644 --- a/content/browser/service_worker/service_worker_job_unittest.cc +++ b/content/browser/service_worker/service_worker_job_unittest.cc
@@ -130,10 +130,10 @@ scoped_refptr<ServiceWorkerRegistration> FindRegistrationForPattern( const GURL& pattern, ServiceWorkerStatusCode expected_status = SERVICE_WORKER_OK); - scoped_ptr<ServiceWorkerProviderHost> CreateControllee(); + std::unique_ptr<ServiceWorkerProviderHost> CreateControllee(); TestBrowserThreadBundle browser_thread_bundle_; - scoped_ptr<EmbeddedWorkerTestHelper> helper_; + std::unique_ptr<EmbeddedWorkerTestHelper> helper_; }; scoped_refptr<ServiceWorkerRegistration> ServiceWorkerJobTest::RunRegisterJob( @@ -178,11 +178,14 @@ return registration; } -scoped_ptr<ServiceWorkerProviderHost> ServiceWorkerJobTest::CreateControllee() { - return scoped_ptr<ServiceWorkerProviderHost>(new ServiceWorkerProviderHost( - 33 /* dummy render_process id */, MSG_ROUTING_NONE /* render_frame_id */, - 1 /* dummy provider_id */, SERVICE_WORKER_PROVIDER_FOR_WINDOW, - helper_->context()->AsWeakPtr(), NULL)); +std::unique_ptr<ServiceWorkerProviderHost> +ServiceWorkerJobTest::CreateControllee() { + return std::unique_ptr<ServiceWorkerProviderHost>( + new ServiceWorkerProviderHost(33 /* dummy render_process id */, + MSG_ROUTING_NONE /* render_frame_id */, + 1 /* dummy provider_id */, + SERVICE_WORKER_PROVIDER_FOR_WINDOW, + helper_->context()->AsWeakPtr(), NULL)); } TEST_F(ServiceWorkerJobTest, SameDocumentSameRegistration) { @@ -691,7 +694,7 @@ GURL("http://www.example.com/service_worker.js")); ASSERT_TRUE(registration.get()); - scoped_ptr<ServiceWorkerProviderHost> host = CreateControllee(); + std::unique_ptr<ServiceWorkerProviderHost> host = CreateControllee(); registration->active_version()->AddControllee(host.get()); scoped_refptr<ServiceWorkerVersion> version = registration->active_version(); @@ -734,10 +737,10 @@ const std::string& headers, IOBuffer* body, int length) { - scoped_ptr<ServiceWorkerResponseWriter> writer = + std::unique_ptr<ServiceWorkerResponseWriter> writer = storage->CreateResponseWriter(id); - scoped_ptr<net::HttpResponseInfo> info(new net::HttpResponseInfo); + std::unique_ptr<net::HttpResponseInfo> info(new net::HttpResponseInfo); info->request_time = base::Time::Now(); info->response_time = base::Time::Now(); info->was_cached = false; @@ -1186,7 +1189,7 @@ GURL("http://www.example.com/service_worker.js")); // Add a controllee and queue an unregister to force the uninstalling state. - scoped_ptr<ServiceWorkerProviderHost> host = CreateControllee(); + std::unique_ptr<ServiceWorkerProviderHost> host = CreateControllee(); ServiceWorkerVersion* active_version = registration->active_version(); active_version->AddControllee(host.get()); job_coordinator()->Unregister(GURL("http://www.example.com/one/"), @@ -1215,7 +1218,7 @@ RunRegisterJob(pattern, script1); // Add a controllee and queue an unregister to force the uninstalling state. - scoped_ptr<ServiceWorkerProviderHost> host = CreateControllee(); + std::unique_ptr<ServiceWorkerProviderHost> host = CreateControllee(); scoped_refptr<ServiceWorkerVersion> old_version = registration->active_version(); old_version->AddControllee(host.get()); @@ -1259,7 +1262,7 @@ RunRegisterJob(pattern, script1); // Add a controllee and queue an unregister to force the uninstalling state. - scoped_ptr<ServiceWorkerProviderHost> host = CreateControllee(); + std::unique_ptr<ServiceWorkerProviderHost> host = CreateControllee(); scoped_refptr<ServiceWorkerVersion> old_version = registration->active_version(); old_version->AddControllee(host.get()); @@ -1307,7 +1310,7 @@ RunRegisterJob(pattern, script1); // Add a controllee and queue an unregister to force the uninstalling state. - scoped_ptr<ServiceWorkerProviderHost> host = CreateControllee(); + std::unique_ptr<ServiceWorkerProviderHost> host = CreateControllee(); scoped_refptr<ServiceWorkerVersion> old_version = registration->active_version(); old_version->AddControllee(host.get()); @@ -1352,7 +1355,7 @@ RunRegisterJob(pattern, script1); // Add a controllee and queue an unregister to force the uninstalling state. - scoped_ptr<ServiceWorkerProviderHost> host = CreateControllee(); + std::unique_ptr<ServiceWorkerProviderHost> host = CreateControllee(); scoped_refptr<ServiceWorkerVersion> first_version = registration->active_version(); first_version->AddControllee(host.get()); @@ -1440,7 +1443,7 @@ RunRegisterJob(pattern, script1); // Add a controllee and queue an unregister to force the uninstalling state. - scoped_ptr<ServiceWorkerProviderHost> host = CreateControllee(); + std::unique_ptr<ServiceWorkerProviderHost> host = CreateControllee(); scoped_refptr<ServiceWorkerVersion> old_version = registration->active_version(); old_version->AddControllee(host.get()); @@ -1480,7 +1483,7 @@ RunRegisterJob(pattern, script1); // Add a controllee and queue an unregister to force the uninstalling state. - scoped_ptr<ServiceWorkerProviderHost> host = CreateControllee(); + std::unique_ptr<ServiceWorkerProviderHost> host = CreateControllee(); scoped_refptr<ServiceWorkerVersion> old_version = registration->active_version(); old_version->AddControllee(host.get()); @@ -1516,7 +1519,7 @@ RunRegisterJob(pattern, script1); // Add a controllee and queue an unregister to force the uninstalling state. - scoped_ptr<ServiceWorkerProviderHost> host = CreateControllee(); + std::unique_ptr<ServiceWorkerProviderHost> host = CreateControllee(); scoped_refptr<ServiceWorkerVersion> old_version = registration->active_version(); old_version->AddControllee(host.get());
diff --git a/content/browser/service_worker/service_worker_navigation_handle_core.cc b/content/browser/service_worker/service_worker_navigation_handle_core.cc index 8c4791d..279461f8 100644 --- a/content/browser/service_worker/service_worker_navigation_handle_core.cc +++ b/content/browser/service_worker/service_worker_navigation_handle_core.cc
@@ -34,7 +34,7 @@ } void ServiceWorkerNavigationHandleCore::DidPreCreateProviderHost( - scoped_ptr<ServiceWorkerProviderHost> precreated_host) { + std::unique_ptr<ServiceWorkerProviderHost> precreated_host) { DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK(precreated_host.get()); DCHECK(context_wrapper_->context()); @@ -49,7 +49,7 @@ ui_handle_, precreated_host_->provider_id())); } -scoped_ptr<ServiceWorkerProviderHost> +std::unique_ptr<ServiceWorkerProviderHost> ServiceWorkerNavigationHandleCore::RetrievePreCreatedHost() { DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK(precreated_host_);
diff --git a/content/browser/service_worker/service_worker_navigation_handle_core.h b/content/browser/service_worker/service_worker_navigation_handle_core.h index c1ed9eb..88e5013 100644 --- a/content/browser/service_worker/service_worker_navigation_handle_core.h +++ b/content/browser/service_worker/service_worker_navigation_handle_core.h
@@ -5,9 +5,10 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_NAVIGATION_HANDLE_CORE_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_NAVIGATION_HANDLE_CORE_H_ +#include <memory> + #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" namespace content { @@ -34,18 +35,18 @@ // tracked by this ServiceWorkerNavigationHandleCore. Takes ownership of // |precreated_host|. void DidPreCreateProviderHost( - scoped_ptr<ServiceWorkerProviderHost> precreated_host); + std::unique_ptr<ServiceWorkerProviderHost> precreated_host); // Called when the renderer created a ServiceWorkerNetworkProvider matching // |precreated_host_|. This releases ownership of |precreated_host_|. - scoped_ptr<ServiceWorkerProviderHost> RetrievePreCreatedHost(); + std::unique_ptr<ServiceWorkerProviderHost> RetrievePreCreatedHost(); ServiceWorkerContextWrapper* context_wrapper() const { return context_wrapper_.get(); } private: - scoped_ptr<ServiceWorkerProviderHost> precreated_host_; + std::unique_ptr<ServiceWorkerProviderHost> precreated_host_; scoped_refptr<ServiceWorkerContextWrapper> context_wrapper_; base::WeakPtr<ServiceWorkerNavigationHandle> ui_handle_;
diff --git a/content/browser/service_worker/service_worker_process_manager.h b/content/browser/service_worker/service_worker_process_manager.h index 465ed5a..01ddae7 100644 --- a/content/browser/service_worker/service_worker_process_manager.h +++ b/content/browser/service_worker/service_worker_process_manager.h
@@ -11,7 +11,6 @@ #include "base/callback.h" #include "base/gtest_prod_util.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "content/common/service_worker/service_worker_status_code.h"
diff --git a/content/browser/service_worker/service_worker_process_manager_unittest.cc b/content/browser/service_worker/service_worker_process_manager_unittest.cc index 98ded59..047bdb37 100644 --- a/content/browser/service_worker/service_worker_process_manager_unittest.cc +++ b/content/browser/service_worker/service_worker_process_manager_unittest.cc
@@ -2,10 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/browser/service_worker/service_worker_process_manager.h" + #include "base/bind.h" #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/run_loop.h" -#include "content/browser/service_worker/service_worker_process_manager.h" #include "content/common/service_worker/embedded_worker_settings.h" #include "content/public/common/child_process_host.h" #include "content/public/test/mock_render_process_host.h" @@ -52,13 +54,13 @@ process_manager_.reset(); } - scoped_ptr<MockRenderProcessHost> CreateRenderProcessHost() { - return make_scoped_ptr(new MockRenderProcessHost(browser_context_.get())); + std::unique_ptr<MockRenderProcessHost> CreateRenderProcessHost() { + return base::WrapUnique(new MockRenderProcessHost(browser_context_.get())); } protected: - scoped_ptr<TestBrowserContext> browser_context_; - scoped_ptr<ServiceWorkerProcessManager> process_manager_; + std::unique_ptr<TestBrowserContext> browser_context_; + std::unique_ptr<ServiceWorkerProcessManager> process_manager_; GURL pattern_; GURL script_url_; @@ -88,9 +90,9 @@ } TEST_F(ServiceWorkerProcessManagerTest, FindAvailableProcess) { - scoped_ptr<MockRenderProcessHost> host1(CreateRenderProcessHost()); - scoped_ptr<MockRenderProcessHost> host2(CreateRenderProcessHost()); - scoped_ptr<MockRenderProcessHost> host3(CreateRenderProcessHost()); + std::unique_ptr<MockRenderProcessHost> host1(CreateRenderProcessHost()); + std::unique_ptr<MockRenderProcessHost> host2(CreateRenderProcessHost()); + std::unique_ptr<MockRenderProcessHost> host3(CreateRenderProcessHost()); // Process 1 has 2 refs, 2 has 3 refs and 3 has 1 ref. process_manager_->AddProcessReferenceToPattern(pattern_, host1->GetID()); @@ -128,8 +130,8 @@ GURL scope2("http://example.com/scope2"); // Set up mock renderer process hosts. - scoped_ptr<MockRenderProcessHost> host1(CreateRenderProcessHost()); - scoped_ptr<MockRenderProcessHost> host2(CreateRenderProcessHost()); + std::unique_ptr<MockRenderProcessHost> host1(CreateRenderProcessHost()); + std::unique_ptr<MockRenderProcessHost> host2(CreateRenderProcessHost()); process_manager_->AddProcessReferenceToPattern(scope1, host1->GetID()); process_manager_->AddProcessReferenceToPattern(scope2, host2->GetID()); ASSERT_EQ(0, host1->worker_ref_count());
diff --git a/content/browser/service_worker/service_worker_provider_host.cc b/content/browser/service_worker/service_worker_provider_host.cc index 0c8c35d8..12225c94 100644 --- a/content/browser/service_worker/service_worker_provider_host.cc +++ b/content/browser/service_worker/service_worker_provider_host.cc
@@ -45,15 +45,16 @@ } // static -scoped_ptr<ServiceWorkerProviderHost> +std::unique_ptr<ServiceWorkerProviderHost> ServiceWorkerProviderHost::PreCreateNavigationHost( base::WeakPtr<ServiceWorkerContextCore> context) { CHECK(IsBrowserSideNavigationEnabled()); // Generate a new browser-assigned id for the host. int provider_id = g_next_navigation_provider_id--; - return scoped_ptr<ServiceWorkerProviderHost>(new ServiceWorkerProviderHost( - ChildProcessHost::kInvalidUniqueID, MSG_ROUTING_NONE, provider_id, - SERVICE_WORKER_PROVIDER_FOR_WINDOW, context, nullptr)); + return std::unique_ptr<ServiceWorkerProviderHost>( + new ServiceWorkerProviderHost( + ChildProcessHost::kInvalidUniqueID, MSG_ROUTING_NONE, provider_id, + SERVICE_WORKER_PROVIDER_FOR_WINDOW, context, nullptr)); } ServiceWorkerProviderHost::ServiceWorkerProviderHost( @@ -317,7 +318,7 @@ SetControllerVersionAttribute(nullptr, true /* notify_controllerchange */); } -scoped_ptr<ServiceWorkerRequestHandler> +std::unique_ptr<ServiceWorkerRequestHandler> ServiceWorkerProviderHost::CreateRequestHandler( FetchRequestMode request_mode, FetchCredentialsMode credentials_mode, @@ -328,19 +329,19 @@ base::WeakPtr<storage::BlobStorageContext> blob_storage_context, scoped_refptr<ResourceRequestBody> body) { if (IsHostToRunningServiceWorker()) { - return scoped_ptr<ServiceWorkerRequestHandler>( + return std::unique_ptr<ServiceWorkerRequestHandler>( new ServiceWorkerContextRequestHandler( context_, AsWeakPtr(), blob_storage_context, resource_type)); } if (ServiceWorkerUtils::IsMainResourceType(resource_type) || controlling_version()) { - return scoped_ptr<ServiceWorkerRequestHandler>( + return std::unique_ptr<ServiceWorkerRequestHandler>( new ServiceWorkerControlleeRequestHandler( context_, AsWeakPtr(), blob_storage_context, request_mode, credentials_mode, redirect_mode, resource_type, request_context_type, frame_type, body)); } - return scoped_ptr<ServiceWorkerRequestHandler>(); + return std::unique_ptr<ServiceWorkerRequestHandler>(); } ServiceWorkerObjectInfo @@ -356,7 +357,7 @@ return handle->GetObjectInfo(); } - scoped_ptr<ServiceWorkerHandle> new_handle( + std::unique_ptr<ServiceWorkerHandle> new_handle( ServiceWorkerHandle::Create(context_, AsWeakPtr(), version)); handle = new_handle.get(); dispatcher_host_->RegisterServiceWorkerHandle(std::move(new_handle));
diff --git a/content/browser/service_worker/service_worker_provider_host.h b/content/browser/service_worker/service_worker_provider_host.h index 3f1d247..31a4653 100644 --- a/content/browser/service_worker/service_worker_provider_host.h +++ b/content/browser/service_worker/service_worker_provider_host.h
@@ -58,7 +58,7 @@ // Used to pre-create a ServiceWorkerProviderHost for a navigation. The // ServiceWorkerNetworkProvider will later be created in the renderer, should // the navigation succeed. - static scoped_ptr<ServiceWorkerProviderHost> PreCreateNavigationHost( + static std::unique_ptr<ServiceWorkerProviderHost> PreCreateNavigationHost( base::WeakPtr<ServiceWorkerContextCore> context); // When this provider host is for a Service Worker context, |route_id| is @@ -137,7 +137,7 @@ // Returns a handler for a request, the handler may return NULL if // the request doesn't require special handling. - scoped_ptr<ServiceWorkerRequestHandler> CreateRequestHandler( + std::unique_ptr<ServiceWorkerRequestHandler> CreateRequestHandler( FetchRequestMode request_mode, FetchCredentialsMode credentials_mode, FetchRedirectMode redirect_mode, @@ -321,7 +321,7 @@ // URL starts with. ServiceWorkerRegistrationMap matching_registrations_; - scoped_ptr<OneShotGetReadyCallback> get_ready_callback_; + std::unique_ptr<OneShotGetReadyCallback> get_ready_callback_; scoped_refptr<ServiceWorkerVersion> controlling_version_; scoped_refptr<ServiceWorkerVersion> running_hosted_version_; base::WeakPtr<ServiceWorkerContextCore> context_;
diff --git a/content/browser/service_worker/service_worker_provider_host_unittest.cc b/content/browser/service_worker/service_worker_provider_host_unittest.cc index 642260b0..cbffe12 100644 --- a/content/browser/service_worker/service_worker_provider_host_unittest.cc +++ b/content/browser/service_worker/service_worker_provider_host_unittest.cc
@@ -2,12 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/browser/service_worker/service_worker_provider_host.h" + #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/memory/weak_ptr.h" #include "base/thread_task_runner_handle.h" #include "content/browser/service_worker/embedded_worker_test_helper.h" #include "content/browser/service_worker/service_worker_context_core.h" -#include "content/browser/service_worker/service_worker_provider_host.h" #include "content/browser/service_worker/service_worker_register_job.h" #include "content/browser/service_worker/service_worker_registration.h" #include "content/browser/service_worker/service_worker_version.h" @@ -32,20 +34,22 @@ GURL("http://www.example.com/example"), 2L, context_->AsWeakPtr()); // Prepare provider hosts (for the same process). - scoped_ptr<ServiceWorkerProviderHost> host1(new ServiceWorkerProviderHost( - helper_->mock_render_process_id(), MSG_ROUTING_NONE, - 1 /* provider_id */, SERVICE_WORKER_PROVIDER_FOR_WINDOW, - context_->AsWeakPtr(), NULL)); + std::unique_ptr<ServiceWorkerProviderHost> host1( + new ServiceWorkerProviderHost(helper_->mock_render_process_id(), + MSG_ROUTING_NONE, 1 /* provider_id */, + SERVICE_WORKER_PROVIDER_FOR_WINDOW, + context_->AsWeakPtr(), NULL)); host1->SetDocumentUrl(GURL("http://www.example.com/example1.html")); - scoped_ptr<ServiceWorkerProviderHost> host2(new ServiceWorkerProviderHost( - helper_->mock_render_process_id(), MSG_ROUTING_NONE, - 2 /* provider_id */, SERVICE_WORKER_PROVIDER_FOR_WINDOW, - context_->AsWeakPtr(), NULL)); + std::unique_ptr<ServiceWorkerProviderHost> host2( + new ServiceWorkerProviderHost(helper_->mock_render_process_id(), + MSG_ROUTING_NONE, 2 /* provider_id */, + SERVICE_WORKER_PROVIDER_FOR_WINDOW, + context_->AsWeakPtr(), NULL)); host2->SetDocumentUrl(GURL("http://www.example.com/example2.html")); provider_host1_ = host1->AsWeakPtr(); provider_host2_ = host2->AsWeakPtr(); - context_->AddProviderHost(make_scoped_ptr(host1.release())); - context_->AddProviderHost(make_scoped_ptr(host2.release())); + context_->AddProviderHost(base::WrapUnique(host1.release())); + context_->AddProviderHost(base::WrapUnique(host2.release())); } void TearDown() override { @@ -59,7 +63,7 @@ } content::TestBrowserThreadBundle thread_bundle_; - scoped_ptr<EmbeddedWorkerTestHelper> helper_; + std::unique_ptr<EmbeddedWorkerTestHelper> helper_; ServiceWorkerContextCore* context_; scoped_refptr<ServiceWorkerRegistration> registration1_; scoped_refptr<ServiceWorkerRegistration> registration2_;
diff --git a/content/browser/service_worker/service_worker_read_from_cache_job.h b/content/browser/service_worker/service_worker_read_from_cache_job.h index 41b40ca..4373fad8 100644 --- a/content/browser/service_worker/service_worker_read_from_cache_job.h +++ b/content/browser/service_worker/service_worker_read_from_cache_job.h
@@ -73,11 +73,11 @@ base::WeakPtr<ServiceWorkerContextCore> context_; scoped_refptr<ServiceWorkerVersion> version_; - scoped_ptr<ServiceWorkerResponseReader> reader_; + std::unique_ptr<ServiceWorkerResponseReader> reader_; scoped_refptr<HttpResponseInfoIOBuffer> http_info_io_buffer_; - scoped_ptr<net::HttpResponseInfo> http_info_; + std::unique_ptr<net::HttpResponseInfo> http_info_; net::HttpByteRange range_requested_; - scoped_ptr<net::HttpResponseInfo> range_response_info_; + std::unique_ptr<net::HttpResponseInfo> range_response_info_; bool has_been_killed_ = false; base::WeakPtrFactory<ServiceWorkerReadFromCacheJob> weak_factory_;
diff --git a/content/browser/service_worker/service_worker_read_from_cache_job_unittest.cc b/content/browser/service_worker/service_worker_read_from_cache_job_unittest.cc index 6cb1cbd..63e28ce 100644 --- a/content/browser/service_worker/service_worker_read_from_cache_job_unittest.cc +++ b/content/browser/service_worker/service_worker_read_from_cache_job_unittest.cc
@@ -6,8 +6,10 @@ #include <stdint.h> +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" +#include "base/memory/ptr_util.h" #include "base/run_loop.h" #include "content/browser/fileapi/mock_url_request_delegate.h" #include "content/browser/service_worker/embedded_worker_test_helper.h" @@ -74,7 +76,7 @@ // The |test_job_factory_| takes ownership of the interceptor. test_job_interceptor_ = new net::TestJobInterceptor(); EXPECT_TRUE(test_job_factory_.SetProtocolHandler( - url::kHttpScheme, make_scoped_ptr(test_job_interceptor_))); + url::kHttpScheme, base::WrapUnique(test_job_interceptor_))); url_request_context_->set_job_factory(&test_job_factory_); url_request_context_->Init(); @@ -107,10 +109,10 @@ std::string headers(kHttpHeaders, arraysize(kHttpHeaders)); scoped_refptr<net::IOBuffer> body(new net::WrappedIOBuffer(kHttpBody)); - scoped_ptr<ServiceWorkerResponseWriter> writer = + std::unique_ptr<ServiceWorkerResponseWriter> writer = context()->storage()->CreateResponseWriter(resource_id); - scoped_ptr<net::HttpResponseInfo> info(new net::HttpResponseInfo); + std::unique_ptr<net::HttpResponseInfo> info(new net::HttpResponseInfo); info->request_time = base::Time::Now(); info->response_time = base::Time::Now(); info->was_cached = false; @@ -169,7 +171,7 @@ protected: TestBrowserThreadBundle thread_bundle_; - scoped_ptr<EmbeddedWorkerTestHelper> helper_; + std::unique_ptr<EmbeddedWorkerTestHelper> helper_; scoped_refptr<ServiceWorkerRegistration> registration_; scoped_refptr<ServiceWorkerVersion> version_; @@ -180,16 +182,17 @@ net::TestJobInterceptor* test_job_interceptor_; net::URLRequestJobFactoryImpl test_job_factory_; - scoped_ptr<net::TestURLRequestContext> url_request_context_; + std::unique_ptr<net::TestURLRequestContext> url_request_context_; MockURLRequestDelegate delegate_; }; TEST_F(ServiceWorkerReadFromCacheJobTest, ReadMainScript) { // Read the main script from the diskcache. - scoped_ptr<net::URLRequest> request = url_request_context_->CreateRequest( - main_script_.url, net::DEFAULT_PRIORITY, &delegate_); + std::unique_ptr<net::URLRequest> request = + url_request_context_->CreateRequest(main_script_.url, + net::DEFAULT_PRIORITY, &delegate_); test_job_interceptor_->set_main_intercept_job( - make_scoped_ptr(new ServiceWorkerReadFromCacheJob( + base::WrapUnique(new ServiceWorkerReadFromCacheJob( request.get(), nullptr /* NetworkDelegate */, RESOURCE_TYPE_SERVICE_WORKER, context()->AsWeakPtr(), version_, main_script_.resource_id))); @@ -203,10 +206,11 @@ TEST_F(ServiceWorkerReadFromCacheJobTest, ReadImportedScript) { // Read the imported script from the diskcache. - scoped_ptr<net::URLRequest> request = url_request_context_->CreateRequest( - imported_script_.url, net::DEFAULT_PRIORITY, &delegate_); + std::unique_ptr<net::URLRequest> request = + url_request_context_->CreateRequest(imported_script_.url, + net::DEFAULT_PRIORITY, &delegate_); test_job_interceptor_->set_main_intercept_job( - make_scoped_ptr(new ServiceWorkerReadFromCacheJob( + base::WrapUnique(new ServiceWorkerReadFromCacheJob( request.get(), nullptr /* NetworkDelegate */, RESOURCE_TYPE_SCRIPT, context()->AsWeakPtr(), version_, imported_script_.resource_id))); StartAndWaitForRequest(request.get()); @@ -221,12 +225,13 @@ ASSERT_EQ(SERVICE_WORKER_OK, FindRegistration()); // Try to read a nonexistent resource from the diskcache. - scoped_ptr<net::URLRequest> request = url_request_context_->CreateRequest( - GURL("http://example.com/nonexistent"), net::DEFAULT_PRIORITY, - &delegate_); + std::unique_ptr<net::URLRequest> request = + url_request_context_->CreateRequest( + GURL("http://example.com/nonexistent"), net::DEFAULT_PRIORITY, + &delegate_); const int64_t kNonexistentResourceId = 100; test_job_interceptor_->set_main_intercept_job( - make_scoped_ptr(new ServiceWorkerReadFromCacheJob( + base::WrapUnique(new ServiceWorkerReadFromCacheJob( request.get(), nullptr /* NetworkDelegate */, RESOURCE_TYPE_SERVICE_WORKER, context()->AsWeakPtr(), version_, kNonexistentResourceId)));
diff --git a/content/browser/service_worker/service_worker_register_job.cc b/content/browser/service_worker/service_worker_register_job.cc index 2b443765..50e8dbd 100644 --- a/content/browser/service_worker/service_worker_register_job.cc +++ b/content/browser/service_worker/service_worker_register_job.cc
@@ -566,7 +566,7 @@ void ServiceWorkerRegisterJob::AddRegistrationToMatchingProviderHosts( ServiceWorkerRegistration* registration) { DCHECK(registration); - for (scoped_ptr<ServiceWorkerContextCore::ProviderHostIterator> it = + for (std::unique_ptr<ServiceWorkerContextCore::ProviderHostIterator> it = context_->GetProviderHostIterator(); !it->IsAtEnd(); it->Advance()) { ServiceWorkerProviderHost* host = it->GetProviderHost();
diff --git a/content/browser/service_worker/service_worker_registration.cc b/content/browser/service_worker/service_worker_registration.cc index 90aa7ff..b803edf 100644 --- a/content/browser/service_worker/service_worker_registration.cc +++ b/content/browser/service_worker/service_worker_registration.cc
@@ -184,7 +184,7 @@ DCHECK(context_); DCHECK(active_version()); - for (scoped_ptr<ServiceWorkerContextCore::ProviderHostIterator> it = + for (std::unique_ptr<ServiceWorkerContextCore::ProviderHostIterator> it = context_->GetProviderHostIterator(); !it->IsAtEnd(); it->Advance()) { ServiceWorkerProviderHost* host = it->GetProviderHost(); @@ -297,7 +297,7 @@ UnsetVersion(version.get()); - for (scoped_ptr<ServiceWorkerContextCore::ProviderHostIterator> it = + for (std::unique_ptr<ServiceWorkerContextCore::ProviderHostIterator> it = context_->GetProviderHostIterator(); !it->IsAtEnd(); it->Advance()) { ServiceWorkerProviderHost* host = it->GetProviderHost();
diff --git a/content/browser/service_worker/service_worker_registration.h b/content/browser/service_worker/service_worker_registration.h index 3450bcde..6b7739f0 100644 --- a/content/browser/service_worker/service_worker_registration.h +++ b/content/browser/service_worker/service_worker_registration.h
@@ -7,12 +7,12 @@ #include <stdint.h> +#include <memory> #include <string> #include "base/logging.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/service_worker/service_worker_version.h" #include "content/common/content_export.h" #include "content/common/service_worker/service_worker_types.h"
diff --git a/content/browser/service_worker/service_worker_registration_handle.h b/content/browser/service_worker/service_worker_registration_handle.h index 6fb4e07d..9ddd0c5 100644 --- a/content/browser/service_worker/service_worker_registration_handle.h +++ b/content/browser/service_worker/service_worker_registration_handle.h
@@ -5,9 +5,10 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_HANDLE_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_HANDLE_H_ +#include <memory> + #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "content/browser/service_worker/service_worker_registration.h" #include "content/browser/service_worker/service_worker_version.h"
diff --git a/content/browser/service_worker/service_worker_registration_unittest.cc b/content/browser/service_worker/service_worker_registration_unittest.cc index 78bbf93..0ec9985 100644 --- a/content/browser/service_worker/service_worker_registration_unittest.cc +++ b/content/browser/service_worker/service_worker_registration_unittest.cc
@@ -74,7 +74,7 @@ }; private: - scoped_ptr<EmbeddedWorkerTestHelper> helper_; + std::unique_ptr<EmbeddedWorkerTestHelper> helper_; TestBrowserThreadBundle thread_bundle_; }; @@ -152,7 +152,7 @@ scoped_refptr<ServiceWorkerRegistration> registration = new ServiceWorkerRegistration(kScope, kRegistrationId, context()->AsWeakPtr()); - scoped_ptr<ServiceWorkerRegistrationHandle> handle( + std::unique_ptr<ServiceWorkerRegistrationHandle> handle( new ServiceWorkerRegistrationHandle( context()->AsWeakPtr(), base::WeakPtr<ServiceWorkerProviderHost>(), registration.get()));
diff --git a/content/browser/service_worker/service_worker_request_handler.cc b/content/browser/service_worker/service_worker_request_handler.cc index f8190e2..0195e32d 100644 --- a/content/browser/service_worker/service_worker_request_handler.cc +++ b/content/browser/service_worker/service_worker_request_handler.cc
@@ -79,7 +79,7 @@ return; } - scoped_ptr<ServiceWorkerRequestHandler> handler( + std::unique_ptr<ServiceWorkerRequestHandler> handler( provider_host->CreateRequestHandler( request_mode, credentials_mode, redirect_mode, resource_type, request_context_type, frame_type, blob_storage_context->AsWeakPtr(), @@ -122,7 +122,7 @@ } // Initialize the SWProviderHost. - scoped_ptr<ServiceWorkerProviderHost> provider_host = + std::unique_ptr<ServiceWorkerProviderHost> provider_host = ServiceWorkerProviderHost::PreCreateNavigationHost( navigation_handle_core->context_wrapper()->context()->AsWeakPtr()); @@ -183,10 +183,10 @@ request->GetUserData(&kUserDataKey)); } -scoped_ptr<net::URLRequestInterceptor> +std::unique_ptr<net::URLRequestInterceptor> ServiceWorkerRequestHandler::CreateInterceptor( ResourceContext* resource_context) { - return scoped_ptr<net::URLRequestInterceptor>( + return std::unique_ptr<net::URLRequestInterceptor>( new ServiceWorkerRequestInterceptor(resource_context)); }
diff --git a/content/browser/service_worker/service_worker_request_handler.h b/content/browser/service_worker/service_worker_request_handler.h index e75a993e..ea192fd 100644 --- a/content/browser/service_worker/service_worker_request_handler.h +++ b/content/browser/service_worker/service_worker_request_handler.h
@@ -5,8 +5,9 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_ +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/supports_user_data.h" #include "base/time/time.h" @@ -84,7 +85,7 @@ net::URLRequest* request); // Creates a protocol interceptor for ServiceWorker. - static scoped_ptr<net::URLRequestInterceptor> CreateInterceptor( + static std::unique_ptr<net::URLRequestInterceptor> CreateInterceptor( ResourceContext* resource_context); // Returns true if the request falls into the scope of a ServiceWorker. @@ -128,7 +129,7 @@ ResourceType resource_type_; private: - scoped_ptr<ServiceWorkerProviderHost> host_for_cross_site_transfer_; + std::unique_ptr<ServiceWorkerProviderHost> host_for_cross_site_transfer_; int old_process_id_; int old_provider_id_;
diff --git a/content/browser/service_worker/service_worker_request_handler_unittest.cc b/content/browser/service_worker/service_worker_request_handler_unittest.cc index f2be209..56dcac6 100644 --- a/content/browser/service_worker/service_worker_request_handler_unittest.cc +++ b/content/browser/service_worker/service_worker_request_handler_unittest.cc
@@ -50,9 +50,11 @@ context()->AsWeakPtr()); // An empty host. - scoped_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( - helper_->mock_render_process_id(), MSG_ROUTING_NONE, kMockProviderId, - SERVICE_WORKER_PROVIDER_FOR_WINDOW, context()->AsWeakPtr(), nullptr)); + std::unique_ptr<ServiceWorkerProviderHost> host( + new ServiceWorkerProviderHost(helper_->mock_render_process_id(), + MSG_ROUTING_NONE, kMockProviderId, + SERVICE_WORKER_PROVIDER_FOR_WINDOW, + context()->AsWeakPtr(), nullptr)); host->SetDocumentUrl(GURL("http://host/scope/")); provider_host_ = host->AsWeakPtr(); context()->AddProviderHost(std::move(host)); @@ -87,8 +89,9 @@ bool skip_service_worker, ResourceType resource_type) { const GURL kDocUrl(url); - scoped_ptr<net::URLRequest> request = url_request_context_.CreateRequest( - kDocUrl, net::DEFAULT_PRIORITY, &url_request_delegate_); + std::unique_ptr<net::URLRequest> request = + url_request_context_.CreateRequest(kDocUrl, net::DEFAULT_PRIORITY, + &url_request_delegate_); request->set_method(method); ServiceWorkerRequestHandler::InitializeHandler( request.get(), context_wrapper(), &blob_storage_context_, @@ -102,7 +105,7 @@ protected: TestBrowserThreadBundle browser_thread_bundle_; - scoped_ptr<EmbeddedWorkerTestHelper> helper_; + std::unique_ptr<EmbeddedWorkerTestHelper> helper_; scoped_refptr<ServiceWorkerRegistration> registration_; scoped_refptr<ServiceWorkerVersion> version_; base::WeakPtr<ServiceWorkerProviderHost> provider_host_;
diff --git a/content/browser/service_worker/service_worker_script_cache_map.cc b/content/browser/service_worker/service_worker_script_cache_map.cc index 5a9f2b3..74f651a78 100644 --- a/content/browser/service_worker/service_worker_script_cache_map.cc +++ b/content/browser/service_worker/service_worker_script_cache_map.cc
@@ -100,7 +100,7 @@ scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(data.size())); if (data.size()) memmove(buffer->data(), &data[0], data.size()); - scoped_ptr<ServiceWorkerResponseMetadataWriter> writer; + std::unique_ptr<ServiceWorkerResponseMetadataWriter> writer; writer = context_->storage()->CreateResponseMetadataWriter( found->second.resource_id); ServiceWorkerResponseMetadataWriter* raw_writer = writer.get(); @@ -117,7 +117,7 @@ } void ServiceWorkerScriptCacheMap::OnMetadataWritten( - scoped_ptr<ServiceWorkerResponseMetadataWriter> writer, + std::unique_ptr<ServiceWorkerResponseMetadataWriter> writer, const net::CompletionCallback& callback, int result) { callback.Run(result);
diff --git a/content/browser/service_worker/service_worker_script_cache_map.h b/content/browser/service_worker/service_worker_script_cache_map.h index f2c27c6d..acd23f3d 100644 --- a/content/browser/service_worker/service_worker_script_cache_map.h +++ b/content/browser/service_worker/service_worker_script_cache_map.h
@@ -75,9 +75,10 @@ base::WeakPtr<ServiceWorkerContextCore> context); ~ServiceWorkerScriptCacheMap(); - void OnMetadataWritten(scoped_ptr<ServiceWorkerResponseMetadataWriter> writer, - const net::CompletionCallback& callback, - int result); + void OnMetadataWritten( + std::unique_ptr<ServiceWorkerResponseMetadataWriter> writer, + const net::CompletionCallback& callback, + int result); ServiceWorkerVersion* owner_; base::WeakPtr<ServiceWorkerContextCore> context_;
diff --git a/content/browser/service_worker/service_worker_storage.cc b/content/browser/service_worker/service_worker_storage.cc index ddb1e647..a015f23 100644 --- a/content/browser/service_worker/service_worker_storage.cc +++ b/content/browser/service_worker/service_worker_storage.cc
@@ -5,10 +5,12 @@ #include "content/browser/service_worker/service_worker_storage.h" #include <stddef.h> + #include <utility> #include "base/bind_helpers.h" #include "base/files/file_util.h" +#include "base/memory/ptr_util.h" #include "base/message_loop/message_loop.h" #include "base/sequenced_task_runner.h" #include "base/single_thread_task_runner.h" @@ -111,29 +113,26 @@ } // static -scoped_ptr<ServiceWorkerStorage> ServiceWorkerStorage::Create( +std::unique_ptr<ServiceWorkerStorage> ServiceWorkerStorage::Create( const base::FilePath& path, const base::WeakPtr<ServiceWorkerContextCore>& context, - scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager, + std::unique_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager, const scoped_refptr<base::SingleThreadTaskRunner>& disk_cache_thread, storage::QuotaManagerProxy* quota_manager_proxy, storage::SpecialStoragePolicy* special_storage_policy) { - return make_scoped_ptr(new ServiceWorkerStorage( + return base::WrapUnique(new ServiceWorkerStorage( path, context, std::move(database_task_manager), disk_cache_thread, quota_manager_proxy, special_storage_policy)); } // static -scoped_ptr<ServiceWorkerStorage> ServiceWorkerStorage::Create( +std::unique_ptr<ServiceWorkerStorage> ServiceWorkerStorage::Create( const base::WeakPtr<ServiceWorkerContextCore>& context, ServiceWorkerStorage* old_storage) { - return make_scoped_ptr( - new ServiceWorkerStorage(old_storage->path_, - context, - old_storage->database_task_manager_->Clone(), - old_storage->disk_cache_thread_, - old_storage->quota_manager_proxy_.get(), - old_storage->special_storage_policy_.get())); + return base::WrapUnique(new ServiceWorkerStorage( + old_storage->path_, context, old_storage->database_task_manager_->Clone(), + old_storage->disk_cache_thread_, old_storage->quota_manager_proxy_.get(), + old_storage->special_storage_policy_.get())); } void ServiceWorkerStorage::FindRegistrationForDocument( @@ -517,21 +516,21 @@ registration->set_is_deleted(true); } -scoped_ptr<ServiceWorkerResponseReader> +std::unique_ptr<ServiceWorkerResponseReader> ServiceWorkerStorage::CreateResponseReader(int64_t resource_id) { - return make_scoped_ptr( + return base::WrapUnique( new ServiceWorkerResponseReader(resource_id, disk_cache()->GetWeakPtr())); } -scoped_ptr<ServiceWorkerResponseWriter> +std::unique_ptr<ServiceWorkerResponseWriter> ServiceWorkerStorage::CreateResponseWriter(int64_t resource_id) { - return make_scoped_ptr( + return base::WrapUnique( new ServiceWorkerResponseWriter(resource_id, disk_cache()->GetWeakPtr())); } -scoped_ptr<ServiceWorkerResponseMetadataWriter> +std::unique_ptr<ServiceWorkerResponseMetadataWriter> ServiceWorkerStorage::CreateResponseMetadataWriter(int64_t resource_id) { - return make_scoped_ptr(new ServiceWorkerResponseMetadataWriter( + return base::WrapUnique(new ServiceWorkerResponseMetadataWriter( resource_id, disk_cache()->GetWeakPtr())); } @@ -780,7 +779,7 @@ ServiceWorkerStorage::ServiceWorkerStorage( const base::FilePath& path, base::WeakPtr<ServiceWorkerContextCore> context, - scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager, + std::unique_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager, const scoped_refptr<base::SingleThreadTaskRunner>& disk_cache_thread, storage::QuotaManagerProxy* quota_manager_proxy, storage::SpecialStoragePolicy* special_storage_policy) @@ -841,7 +840,7 @@ } void ServiceWorkerStorage::DidReadInitialData( - scoped_ptr<InitialData> data, + std::unique_ptr<InitialData> data, ServiceWorkerDatabase::Status status) { DCHECK(data); DCHECK_EQ(INITIALIZING, state_); @@ -1471,7 +1470,7 @@ scoped_refptr<base::SequencedTaskRunner> original_task_runner, const InitializeCallback& callback) { DCHECK(database); - scoped_ptr<ServiceWorkerStorage::InitialData> data( + std::unique_ptr<ServiceWorkerStorage::InitialData> data( new ServiceWorkerStorage::InitialData()); ServiceWorkerDatabase::Status status =
diff --git a/content/browser/service_worker/service_worker_storage.h b/content/browser/service_worker/service_worker_storage.h index c4dbe08..1ec4ed12 100644 --- a/content/browser/service_worker/service_worker_storage.h +++ b/content/browser/service_worker/service_worker_storage.h
@@ -77,16 +77,16 @@ ~ServiceWorkerStorage() override; - static scoped_ptr<ServiceWorkerStorage> Create( + static std::unique_ptr<ServiceWorkerStorage> Create( const base::FilePath& path, const base::WeakPtr<ServiceWorkerContextCore>& context, - scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager, + std::unique_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager, const scoped_refptr<base::SingleThreadTaskRunner>& disk_cache_thread, storage::QuotaManagerProxy* quota_manager_proxy, storage::SpecialStoragePolicy* special_storage_policy); // Used for DeleteAndStartOver. Creates new storage based on |old_storage|. - static scoped_ptr<ServiceWorkerStorage> Create( + static std::unique_ptr<ServiceWorkerStorage> Create( const base::WeakPtr<ServiceWorkerContextCore>& context, ServiceWorkerStorage* old_storage); @@ -150,12 +150,12 @@ // Creates a resource accessor. Never returns nullptr but an accessor may be // associated with the disabled disk cache if the storage is disabled. - scoped_ptr<ServiceWorkerResponseReader> CreateResponseReader( + std::unique_ptr<ServiceWorkerResponseReader> CreateResponseReader( int64_t resource_id); - scoped_ptr<ServiceWorkerResponseWriter> CreateResponseWriter( + std::unique_ptr<ServiceWorkerResponseWriter> CreateResponseWriter( int64_t resource_id); - scoped_ptr<ServiceWorkerResponseMetadataWriter> CreateResponseMetadataWriter( - int64_t resource_id); + std::unique_ptr<ServiceWorkerResponseMetadataWriter> + CreateResponseMetadataWriter(int64_t resource_id); // Adds |resource_id| to the set of resources that are in the disk cache // but not yet stored with a registration. @@ -292,7 +292,7 @@ typedef std::vector<ServiceWorkerDatabase::RegistrationData> RegistrationList; typedef std::map<int64_t, scoped_refptr<ServiceWorkerRegistration>> RegistrationRefsById; - typedef base::Callback<void(scoped_ptr<InitialData> data, + typedef base::Callback<void(std::unique_ptr<InitialData> data, ServiceWorkerDatabase::Status status)> InitializeCallback; typedef base::Callback<void(ServiceWorkerDatabase::Status status)> @@ -325,7 +325,7 @@ ServiceWorkerStorage( const base::FilePath& path, base::WeakPtr<ServiceWorkerContextCore> context, - scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager, + std::unique_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager, const scoped_refptr<base::SingleThreadTaskRunner>& disk_cache_thread, storage::QuotaManagerProxy* quota_manager_proxy, storage::SpecialStoragePolicy* special_storage_policy); @@ -335,7 +335,7 @@ bool LazyInitialize( const base::Closure& callback); - void DidReadInitialData(scoped_ptr<InitialData> data, + void DidReadInitialData(std::unique_ptr<InitialData> data, ServiceWorkerDatabase::Status status); void DidFindRegistrationForDocument( const GURL& document_url, @@ -528,14 +528,14 @@ base::WeakPtr<ServiceWorkerContextCore> context_; // Only accessed using |database_task_manager_|. - scoped_ptr<ServiceWorkerDatabase> database_; + std::unique_ptr<ServiceWorkerDatabase> database_; - scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager_; + std::unique_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager_; scoped_refptr<base::SingleThreadTaskRunner> disk_cache_thread_; scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy_; scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy_; - scoped_ptr<ServiceWorkerDiskCache> disk_cache_; + std::unique_ptr<ServiceWorkerDiskCache> disk_cache_; std::deque<int64_t> purgeable_resource_ids_; bool is_purge_pending_;
diff --git a/content/browser/service_worker/service_worker_storage_unittest.cc b/content/browser/service_worker/service_worker_storage_unittest.cc index a2a88ef..c1ee5ab 100644 --- a/content/browser/service_worker/service_worker_storage_unittest.cc +++ b/content/browser/service_worker/service_worker_storage_unittest.cc
@@ -144,10 +144,10 @@ const std::string& headers, IOBuffer* body, int length) { - scoped_ptr<ServiceWorkerResponseWriter> writer = + std::unique_ptr<ServiceWorkerResponseWriter> writer = storage->CreateResponseWriter(id); - scoped_ptr<net::HttpResponseInfo> info(new net::HttpResponseInfo); + std::unique_ptr<net::HttpResponseInfo> info(new net::HttpResponseInfo); info->request_time = base::Time::Now(); info->response_time = base::Time::Now(); info->was_cached = false; @@ -188,7 +188,7 @@ int ReadResponseInfo(ServiceWorkerStorage* storage, int64_t id, HttpResponseInfoIOBuffer* info_buffer) { - scoped_ptr<ServiceWorkerResponseReader> reader = + std::unique_ptr<ServiceWorkerResponseReader> reader = storage->CreateResponseReader(id); TestCompletionCallback cb; reader->ReadInfo(info_buffer, cb.callback()); @@ -199,7 +199,7 @@ int64_t id, bool expected_positive_result) { const std::string kExpectedHttpBody("Hello"); - scoped_ptr<ServiceWorkerResponseReader> reader = + std::unique_ptr<ServiceWorkerResponseReader> reader = storage->CreateResponseReader(id); scoped_refptr<HttpResponseInfoIOBuffer> info_buffer = new HttpResponseInfoIOBuffer(); @@ -234,7 +234,7 @@ int64_t id, const std::string& metadata) { scoped_refptr<IOBuffer> body_buffer(new WrappedIOBuffer(metadata.data())); - scoped_ptr<ServiceWorkerResponseMetadataWriter> metadata_writer = + std::unique_ptr<ServiceWorkerResponseMetadataWriter> metadata_writer = storage->CreateResponseMetadataWriter(id); TestCompletionCallback cb; metadata_writer->WriteMetadata(body_buffer.get(), metadata.length(), @@ -262,7 +262,7 @@ bool VerifyResponseMetadata(ServiceWorkerStorage* storage, int64_t id, const std::string& expected_metadata) { - scoped_ptr<ServiceWorkerResponseReader> reader = + std::unique_ptr<ServiceWorkerResponseReader> reader = storage->CreateResponseReader(id); scoped_refptr<HttpResponseInfoIOBuffer> info_buffer = new HttpResponseInfoIOBuffer(); @@ -506,7 +506,7 @@ // user_data_directory_ must be declared first to preserve destructor order. base::ScopedTempDir user_data_directory_; - scoped_ptr<EmbeddedWorkerTestHelper> helper_; + std::unique_ptr<EmbeddedWorkerTestHelper> helper_; TestBrowserThreadBundle browser_thread_bundle_; }; @@ -1221,7 +1221,7 @@ registration_->SetActiveVersion(registration_->waiting_version()); storage()->UpdateToActiveState( registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); - scoped_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( + std::unique_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( 33 /* dummy render process id */, MSG_ROUTING_NONE, 1 /* dummy provider_id */, SERVICE_WORKER_PROVIDER_FOR_WINDOW, context()->AsWeakPtr(), NULL)); @@ -1272,7 +1272,7 @@ registration_->SetWaitingVersion(NULL); storage()->UpdateToActiveState( registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); - scoped_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( + std::unique_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( 33 /* dummy render process id */, MSG_ROUTING_NONE, 1 /* dummy provider_id */, SERVICE_WORKER_PROVIDER_FOR_WINDOW, context()->AsWeakPtr(), NULL)); @@ -1431,7 +1431,7 @@ registration_->SetActiveVersion(registration_->waiting_version()); storage()->UpdateToActiveState( registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); - scoped_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( + std::unique_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( 33 /* dummy render process id */, MSG_ROUTING_NONE, 1 /* dummy provider_id */, SERVICE_WORKER_PROVIDER_FOR_WINDOW, context()->AsWeakPtr(), NULL));
diff --git a/content/browser/service_worker/service_worker_url_request_job.cc b/content/browser/service_worker/service_worker_url_request_job.cc index 47128f0..9dbd4bea 100644 --- a/content/browser/service_worker/service_worker_url_request_job.cc +++ b/content/browser/service_worker/service_worker_url_request_job.cc
@@ -6,8 +6,10 @@ #include <stddef.h> #include <stdint.h> + #include <limits> #include <map> +#include <memory> #include <string> #include <utility> #include <vector> @@ -15,7 +17,6 @@ #include "base/bind.h" #include "base/guid.h" #include "base/location.h" -#include "base/memory/scoped_ptr.h" #include "base/single_thread_task_runner.h" #include "base/strings/stringprintf.h" #include "base/thread_task_runner_handle.h" @@ -446,14 +447,14 @@ NOTREACHED(); } -scoped_ptr<ServiceWorkerFetchRequest> +std::unique_ptr<ServiceWorkerFetchRequest> ServiceWorkerURLRequestJob::CreateFetchRequest() { std::string blob_uuid; uint64_t blob_size = 0; // The upload data in URLRequest may have been cleared while handing redirect. if (request_->has_upload()) CreateRequestBodyBlob(&blob_uuid, &blob_size); - scoped_ptr<ServiceWorkerFetchRequest> request( + std::unique_ptr<ServiceWorkerFetchRequest> request( new ServiceWorkerFetchRequest()); request->mode = request_mode_; request->is_main_resource_load = IsMainResourceLoad(); @@ -495,8 +496,8 @@ return false; // To ensure the blobs stick around until the end of the reading. - std::vector<scoped_ptr<storage::BlobDataHandle>> handles; - std::vector<scoped_ptr<storage::BlobDataSnapshot>> snapshots; + std::vector<std::unique_ptr<storage::BlobDataHandle>> handles; + std::vector<std::unique_ptr<storage::BlobDataSnapshot>> snapshots; // TODO(dmurph): Allow blobs to be added below, so that the context can // efficiently re-use blob items for the new blob. std::vector<const ResourceRequestBody::Element*> resolved_elements; @@ -505,9 +506,10 @@ resolved_elements.push_back(&element); continue; } - scoped_ptr<storage::BlobDataHandle> handle = + std::unique_ptr<storage::BlobDataHandle> handle = blob_storage_context_->GetBlobDataFromUUID(element.blob_uuid()); - scoped_ptr<storage::BlobDataSnapshot> snapshot = handle->CreateSnapshot(); + std::unique_ptr<storage::BlobDataSnapshot> snapshot = + handle->CreateSnapshot(); if (snapshot->items().empty()) continue; const auto& items = snapshot->items(); @@ -688,7 +690,7 @@ // Set up a request for reading the blob. if (!response.blob_uuid.empty() && blob_storage_context_) { SetResponseBodyType(BLOB); - scoped_ptr<storage::BlobDataHandle> blob_data_handle = + std::unique_ptr<storage::BlobDataHandle> blob_data_handle = blob_storage_context_->GetBlobDataFromUUID(response.blob_uuid); if (!blob_data_handle) { // The renderer gave us a bad blob UUID.
diff --git a/content/browser/service_worker/service_worker_url_request_job.h b/content/browser/service_worker/service_worker_url_request_job.h index 9c4101f5..66635a5 100644 --- a/content/browser/service_worker/service_worker_url_request_job.h +++ b/content/browser/service_worker/service_worker_url_request_job.h
@@ -181,7 +181,7 @@ void StartRequest(); // Creates ServiceWorkerFetchRequest from |request_| and |body_|. - scoped_ptr<ServiceWorkerFetchRequest> CreateFetchRequest(); + std::unique_ptr<ServiceWorkerFetchRequest> CreateFetchRequest(); // Creates BlobDataHandle of the request body from |body_|. This handle // |request_body_blob_data_handle_| will be deleted when @@ -244,19 +244,19 @@ bool is_started_; net::HttpByteRange byte_range_; - scoped_ptr<net::HttpResponseInfo> range_response_info_; - scoped_ptr<net::HttpResponseInfo> http_response_info_; + std::unique_ptr<net::HttpResponseInfo> range_response_info_; + std::unique_ptr<net::HttpResponseInfo> http_response_info_; // Headers that have not yet been committed to |http_response_info_|. scoped_refptr<net::HttpResponseHeaders> http_response_headers_; GURL response_url_; blink::WebServiceWorkerResponseType service_worker_response_type_; // Used when response type is FORWARD_TO_SERVICE_WORKER. - scoped_ptr<ServiceWorkerFetchDispatcher> fetch_dispatcher_; + std::unique_ptr<ServiceWorkerFetchDispatcher> fetch_dispatcher_; std::string client_id_; base::WeakPtr<storage::BlobStorageContext> blob_storage_context_; const ResourceContext* resource_context_; - scoped_ptr<net::URLRequest> blob_request_; + std::unique_ptr<net::URLRequest> blob_request_; scoped_refptr<Stream> stream_; GURL waiting_stream_url_; scoped_refptr<net::IOBuffer> stream_pending_buffer_; @@ -272,7 +272,7 @@ // ResourceRequestBody has a collection of BlobDataHandles attached to it // using the userdata mechanism. So we have to keep it not to free the blobs. scoped_refptr<ResourceRequestBody> body_; - scoped_ptr<storage::BlobDataHandle> request_body_blob_data_handle_; + std::unique_ptr<storage::BlobDataHandle> request_body_blob_data_handle_; scoped_refptr<ServiceWorkerVersion> streaming_version_; ServiceWorkerFetchType fetch_type_;
diff --git a/content/browser/service_worker/service_worker_url_request_job_unittest.cc b/content/browser/service_worker/service_worker_url_request_job_unittest.cc index 6440dd1..47b3a527 100644 --- a/content/browser/service_worker/service_worker_url_request_job_unittest.cc +++ b/content/browser/service_worker/service_worker_url_request_job_unittest.cc
@@ -5,12 +5,14 @@ #include "content/browser/service_worker/service_worker_url_request_job.h" #include <stdint.h> + +#include <memory> #include <utility> #include <vector> #include "base/callback.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" +#include "base/memory/ptr_util.h" #include "base/message_loop/message_loop.h" #include "base/run_loop.h" #include "base/thread_task_runner_handle.h" @@ -206,11 +208,11 @@ // Returns a BlobProtocolHandler that uses |blob_storage_context|. Caller owns // the memory. -scoped_ptr<storage::BlobProtocolHandler> CreateMockBlobProtocolHandler( +std::unique_ptr<storage::BlobProtocolHandler> CreateMockBlobProtocolHandler( storage::BlobStorageContext* blob_storage_context) { // The FileSystemContext and task runner are not actually used but a // task runner is needed to avoid a DCHECK in BlobURLRequestJob ctor. - return make_scoped_ptr(new storage::BlobProtocolHandler( + return base::WrapUnique(new storage::BlobProtocolHandler( blob_storage_context, nullptr, base::ThreadTaskRunnerHandle::Get().get())); } @@ -272,7 +274,7 @@ version_->SetMainScriptHttpResponseInfo(http_info); } - scoped_ptr<ServiceWorkerProviderHost> provider_host( + std::unique_ptr<ServiceWorkerProviderHost> provider_host( new ServiceWorkerProviderHost( helper_->mock_render_process_id(), MSG_ROUTING_NONE, kProviderID, SERVICE_WORKER_PROVIDER_FOR_WINDOW, helper_->context()->AsWeakPtr(), @@ -293,7 +295,7 @@ url_request_job_factory_.reset(new net::URLRequestJobFactoryImpl); url_request_job_factory_->SetProtocolHandler( "http", - make_scoped_ptr(new MockHttpProtocolHandler( + base::WrapUnique(new MockHttpProtocolHandler( provider_host->AsWeakPtr(), browser_context_->GetResourceContext(), blob_storage_context->AsWeakPtr(), this))); url_request_job_factory_->SetProtocolHandler( @@ -401,17 +403,17 @@ TestBrowserThreadBundle thread_bundle_; - scoped_ptr<TestBrowserContext> browser_context_; - scoped_ptr<EmbeddedWorkerTestHelper> helper_; + std::unique_ptr<TestBrowserContext> browser_context_; + std::unique_ptr<EmbeddedWorkerTestHelper> helper_; scoped_refptr<ServiceWorkerRegistration> registration_; scoped_refptr<ServiceWorkerVersion> version_; - scoped_ptr<net::URLRequestJobFactoryImpl> url_request_job_factory_; + std::unique_ptr<net::URLRequestJobFactoryImpl> url_request_job_factory_; net::URLRequestContext url_request_context_; MockURLRequestDelegate url_request_delegate_; - scoped_ptr<net::URLRequest> request_; + std::unique_ptr<net::URLRequest> request_; - scoped_ptr<storage::BlobDataBuilder> blob_data_; + std::unique_ptr<storage::BlobDataBuilder> blob_data_; TestCallbackTracker callback_tracker_; base::WeakPtr<ServiceWorkerProviderHost> provider_host_; @@ -549,7 +551,7 @@ blob_data_->AppendData(kTestData); expected_response += kTestData; } - scoped_ptr<storage::BlobDataHandle> blob_handle = + std::unique_ptr<storage::BlobDataHandle> blob_handle = blob_storage_context->context()->AddFinishedBlob(blob_data_.get()); SetUpWithHelper( new BlobResponder(blob_handle->uuid(), expected_response.size()));
diff --git a/content/browser/service_worker/service_worker_version.cc b/content/browser/service_worker/service_worker_version.cc index cf3c209d..5cb4d5a82 100644 --- a/content/browser/service_worker/service_worker_version.cc +++ b/content/browser/service_worker/service_worker_version.cc
@@ -1353,7 +1353,7 @@ StartTimeoutTimer(); - scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params( + std::unique_ptr<EmbeddedWorkerMsg_StartWorker_Params> params( new EmbeddedWorkerMsg_StartWorker_Params()); params->service_worker_version_id = version_id_; params->scope = scope_;
diff --git a/content/browser/service_worker/service_worker_version.h b/content/browser/service_worker/service_worker_version.h index b951750..925380d 100644 --- a/content/browser/service_worker/service_worker_version.h +++ b/content/browser/service_worker/service_worker_version.h
@@ -9,6 +9,7 @@ #include <functional> #include <map> +#include <memory> #include <queue> #include <set> #include <string> @@ -19,8 +20,8 @@ #include "base/gtest_prod_util.h" #include "base/id_map.h" #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/observer_list.h" #include "base/thread_task_runner_handle.h" #include "base/timer/timer.h" @@ -386,7 +387,7 @@ // Compared as pointer, so should only contain static strings. Typically // this would be Interface::Name_ for some mojo interface. const char* mojo_service = nullptr; - scoped_ptr<EmbeddedWorkerInstance::Listener> listener; + std::unique_ptr<EmbeddedWorkerInstance::Listener> listener; }; // Base class to enable storing a list of mojo interface pointers for @@ -616,7 +617,7 @@ std::vector<url::Origin> foreign_fetch_origins_; Status status_ = NEW; - scoped_ptr<EmbeddedWorkerInstance> embedded_worker_; + std::unique_ptr<EmbeddedWorkerInstance> embedded_worker_; std::vector<StatusCallback> start_callbacks_; std::vector<StatusCallback> stop_callbacks_; std::vector<base::Closure> status_change_callbacks_; @@ -630,7 +631,7 @@ // from this map. // mojo_services_[Interface::Name_] is assumed to always contain a // MojoServiceWrapper<Interface> instance. - base::ScopedPtrHashMap<const char*, scoped_ptr<BaseMojoServiceWrapper>> + base::ScopedPtrHashMap<const char*, std::unique_ptr<BaseMojoServiceWrapper>> mojo_services_; std::set<const ServiceWorkerURLRequestJob*> streaming_url_request_jobs_; @@ -671,14 +672,14 @@ bool in_dtor_ = false; std::vector<int> pending_skip_waiting_requests_; - scoped_ptr<net::HttpResponseInfo> main_script_http_info_; + std::unique_ptr<net::HttpResponseInfo> main_script_http_info_; // If not OK, the reason that StartWorker failed. Used for // running |start_callbacks_|. ServiceWorkerStatusCode start_worker_status_ = SERVICE_WORKER_OK; - scoped_ptr<PingController> ping_controller_; - scoped_ptr<Metrics> metrics_; + std::unique_ptr<PingController> ping_controller_; + std::unique_ptr<Metrics> metrics_; const bool should_exclude_from_uma_ = false; base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; @@ -706,7 +707,7 @@ base::Bind(&ServiceWorkerVersion::OnMojoConnectionError, weak_factory_.GetWeakPtr(), Interface::Name_)); service = new MojoServiceWrapper<Interface>(this, std::move(interface)); - mojo_services_.add(Interface::Name_, make_scoped_ptr(service)); + mojo_services_.add(Interface::Name_, base::WrapUnique(service)); } request->mojo_service = Interface::Name_; return service->GetWeakPtr();
diff --git a/content/browser/service_worker/service_worker_version_unittest.cc b/content/browser/service_worker/service_worker_version_unittest.cc index 49a86ea..1f74c047 100644 --- a/content/browser/service_worker/service_worker_version_unittest.cc +++ b/content/browser/service_worker/service_worker_version_unittest.cc
@@ -2,9 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/browser/service_worker/service_worker_version.h" + #include <stdint.h> #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/run_loop.h" #include "content/browser/message_port_service.h" #include "content/browser/service_worker/embedded_worker_registry.h" @@ -12,7 +15,6 @@ #include "content/browser/service_worker/service_worker_context_core.h" #include "content/browser/service_worker/service_worker_registration.h" #include "content/browser/service_worker/service_worker_test_utils.h" -#include "content/browser/service_worker/service_worker_version.h" #include "content/common/service_worker/service_worker_utils.h" #include "content/public/test/mock_render_process_host.h" #include "content/public/test/test_browser_thread_bundle.h" @@ -237,8 +239,8 @@ ->PatternHasProcessToRun(pattern_)); } - virtual scoped_ptr<MessageReceiver> GetMessageReceiver() { - return make_scoped_ptr(new MessageReceiver()); + virtual std::unique_ptr<MessageReceiver> GetMessageReceiver() { + return base::WrapUnique(new MessageReceiver()); } void TearDown() override { @@ -271,7 +273,7 @@ } TestBrowserThreadBundle thread_bundle_; - scoped_ptr<MessageReceiver> helper_; + std::unique_ptr<MessageReceiver> helper_; scoped_refptr<ServiceWorkerRegistration> registration_; scoped_refptr<ServiceWorkerVersion> version_; GURL pattern_; @@ -325,8 +327,8 @@ helper->set_start_mode(mode); } - scoped_ptr<MessageReceiver> GetMessageReceiver() override { - return make_scoped_ptr(new MessageReceiverDisallowStart()); + std::unique_ptr<MessageReceiver> GetMessageReceiver() override { + return base::WrapUnique(new MessageReceiverDisallowStart()); } private: @@ -350,8 +352,8 @@ protected: ServiceWorkerStallInStoppingTest() : ServiceWorkerVersionTest() {} - scoped_ptr<MessageReceiver> GetMessageReceiver() override { - return make_scoped_ptr(new MessageReceiverDisallowStop()); + std::unique_ptr<MessageReceiver> GetMessageReceiver() override { + return base::WrapUnique(new MessageReceiverDisallowStop()); } private: @@ -375,8 +377,8 @@ protected: ServiceWorkerVersionWithMojoTest() : ServiceWorkerVersionTest() {} - scoped_ptr<MessageReceiver> GetMessageReceiver() override { - return make_scoped_ptr(new MessageReceiverMojoTestService()); + std::unique_ptr<MessageReceiver> GetMessageReceiver() override { + return base::WrapUnique(new MessageReceiverMojoTestService()); } private: @@ -626,7 +628,7 @@ // Adding a controllee resets the idle time. version_->idle_time_ -= kOneSecond; idle_time = version_->idle_time_; - scoped_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( + std::unique_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( 33 /* dummy render process id */, MSG_ROUTING_NONE /* render_frame_id */, 1 /* dummy provider_id */, SERVICE_WORKER_PROVIDER_FOR_WINDOW, helper_->context()->AsWeakPtr(), NULL));
diff --git a/content/browser/service_worker/service_worker_write_to_cache_job.cc b/content/browser/service_worker/service_worker_write_to_cache_job.cc index 96e9e8f..b1e7d4b 100644 --- a/content/browser/service_worker/service_worker_write_to_cache_job.cc +++ b/content/browser/service_worker/service_worker_write_to_cache_job.cc
@@ -478,7 +478,7 @@ return result; } -scoped_ptr<ServiceWorkerResponseReader> +std::unique_ptr<ServiceWorkerResponseReader> ServiceWorkerWriteToCacheJob::CreateCacheResponseReader() { if (incumbent_resource_id_ == kInvalidServiceWorkerResourceId || !version_->pause_after_download()) { @@ -487,7 +487,7 @@ return context_->storage()->CreateResponseReader(incumbent_resource_id_); } -scoped_ptr<ServiceWorkerResponseWriter> +std::unique_ptr<ServiceWorkerResponseWriter> ServiceWorkerWriteToCacheJob::CreateCacheResponseWriter() { return context_->storage()->CreateResponseWriter(resource_id_); }
diff --git a/content/browser/service_worker/service_worker_write_to_cache_job.h b/content/browser/service_worker/service_worker_write_to_cache_job.h index 314fcb2..6a8be3a0 100644 --- a/content/browser/service_worker/service_worker_write_to_cache_job.h +++ b/content/browser/service_worker/service_worker_write_to_cache_job.h
@@ -137,8 +137,8 @@ net::Error NotifyFinishedCaching(net::URLRequestStatus status, const std::string& status_message); - scoped_ptr<ServiceWorkerResponseReader> CreateCacheResponseReader(); - scoped_ptr<ServiceWorkerResponseWriter> CreateCacheResponseWriter(); + std::unique_ptr<ServiceWorkerResponseReader> CreateCacheResponseReader(); + std::unique_ptr<ServiceWorkerResponseWriter> CreateCacheResponseWriter(); ResourceType resource_type_; // Differentiate main script and imports scoped_refptr<net::IOBuffer> io_buffer_; @@ -147,11 +147,11 @@ GURL url_; int64_t resource_id_; int64_t incumbent_resource_id_; - scoped_ptr<net::URLRequest> net_request_; - scoped_ptr<net::HttpResponseInfo> http_info_; - scoped_ptr<ServiceWorkerResponseWriter> writer_; + std::unique_ptr<net::URLRequest> net_request_; + std::unique_ptr<net::HttpResponseInfo> http_info_; + std::unique_ptr<ServiceWorkerResponseWriter> writer_; scoped_refptr<ServiceWorkerVersion> version_; - scoped_ptr<ServiceWorkerCacheWriter> cache_writer_; + std::unique_ptr<ServiceWorkerCacheWriter> cache_writer_; bool has_been_killed_; bool did_notify_started_; bool did_notify_finished_;
diff --git a/content/browser/service_worker/service_worker_write_to_cache_job_unittest.cc b/content/browser/service_worker/service_worker_write_to_cache_job_unittest.cc index 7b9873d2..c47eeba 100644 --- a/content/browser/service_worker/service_worker_write_to_cache_job_unittest.cc +++ b/content/browser/service_worker/service_worker_write_to_cache_job_unittest.cc
@@ -4,10 +4,12 @@ #include <stddef.h> #include <stdint.h> + #include <utility> #include "base/location.h" #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/thread_task_runner_handle.h" @@ -202,7 +204,7 @@ class ResponseVerifier : public base::RefCounted<ResponseVerifier> { public: - ResponseVerifier(scoped_ptr<ServiceWorkerResponseReader> reader, + ResponseVerifier(std::unique_ptr<ServiceWorkerResponseReader> reader, const std::string& expected, const base::Callback<void(bool)> callback) : reader_(reader.release()), expected_(expected), callback_(callback) {} @@ -256,7 +258,7 @@ friend class base::RefCounted<ResponseVerifier>; ~ResponseVerifier() {} - scoped_ptr<ServiceWorkerResponseReader> reader_; + std::unique_ptr<ServiceWorkerResponseReader> reader_; const std::string expected_; base::Callback<void(bool)> callback_; scoped_refptr<HttpResponseInfoIOBuffer> info_buffer_; @@ -277,9 +279,10 @@ int process_id, int provider_id, const scoped_refptr<ServiceWorkerVersion>& version) { - scoped_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( - process_id, MSG_ROUTING_NONE, provider_id, - SERVICE_WORKER_PROVIDER_FOR_WORKER, context()->AsWeakPtr(), nullptr)); + std::unique_ptr<ServiceWorkerProviderHost> host( + new ServiceWorkerProviderHost(process_id, MSG_ROUTING_NONE, provider_id, + SERVICE_WORKER_PROVIDER_FOR_WORKER, + context()->AsWeakPtr(), nullptr)); base::WeakPtr<ServiceWorkerProviderHost> provider_host = host->AsWeakPtr(); context()->AddProviderHost(std::move(host)); provider_host->running_hosted_version_ = version; @@ -297,7 +300,7 @@ mock_protocol_handler_ = new MockHttpProtocolHandler(&resource_context_); url_request_job_factory_.reset(new net::URLRequestJobFactoryImpl); url_request_job_factory_->SetProtocolHandler( - "https", make_scoped_ptr(mock_protocol_handler_)); + "https", base::WrapUnique(mock_protocol_handler_)); url_request_context_->set_job_factory(url_request_job_factory_.get()); request_ = url_request_context_->CreateRequest( @@ -394,7 +397,7 @@ void VerifyResource(int id, const std::string& expected) { ASSERT_NE(kInvalidServiceWorkerResourceId, id); bool is_equal = false; - scoped_ptr<ServiceWorkerResponseReader> reader = + std::unique_ptr<ServiceWorkerResponseReader> reader = context()->storage()->CreateResponseReader(id); scoped_refptr<ResponseVerifier> verifier = new ResponseVerifier( std::move(reader), expected, CreateReceiverOnCurrentThread(&is_equal)); @@ -413,13 +416,13 @@ protected: TestBrowserThreadBundle browser_thread_bundle_; - scoped_ptr<EmbeddedWorkerTestHelper> helper_; + std::unique_ptr<EmbeddedWorkerTestHelper> helper_; scoped_refptr<ServiceWorkerRegistration> registration_; scoped_refptr<ServiceWorkerVersion> version_; base::WeakPtr<ServiceWorkerProviderHost> provider_host_; - scoped_ptr<net::URLRequestContext> url_request_context_; - scoped_ptr<net::URLRequestJobFactoryImpl> url_request_job_factory_; - scoped_ptr<net::URLRequest> request_; + std::unique_ptr<net::URLRequestContext> url_request_context_; + std::unique_ptr<net::URLRequestJobFactoryImpl> url_request_job_factory_; + std::unique_ptr<net::URLRequest> request_; MockHttpProtocolHandler* mock_protocol_handler_; storage::BlobStorageContext blob_storage_context_;
diff --git a/content/browser/session_history_browsertest.cc b/content/browser/session_history_browsertest.cc index dca5546..aae42f62 100644 --- a/content/browser/session_history_browsertest.cc +++ b/content/browser/session_history_browsertest.cc
@@ -27,14 +27,14 @@ namespace { // Handles |request| by serving a response with title set to request contents. -scoped_ptr<net::test_server::HttpResponse> HandleEchoTitleRequest( +std::unique_ptr<net::test_server::HttpResponse> HandleEchoTitleRequest( const std::string& echotitle_path, const net::test_server::HttpRequest& request) { if (!base::StartsWith(request.relative_url, echotitle_path, base::CompareCase::SENSITIVE)) - return scoped_ptr<net::test_server::HttpResponse>(); + return std::unique_ptr<net::test_server::HttpResponse>(); - scoped_ptr<net::test_server::BasicHttpResponse> http_response( + std::unique_ptr<net::test_server::BasicHttpResponse> http_response( new net::test_server::BasicHttpResponse); http_response->set_code(net::HTTP_OK); http_response->set_content(
diff --git a/content/browser/shared_worker/shared_worker_host.cc b/content/browser/shared_worker/shared_worker_host.cc index e98be02..bf32f77 100644 --- a/content/browser/shared_worker/shared_worker_host.cc +++ b/content/browser/shared_worker/shared_worker_host.cc
@@ -182,8 +182,9 @@ } } -void SharedWorkerHost::AllowFileSystem(const GURL& url, - scoped_ptr<IPC::Message> reply_msg) { +void SharedWorkerHost::AllowFileSystem( + const GURL& url, + std::unique_ptr<IPC::Message> reply_msg) { if (!instance_) return; GetContentClient()->browser()->AllowWorkerFileSystem( @@ -196,7 +197,7 @@ } void SharedWorkerHost::AllowFileSystemResponse( - scoped_ptr<IPC::Message> reply_msg, + std::unique_ptr<IPC::Message> reply_msg, bool allowed) { WorkerProcessHostMsg_RequestFileSystemAccessSync::WriteReplyParams( reply_msg.get(),
diff --git a/content/browser/shared_worker/shared_worker_host.h b/content/browser/shared_worker/shared_worker_host.h index 621c69b..63564405 100644 --- a/content/browser/shared_worker/shared_worker_host.h +++ b/content/browser/shared_worker/shared_worker_host.h
@@ -6,10 +6,10 @@ #define CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_HOST_H_ #include <list> +#include <memory> #include <vector> #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/strings/string16.h" #include "base/time/time.h" @@ -62,7 +62,8 @@ void WorkerScriptLoadFailed(); void WorkerConnected(int message_port_id); void WorkerContextDestroyed(); - void AllowFileSystem(const GURL& url, scoped_ptr<IPC::Message> reply_msg); + void AllowFileSystem(const GURL& url, + std::unique_ptr<IPC::Message> reply_msg); void AllowIndexedDB(const GURL& url, const base::string16& name, bool* result); @@ -115,9 +116,9 @@ void SetMessagePortID(SharedWorkerMessageFilter* filter, int route_id, int message_port_id); - void AllowFileSystemResponse(scoped_ptr<IPC::Message> reply_msg, + void AllowFileSystemResponse(std::unique_ptr<IPC::Message> reply_msg, bool allowed); - scoped_ptr<SharedWorkerInstance> instance_; + std::unique_ptr<SharedWorkerInstance> instance_; scoped_refptr<WorkerDocumentSet> worker_document_set_; FilterList filters_; SharedWorkerMessageFilter* container_render_filter_;
diff --git a/content/browser/shared_worker/shared_worker_instance_unittest.cc b/content/browser/shared_worker/shared_worker_instance_unittest.cc index 9e773f7..30b0662 100644 --- a/content/browser/shared_worker/shared_worker_instance_unittest.cc +++ b/content/browser/shared_worker/shared_worker_instance_unittest.cc
@@ -2,11 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/browser/shared_worker/shared_worker_instance.h" + +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" -#include "content/browser/shared_worker/shared_worker_instance.h" #include "content/browser/shared_worker/worker_storage_partition.h" #include "content/public/test/test_browser_context.h" #include "content/public/test/test_browser_thread_bundle.h" @@ -39,8 +41,8 @@ } TestBrowserThreadBundle thread_bundle_; - scoped_ptr<TestBrowserContext> browser_context_; - scoped_ptr<WorkerStoragePartition> partition_; + std::unique_ptr<TestBrowserContext> browser_context_; + std::unique_ptr<WorkerStoragePartition> partition_; const WorkerStoragePartitionId partition_id_; DISALLOW_COPY_AND_ASSIGN(SharedWorkerInstanceTest);
diff --git a/content/browser/shared_worker/shared_worker_service_impl.cc b/content/browser/shared_worker/shared_worker_service_impl.cc index 31443a39..7e5134c 100644 --- a/content/browser/shared_worker/shared_worker_service_impl.cc +++ b/content/browser/shared_worker/shared_worker_service_impl.cc
@@ -5,6 +5,7 @@ #include "content/browser/shared_worker/shared_worker_service_impl.h" #include <stddef.h> + #include <algorithm> #include <iterator> #include <set> @@ -13,6 +14,7 @@ #include "base/callback.h" #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/memory/ref_counted.h" #include "content/browser/devtools/shared_worker_devtools_manager.h" #include "content/browser/renderer_host/render_process_host_impl.h" @@ -129,7 +131,7 @@ typedef ScopedVector<SharedWorkerPendingRequest> SharedWorkerPendingRequests; explicit SharedWorkerPendingInstance( - scoped_ptr<SharedWorkerInstance> instance) + std::unique_ptr<SharedWorkerInstance> instance) : instance_(std::move(instance)) {} ~SharedWorkerPendingInstance() {} SharedWorkerInstance* instance() { return instance_.get(); } @@ -142,7 +144,7 @@ } return NULL; } - void AddRequest(scoped_ptr<SharedWorkerPendingRequest> request_info) { + void AddRequest(std::unique_ptr<SharedWorkerPendingRequest> request_info) { requests_.push_back(request_info.release()); } void RemoveRequest(int process_id) { @@ -172,7 +174,7 @@ } private: - scoped_ptr<SharedWorkerInstance> instance_; + std::unique_ptr<SharedWorkerInstance> instance_; SharedWorkerPendingRequests requests_; DISALLOW_COPY_AND_ASSIGN(SharedWorkerPendingInstance); }; @@ -290,16 +292,13 @@ blink::WebWorkerCreationError* creation_error) { DCHECK_CURRENTLY_ON(BrowserThread::IO); *creation_error = blink::WebWorkerCreationErrorNone; - scoped_ptr<SharedWorkerInstance> instance(new SharedWorkerInstance( + std::unique_ptr<SharedWorkerInstance> instance(new SharedWorkerInstance( params.url, params.name, params.content_security_policy, params.security_policy_type, params.creation_address_space, resource_context, partition_id, params.creation_context_type)); - scoped_ptr<SharedWorkerPendingInstance::SharedWorkerPendingRequest> request( - new SharedWorkerPendingInstance::SharedWorkerPendingRequest( - filter, - route_id, - params.document_id, - filter->render_process_id(), + std::unique_ptr<SharedWorkerPendingInstance::SharedWorkerPendingRequest> + request(new SharedWorkerPendingInstance::SharedWorkerPendingRequest( + filter, route_id, params.document_id, filter->render_process_id(), params.render_frame_route_id)); if (SharedWorkerPendingInstance* pending = FindPendingInstance(*instance)) { if (params.url != pending->instance()->url()) { @@ -313,7 +312,7 @@ pending->AddRequest(std::move(request)); return; } - scoped_ptr<SharedWorkerPendingInstance> pending_instance( + std::unique_ptr<SharedWorkerPendingInstance> pending_instance( new SharedWorkerPendingInstance(std::move(instance))); pending_instance->AddRequest(std::move(request)); ReserveRenderProcessToCreateWorker(std::move(pending_instance), @@ -354,9 +353,8 @@ int worker_route_id, SharedWorkerMessageFilter* filter) { ScopedWorkerDependencyChecker checker(this); - scoped_ptr<SharedWorkerHost> host = - worker_hosts_.take_and_erase(std::make_pair(filter->render_process_id(), - worker_route_id)); + std::unique_ptr<SharedWorkerHost> host = worker_hosts_.take_and_erase( + std::make_pair(filter->render_process_id(), worker_route_id)); if (!host) return; host->WorkerContextDestroyed(); @@ -380,9 +378,8 @@ int worker_route_id, SharedWorkerMessageFilter* filter) { ScopedWorkerDependencyChecker checker(this); - scoped_ptr<SharedWorkerHost> host = - worker_hosts_.take_and_erase(std::make_pair(filter->render_process_id(), - worker_route_id)); + std::unique_ptr<SharedWorkerHost> host = worker_hosts_.take_and_erase( + std::make_pair(filter->render_process_id(), worker_route_id)); if (!host) return; host->WorkerScriptLoadFailed(); @@ -402,7 +399,7 @@ IPC::Message* reply_msg, SharedWorkerMessageFilter* filter) { if (SharedWorkerHost* host = FindSharedWorkerHost(filter, worker_route_id)) { - host->AllowFileSystem(url, make_scoped_ptr(reply_msg)); + host->AllowFileSystem(url, base::WrapUnique(reply_msg)); } else { filter->Send(reply_msg); return; @@ -433,7 +430,7 @@ remove_list.push_back(iter->first); } for (size_t i = 0; i < remove_list.size(); ++i) { - scoped_ptr<SharedWorkerHost> host = + std::unique_ptr<SharedWorkerHost> host = worker_hosts_.take_and_erase(remove_list[i]); } @@ -456,7 +453,7 @@ } void SharedWorkerServiceImpl::ReserveRenderProcessToCreateWorker( - scoped_ptr<SharedWorkerPendingInstance> pending_instance, + std::unique_ptr<SharedWorkerPendingInstance> pending_instance, blink::WebWorkerCreationError* creation_error) { DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK(!FindPendingInstance(*pending_instance->instance())); @@ -530,7 +527,7 @@ // ScopeWorkerDependencyChecker's destructor. ScopedWorkerDependencyChecker checker( this, base::Bind(&DecrementWorkerRefCount, worker_process_id)); - scoped_ptr<SharedWorkerPendingInstance> pending_instance = + std::unique_ptr<SharedWorkerPendingInstance> pending_instance = pending_instances_.take_and_erase(pending_instance_id); if (!pending_instance) return; @@ -557,7 +554,7 @@ ReserveRenderProcessToCreateWorker(std::move(pending_instance), NULL); return; } - scoped_ptr<SharedWorkerHost> host(new SharedWorkerHost( + std::unique_ptr<SharedWorkerHost> host(new SharedWorkerHost( pending_instance->release_instance(), filter, worker_route_id)); pending_instance->RegisterToSharedWorkerHost(host.get()); const GURL url = host->instance()->url(); @@ -578,7 +575,7 @@ bool is_new_worker) { worker_hosts_.take_and_erase( std::make_pair(worker_process_id, worker_route_id)); - scoped_ptr<SharedWorkerPendingInstance> pending_instance = + std::unique_ptr<SharedWorkerPendingInstance> pending_instance = pending_instances_.take_and_erase(pending_instance_id); if (!pending_instance) return;
diff --git a/content/browser/shared_worker/shared_worker_service_impl.h b/content/browser/shared_worker/shared_worker_service_impl.h index 4af3bbf..22073e8 100644 --- a/content/browser/shared_worker/shared_worker_service_impl.h +++ b/content/browser/shared_worker/shared_worker_service_impl.h
@@ -5,12 +5,12 @@ #ifndef CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_SERVICE_IMPL_H_ #define CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_SERVICE_IMPL_H_ +#include <memory> #include <set> #include "base/compiler_specific.h" #include "base/containers/scoped_ptr_hash_map.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/singleton.h" #include "base/observer_list.h" #include "content/public/browser/notification_observer.h" @@ -104,8 +104,10 @@ // Pair of render_process_id and worker_route_id. typedef std::pair<int, int> ProcessRouteIdPair; typedef base::ScopedPtrHashMap<ProcessRouteIdPair, - scoped_ptr<SharedWorkerHost>> WorkerHostMap; - typedef base::ScopedPtrHashMap<int, scoped_ptr<SharedWorkerPendingInstance>> + std::unique_ptr<SharedWorkerHost>> + WorkerHostMap; + typedef base::ScopedPtrHashMap<int, + std::unique_ptr<SharedWorkerPendingInstance>> PendingInstanceMap; SharedWorkerServiceImpl(); @@ -118,7 +120,7 @@ // RenderProcessReservedCallback() or RenderProcessReserveFailedCallback() // will be called on IO thread. void ReserveRenderProcessToCreateWorker( - scoped_ptr<SharedWorkerPendingInstance> pending_instance, + std::unique_ptr<SharedWorkerPendingInstance> pending_instance, blink::WebWorkerCreationError* creation_error); // Called after the render process is reserved to create Shared Worker in it.
diff --git a/content/browser/shared_worker/shared_worker_service_impl_unittest.cc b/content/browser/shared_worker/shared_worker_service_impl_unittest.cc index 1c7d409..990f14a 100644 --- a/content/browser/shared_worker/shared_worker_service_impl_unittest.cc +++ b/content/browser/shared_worker/shared_worker_service_impl_unittest.cc
@@ -2,22 +2,23 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/browser/shared_worker/shared_worker_service_impl.h" + #include <stddef.h> #include <map> +#include <memory> #include <set> #include <vector> #include "base/atomic_sequence_num.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_vector.h" #include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" #include "base/synchronization/lock.h" #include "content/browser/message_port_message_filter.h" #include "content/browser/shared_worker/shared_worker_message_filter.h" -#include "content/browser/shared_worker/shared_worker_service_impl.h" #include "content/browser/shared_worker/worker_storage_partition.h" #include "content/common/message_port_messages.h" #include "content/common/view_messages.h" @@ -83,8 +84,8 @@ } TestBrowserThreadBundle browser_thread_bundle_; - scoped_ptr<TestBrowserContext> browser_context_; - scoped_ptr<WorkerStoragePartition> partition_; + std::unique_ptr<TestBrowserContext> browser_context_; + std::unique_ptr<WorkerStoragePartition> partition_; static int s_update_worker_dependency_call_count_; static std::vector<int> s_worker_dependency_added_ids_; static std::vector<int> s_worker_dependency_removed_ids_; @@ -188,14 +189,14 @@ } bool OnMessageReceived(IPC::Message* message) { - scoped_ptr<IPC::Message> msg(message); + std::unique_ptr<IPC::Message> msg(message); const bool ret = message_filter_->OnMessageReceived(*message) || worker_filter_->OnMessageReceived(*message); if (message->is_sync()) { CHECK(!queued_messages_.empty()); const IPC::Message* response_msg = queued_messages_.back(); IPC::SyncMessage* sync_msg = static_cast<IPC::SyncMessage*>(message); - scoped_ptr<IPC::MessageReplyDeserializer> reply_serializer( + std::unique_ptr<IPC::MessageReplyDeserializer> reply_serializer( sync_msg->GetReplyDeserializer()); bool result = reply_serializer->SerializeOutputParameters(*response_msg); CHECK(result); @@ -206,9 +207,9 @@ size_t QueuedMessageCount() const { return queued_messages_.size(); } - scoped_ptr<IPC::Message> PopMessage() { + std::unique_ptr<IPC::Message> PopMessage() { CHECK(queued_messages_.size()); - scoped_ptr<IPC::Message> msg(*queued_messages_.begin()); + std::unique_ptr<IPC::Message> msg(*queued_messages_.begin()); queued_messages_.weak_erase(queued_messages_.begin()); return msg; } @@ -328,7 +329,7 @@ const std::string& expected_name, blink::WebContentSecurityPolicyType expected_security_policy_type, int* route_id) { - scoped_ptr<IPC::Message> msg(renderer_host->PopMessage()); + std::unique_ptr<IPC::Message> msg(renderer_host->PopMessage()); EXPECT_EQ(WorkerProcessMsg_CreateWorker::ID, msg->type()); base::Tuple<WorkerProcessMsg_CreateWorker_Params> param; EXPECT_TRUE(WorkerProcessMsg_CreateWorker::Read(msg.get(), ¶m)); @@ -341,14 +342,14 @@ void CheckViewMsgWorkerCreated(MockRendererProcessHost* renderer_host, MockSharedWorkerConnector* connector) { - scoped_ptr<IPC::Message> msg(renderer_host->PopMessage()); + std::unique_ptr<IPC::Message> msg(renderer_host->PopMessage()); EXPECT_EQ(ViewMsg_WorkerCreated::ID, msg->type()); EXPECT_EQ(connector->route_id(), msg->routing_id()); } void CheckMessagePortMsgMessagesQueued(MockRendererProcessHost* renderer_host, MockSharedWorkerConnector* connector) { - scoped_ptr<IPC::Message> msg(renderer_host->PopMessage()); + std::unique_ptr<IPC::Message> msg(renderer_host->PopMessage()); EXPECT_EQ(MessagePortMsg_MessagesQueued::ID, msg->type()); EXPECT_EQ(connector->temporary_remote_port_route_id(), msg->routing_id()); } @@ -357,7 +358,7 @@ int expected_msg_route_id, int expected_sent_message_port_id, int* routing_id) { - scoped_ptr<IPC::Message> msg(renderer_host->PopMessage()); + std::unique_ptr<IPC::Message> msg(renderer_host->PopMessage()); EXPECT_EQ(WorkerMsg_Connect::ID, msg->type()); EXPECT_EQ(expected_msg_route_id, msg->routing_id()); WorkerMsg_Connect::Param params; @@ -370,7 +371,7 @@ void CheckMessagePortMsgMessage(MockRendererProcessHost* renderer_host, int expected_msg_route_id, std::string expected_data) { - scoped_ptr<IPC::Message> msg(renderer_host->PopMessage()); + std::unique_ptr<IPC::Message> msg(renderer_host->PopMessage()); EXPECT_EQ(MessagePortMsg_Message::ID, msg->type()); EXPECT_EQ(expected_msg_route_id, msg->routing_id()); MessagePortMsg_Message::Param params; @@ -381,7 +382,7 @@ void CheckViewMsgWorkerConnected(MockRendererProcessHost* renderer_host, MockSharedWorkerConnector* connector) { - scoped_ptr<IPC::Message> msg(renderer_host->PopMessage()); + std::unique_ptr<IPC::Message> msg(renderer_host->PopMessage()); EXPECT_EQ(ViewMsg_WorkerConnected::ID, msg->type()); EXPECT_EQ(connector->route_id(), msg->routing_id()); } @@ -389,11 +390,11 @@ } // namespace TEST_F(SharedWorkerServiceImplTest, BasicTest) { - scoped_ptr<MockRendererProcessHost> renderer_host( + std::unique_ptr<MockRendererProcessHost> renderer_host( new MockRendererProcessHost(kProcessIDs[0], browser_context_->GetResourceContext(), *partition_.get())); - scoped_ptr<MockSharedWorkerConnector> connector( + std::unique_ptr<MockSharedWorkerConnector> connector( new MockSharedWorkerConnector(renderer_host.get())); int worker_route_id; int worker_msg_port_route_id; @@ -486,11 +487,11 @@ TEST_F(SharedWorkerServiceImplTest, TwoRendererTest) { // The first renderer host. - scoped_ptr<MockRendererProcessHost> renderer_host0( + std::unique_ptr<MockRendererProcessHost> renderer_host0( new MockRendererProcessHost(kProcessIDs[0], browser_context_->GetResourceContext(), *partition_.get())); - scoped_ptr<MockSharedWorkerConnector> connector0( + std::unique_ptr<MockSharedWorkerConnector> connector0( new MockSharedWorkerConnector(renderer_host0.get())); int worker_route_id; int worker_msg_port_route_id1; @@ -578,11 +579,11 @@ renderer_host0.get(), connector0->local_port_route_id(), "test2"); // The second renderer host. - scoped_ptr<MockRendererProcessHost> renderer_host1( + std::unique_ptr<MockRendererProcessHost> renderer_host1( new MockRendererProcessHost(kProcessIDs[1], browser_context_->GetResourceContext(), *partition_.get())); - scoped_ptr<MockSharedWorkerConnector> connector1( + std::unique_ptr<MockSharedWorkerConnector> connector1( new MockSharedWorkerConnector(renderer_host1.get())); int worker_msg_port_route_id2; @@ -667,12 +668,12 @@ TEST_F(SharedWorkerServiceImplTest, CreateWorkerTest) { // The first renderer host. - scoped_ptr<MockRendererProcessHost> renderer_host0( + std::unique_ptr<MockRendererProcessHost> renderer_host0( new MockRendererProcessHost(kProcessIDs[0], browser_context_->GetResourceContext(), *partition_.get())); // The second renderer host. - scoped_ptr<MockRendererProcessHost> renderer_host1( + std::unique_ptr<MockRendererProcessHost> renderer_host1( new MockRendererProcessHost(kProcessIDs[1], browser_context_->GetResourceContext(), *partition_.get())); @@ -680,9 +681,9 @@ // Normal case. { - scoped_ptr<MockSharedWorkerConnector> connector0( + std::unique_ptr<MockSharedWorkerConnector> connector0( new MockSharedWorkerConnector(renderer_host0.get())); - scoped_ptr<MockSharedWorkerConnector> connector1( + std::unique_ptr<MockSharedWorkerConnector> connector1( new MockSharedWorkerConnector(renderer_host1.get())); connector0->Create("http://example.com/w1.js", "name1", @@ -711,9 +712,9 @@ // Normal case (URL mismatch). { - scoped_ptr<MockSharedWorkerConnector> connector0( + std::unique_ptr<MockSharedWorkerConnector> connector0( new MockSharedWorkerConnector(renderer_host0.get())); - scoped_ptr<MockSharedWorkerConnector> connector1( + std::unique_ptr<MockSharedWorkerConnector> connector1( new MockSharedWorkerConnector(renderer_host1.get())); connector0->Create("http://example.com/w2.js", "name2", @@ -743,9 +744,9 @@ // Pending case. { - scoped_ptr<MockSharedWorkerConnector> connector0( + std::unique_ptr<MockSharedWorkerConnector> connector0( new MockSharedWorkerConnector(renderer_host0.get())); - scoped_ptr<MockSharedWorkerConnector> connector1( + std::unique_ptr<MockSharedWorkerConnector> connector1( new MockSharedWorkerConnector(renderer_host1.get())); connector0->Create("http://example.com/w3.js", "name3", @@ -773,9 +774,9 @@ // Pending case (URL mismatch). { - scoped_ptr<MockSharedWorkerConnector> connector0( + std::unique_ptr<MockSharedWorkerConnector> connector0( new MockSharedWorkerConnector(renderer_host0.get())); - scoped_ptr<MockSharedWorkerConnector> connector1( + std::unique_ptr<MockSharedWorkerConnector> connector1( new MockSharedWorkerConnector(renderer_host1.get())); connector0->Create("http://example.com/w4.js", "name4", @@ -803,25 +804,25 @@ TEST_F(SharedWorkerServiceImplTest, CreateWorkerRaceTest) { // Create three renderer hosts. - scoped_ptr<MockRendererProcessHost> renderer_host0( + std::unique_ptr<MockRendererProcessHost> renderer_host0( new MockRendererProcessHost(kProcessIDs[0], browser_context_->GetResourceContext(), *partition_.get())); - scoped_ptr<MockRendererProcessHost> renderer_host1( + std::unique_ptr<MockRendererProcessHost> renderer_host1( new MockRendererProcessHost(kProcessIDs[1], browser_context_->GetResourceContext(), *partition_.get())); - scoped_ptr<MockRendererProcessHost> renderer_host2( + std::unique_ptr<MockRendererProcessHost> renderer_host2( new MockRendererProcessHost(kProcessIDs[2], browser_context_->GetResourceContext(), *partition_.get())); int worker_route_id; - scoped_ptr<MockSharedWorkerConnector> connector0( + std::unique_ptr<MockSharedWorkerConnector> connector0( new MockSharedWorkerConnector(renderer_host0.get())); - scoped_ptr<MockSharedWorkerConnector> connector1( + std::unique_ptr<MockSharedWorkerConnector> connector1( new MockSharedWorkerConnector(renderer_host1.get())); - scoped_ptr<MockSharedWorkerConnector> connector2( + std::unique_ptr<MockSharedWorkerConnector> connector2( new MockSharedWorkerConnector(renderer_host2.get())); connector0->Create("http://example.com/w1.js", "name1", @@ -867,25 +868,25 @@ TEST_F(SharedWorkerServiceImplTest, CreateWorkerRaceTest2) { // Create three renderer hosts. - scoped_ptr<MockRendererProcessHost> renderer_host0( + std::unique_ptr<MockRendererProcessHost> renderer_host0( new MockRendererProcessHost(kProcessIDs[0], browser_context_->GetResourceContext(), *partition_.get())); - scoped_ptr<MockRendererProcessHost> renderer_host1( + std::unique_ptr<MockRendererProcessHost> renderer_host1( new MockRendererProcessHost(kProcessIDs[1], browser_context_->GetResourceContext(), *partition_.get())); - scoped_ptr<MockRendererProcessHost> renderer_host2( + std::unique_ptr<MockRendererProcessHost> renderer_host2( new MockRendererProcessHost(kProcessIDs[2], browser_context_->GetResourceContext(), *partition_.get())); int worker_route_id; - scoped_ptr<MockSharedWorkerConnector> connector0( + std::unique_ptr<MockSharedWorkerConnector> connector0( new MockSharedWorkerConnector(renderer_host0.get())); - scoped_ptr<MockSharedWorkerConnector> connector1( + std::unique_ptr<MockSharedWorkerConnector> connector1( new MockSharedWorkerConnector(renderer_host1.get())); - scoped_ptr<MockSharedWorkerConnector> connector2( + std::unique_ptr<MockSharedWorkerConnector> connector2( new MockSharedWorkerConnector(renderer_host2.get())); connector0->Create("http://example.com/w1.js", "name1",
diff --git a/content/browser/site_instance_impl_unittest.cc b/content/browser/site_instance_impl_unittest.cc index 18cf06f..9a52e3b 100644 --- a/content/browser/site_instance_impl_unittest.cc +++ b/content/browser/site_instance_impl_unittest.cc
@@ -2,10 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/browser/site_instance_impl.h" + #include <stddef.h> #include "base/command_line.h" #include "base/compiler_specific.h" +#include "base/memory/ptr_util.h" #include "base/memory/scoped_vector.h" #include "base/strings/string16.h" #include "content/browser/browser_thread_impl.h" @@ -14,7 +17,6 @@ #include "content/browser/frame_host/navigation_entry_impl.h" #include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_view_host_impl.h" -#include "content/browser/site_instance_impl.h" #include "content/browser/web_contents/web_contents_impl.h" #include "content/browser/webui/content_web_ui_controller_factory.h" #include "content/browser/webui/web_ui_controller_factory_registry.h" @@ -191,9 +193,9 @@ // browsing_instance is now deleted // Ensure that instances are deleted when their RenderViewHosts are gone. - scoped_ptr<TestBrowserContext> browser_context(new TestBrowserContext()); + std::unique_ptr<TestBrowserContext> browser_context(new TestBrowserContext()); { - scoped_ptr<WebContentsImpl> web_contents(static_cast<WebContentsImpl*>( + std::unique_ptr<WebContentsImpl> web_contents(static_cast<WebContentsImpl*>( WebContents::Create(WebContents::CreateParams( browser_context.get(), SiteInstance::Create(browser_context.get()))))); @@ -216,12 +218,13 @@ TEST_F(SiteInstanceTest, CloneNavigationEntry) { const GURL url("test:foo"); - scoped_ptr<NavigationEntryImpl> e1 = make_scoped_ptr(new NavigationEntryImpl( - SiteInstanceImpl::Create(nullptr), 0, url, Referrer(), base::string16(), - ui::PAGE_TRANSITION_LINK, false)); + std::unique_ptr<NavigationEntryImpl> e1 = + base::WrapUnique(new NavigationEntryImpl( + SiteInstanceImpl::Create(nullptr), 0, url, Referrer(), + base::string16(), ui::PAGE_TRANSITION_LINK, false)); // Clone the entry. - scoped_ptr<NavigationEntryImpl> e2 = e1->Clone(); + std::unique_ptr<NavigationEntryImpl> e2 = e1->Clone(); // Should be able to change the SiteInstance of the cloned entry. e2->set_site_instance(SiteInstanceImpl::Create(nullptr)); @@ -246,8 +249,8 @@ // Test to ensure GetProcess returns and creates processes correctly. TEST_F(SiteInstanceTest, GetProcess) { // Ensure that GetProcess returns a process. - scoped_ptr<TestBrowserContext> browser_context(new TestBrowserContext()); - scoped_ptr<RenderProcessHost> host1; + std::unique_ptr<TestBrowserContext> browser_context(new TestBrowserContext()); + std::unique_ptr<RenderProcessHost> host1; scoped_refptr<SiteInstanceImpl> instance( SiteInstanceImpl::Create(browser_context.get())); host1.reset(instance->GetProcess()); @@ -256,7 +259,7 @@ // Ensure that GetProcess creates a new process. scoped_refptr<SiteInstanceImpl> instance2( SiteInstanceImpl::Create(browser_context.get())); - scoped_ptr<RenderProcessHost> host2(instance2->GetProcess()); + std::unique_ptr<RenderProcessHost> host2(instance2->GetProcess()); EXPECT_TRUE(host2.get() != nullptr); EXPECT_NE(host1.get(), host2.get()); @@ -381,7 +384,7 @@ TEST_F(SiteInstanceTest, OneSiteInstancePerSite) { ASSERT_FALSE(base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kProcessPerSite)); - scoped_ptr<TestBrowserContext> browser_context(new TestBrowserContext()); + std::unique_ptr<TestBrowserContext> browser_context(new TestBrowserContext()); BrowsingInstance* browsing_instance = new BrowsingInstance(browser_context.get()); @@ -423,8 +426,9 @@ // The two SiteInstances for http://google.com should not use the same process // if process-per-site is not enabled. - scoped_ptr<RenderProcessHost> process_a1(site_instance_a1->GetProcess()); - scoped_ptr<RenderProcessHost> process_a2_2(site_instance_a2_2->GetProcess()); + std::unique_ptr<RenderProcessHost> process_a1(site_instance_a1->GetProcess()); + std::unique_ptr<RenderProcessHost> process_a2_2( + site_instance_a2_2->GetProcess()); EXPECT_NE(process_a1.get(), process_a2_2.get()); // Should be able to see that we do have SiteInstances. @@ -452,7 +456,7 @@ TEST_F(SiteInstanceTest, OneSiteInstancePerSiteInBrowserContext) { base::CommandLine::ForCurrentProcess()->AppendSwitch( switches::kProcessPerSite); - scoped_ptr<TestBrowserContext> browser_context(new TestBrowserContext()); + std::unique_ptr<TestBrowserContext> browser_context(new TestBrowserContext()); scoped_refptr<BrowsingInstance> browsing_instance = new BrowsingInstance(browser_context.get()); @@ -460,7 +464,7 @@ scoped_refptr<SiteInstanceImpl> site_instance_a1( browsing_instance->GetSiteInstanceForURL(url_a1)); EXPECT_TRUE(site_instance_a1.get() != nullptr); - scoped_ptr<RenderProcessHost> process_a1(site_instance_a1->GetProcess()); + std::unique_ptr<RenderProcessHost> process_a1(site_instance_a1->GetProcess()); // A separate site should create a separate SiteInstance. const GURL url_b1("http://www.yahoo.com/"); @@ -493,13 +497,15 @@ // A visit to the original site in a new BrowsingInstance (different browser // context) should return a different SiteInstance with a different process. - scoped_ptr<TestBrowserContext> browser_context2(new TestBrowserContext()); + std::unique_ptr<TestBrowserContext> browser_context2( + new TestBrowserContext()); BrowsingInstance* browsing_instance3 = new BrowsingInstance(browser_context2.get()); scoped_refptr<SiteInstanceImpl> site_instance_a2_3( browsing_instance3->GetSiteInstanceForURL(url_a2)); EXPECT_TRUE(site_instance_a2_3.get() != nullptr); - scoped_ptr<RenderProcessHost> process_a2_3(site_instance_a2_3->GetProcess()); + std::unique_ptr<RenderProcessHost> process_a2_3( + site_instance_a2_3->GetProcess()); EXPECT_NE(site_instance_a1.get(), site_instance_a2_3.get()); EXPECT_NE(process_a1.get(), process_a2_3.get()); @@ -548,7 +554,7 @@ ChildProcessSecurityPolicyImpl::GetInstance(); // Make a bunch of mock renderers so that we hit the limit. - scoped_ptr<TestBrowserContext> browser_context(new TestBrowserContext()); + std::unique_ptr<TestBrowserContext> browser_context(new TestBrowserContext()); ScopedVector<MockRenderProcessHost> hosts; for (size_t i = 0; i < kMaxRendererProcessCount; ++i) hosts.push_back(new MockRenderProcessHost(browser_context.get())); @@ -563,7 +569,7 @@ CreateSiteInstance(browser_context.get(), GURL(kPrivilegedScheme + std::string("://baz/bar")))); - scoped_ptr<RenderProcessHost> extension_host( + std::unique_ptr<RenderProcessHost> extension_host( extension1_instance->GetProcess()); EXPECT_EQ(extension1_instance->GetProcess(), extension2_instance->GetProcess()); @@ -577,7 +583,7 @@ browser_context.get(), GURL(kChromeUIScheme + std::string("://media-internals")))); - scoped_ptr<RenderProcessHost> dom_host(webui1_instance->GetProcess()); + std::unique_ptr<RenderProcessHost> dom_host(webui1_instance->GetProcess()); EXPECT_EQ(webui1_instance->GetProcess(), webui2_instance->GetProcess()); // Make sure none of differing privilege processes are mixed. @@ -597,8 +603,8 @@ // Test to ensure that HasWrongProcessForURL behaves properly for different // types of URLs. TEST_F(SiteInstanceTest, HasWrongProcessForURL) { - scoped_ptr<TestBrowserContext> browser_context(new TestBrowserContext()); - scoped_ptr<RenderProcessHost> host; + std::unique_ptr<TestBrowserContext> browser_context(new TestBrowserContext()); + std::unique_ptr<RenderProcessHost> host; scoped_refptr<SiteInstanceImpl> instance( SiteInstanceImpl::Create(browser_context.get())); @@ -629,7 +635,7 @@ scoped_refptr<SiteInstanceImpl> webui_instance( SiteInstanceImpl::Create(browser_context.get())); webui_instance->SetSite(webui_url); - scoped_ptr<RenderProcessHost> webui_host(webui_instance->GetProcess()); + std::unique_ptr<RenderProcessHost> webui_host(webui_instance->GetProcess()); // Simulate granting WebUI bindings for the process. ChildProcessSecurityPolicyImpl::GetInstance()->GrantWebUIBindings( @@ -658,8 +664,8 @@ TEST_F(SiteInstanceTest, HasWrongProcessForURLInSitePerProcess) { IsolateAllSitesForTesting(base::CommandLine::ForCurrentProcess()); - scoped_ptr<TestBrowserContext> browser_context(new TestBrowserContext()); - scoped_ptr<RenderProcessHost> host; + std::unique_ptr<TestBrowserContext> browser_context(new TestBrowserContext()); + std::unique_ptr<RenderProcessHost> host; scoped_refptr<SiteInstanceImpl> instance( SiteInstanceImpl::Create(browser_context.get())); @@ -688,9 +694,9 @@ // Test that we do not reuse a process in process-per-site mode if it has the // wrong bindings for its URL. http://crbug.com/174059. TEST_F(SiteInstanceTest, ProcessPerSiteWithWrongBindings) { - scoped_ptr<TestBrowserContext> browser_context(new TestBrowserContext()); - scoped_ptr<RenderProcessHost> host; - scoped_ptr<RenderProcessHost> host2; + std::unique_ptr<TestBrowserContext> browser_context(new TestBrowserContext()); + std::unique_ptr<RenderProcessHost> host; + std::unique_ptr<RenderProcessHost> host2; scoped_refptr<SiteInstanceImpl> instance( SiteInstanceImpl::Create(browser_context.get())); @@ -730,8 +736,8 @@ TEST_F(SiteInstanceTest, NoProcessPerSiteForEmptySite) { base::CommandLine::ForCurrentProcess()->AppendSwitch( switches::kProcessPerSite); - scoped_ptr<TestBrowserContext> browser_context(new TestBrowserContext()); - scoped_ptr<RenderProcessHost> host; + std::unique_ptr<TestBrowserContext> browser_context(new TestBrowserContext()); + std::unique_ptr<RenderProcessHost> host; scoped_refptr<SiteInstanceImpl> instance( SiteInstanceImpl::Create(browser_context.get())); @@ -753,7 +759,7 @@ base::CommandLine::ForCurrentProcess()->AppendSwitch( switches::kTopDocumentIsolation); - scoped_ptr<TestBrowserContext> browser_context(new TestBrowserContext()); + std::unique_ptr<TestBrowserContext> browser_context(new TestBrowserContext()); scoped_refptr<SiteInstanceImpl> main_instance = SiteInstanceImpl::Create(browser_context.get()); scoped_refptr<SiteInstanceImpl> subframe_instance =
diff --git a/content/browser/site_per_process_browsertest.cc b/content/browser/site_per_process_browsertest.cc index ed46e5d6..978e63ea 100644 --- a/content/browser/site_per_process_browsertest.cc +++ b/content/browser/site_per_process_browsertest.cc
@@ -3150,7 +3150,7 @@ // JavaScript. Instead, try to navigate the second frame from the first // frame. This should fail with a console error message, which should // contain the second frame's updated origin (see blink::Frame::canNavigate). - scoped_ptr<ConsoleObserverDelegate> console_delegate( + std::unique_ptr<ConsoleObserverDelegate> console_delegate( new ConsoleObserverDelegate( shell()->web_contents(), "Unsafe JavaScript attempt to initiate navigation*")); @@ -4705,7 +4705,7 @@ gfx::Point center(150, 150); params.position = gfx::PointF(center.x(), center.y()); params.duration_ms = 100; - scoped_ptr<SyntheticTapGesture> gesture(new SyntheticTapGesture(params)); + std::unique_ptr<SyntheticTapGesture> gesture(new SyntheticTapGesture(params)); scoped_refptr<MessageLoopRunner> runner = new MessageLoopRunner(); @@ -6114,7 +6114,7 @@ "document.querySelector('iframe').style.display = 'none'")); // Waits until pending frames are done. - scoped_ptr<MainThreadFrameObserver> observer( + std::unique_ptr<MainThreadFrameObserver> observer( new MainThreadFrameObserver(root_render_widget_host)); observer->Wait();
diff --git a/content/browser/speech/audio_encoder.cc b/content/browser/speech/audio_encoder.cc index e4473a0..c4431cb 100644 --- a/content/browser/speech/audio_encoder.cc +++ b/content/browser/speech/audio_encoder.cc
@@ -6,8 +6,9 @@ #include <stddef.h> +#include <memory> + #include "base/logging.h" -#include "base/memory/scoped_ptr.h" #include "base/strings/string_number_conversions.h" #include "content/browser/speech/audio_buffer.h" @@ -62,7 +63,7 @@ // FLAC encoder wants samples as int32s. const int num_samples = raw_audio.NumSamples(); - scoped_ptr<FLAC__int32[]> flac_samples(new FLAC__int32[num_samples]); + std::unique_ptr<FLAC__int32[]> flac_samples(new FLAC__int32[num_samples]); FLAC__int32* flac_samples_ptr = flac_samples.get(); for (int i = 0; i < num_samples; ++i) flac_samples_ptr[i] = static_cast<FLAC__int32>(raw_audio.GetSample16(i));
diff --git a/content/browser/speech/chunked_byte_buffer.cc b/content/browser/speech/chunked_byte_buffer.cc index 7a05589..a43e40a 100644 --- a/content/browser/speech/chunked_byte_buffer.cc +++ b/content/browser/speech/chunked_byte_buffer.cc
@@ -103,10 +103,10 @@ return !chunks_.empty(); } -scoped_ptr<std::vector<uint8_t>> ChunkedByteBuffer::PopChunk() { +std::unique_ptr<std::vector<uint8_t>> ChunkedByteBuffer::PopChunk() { if (chunks_.empty()) - return scoped_ptr<std::vector<uint8_t>>(); - scoped_ptr<Chunk> chunk(*chunks_.begin()); + return std::unique_ptr<std::vector<uint8_t>>(); + std::unique_ptr<Chunk> chunk(*chunks_.begin()); chunks_.weak_erase(chunks_.begin()); DCHECK_EQ(chunk->header.size(), kHeaderLength); DCHECK_EQ(chunk->content->size(), chunk->ExpectedContentLength());
diff --git a/content/browser/speech/chunked_byte_buffer.h b/content/browser/speech/chunked_byte_buffer.h index 82e576c..41e273d 100644 --- a/content/browser/speech/chunked_byte_buffer.h +++ b/content/browser/speech/chunked_byte_buffer.h
@@ -8,11 +8,11 @@ #include <stddef.h> #include <stdint.h> +#include <memory> #include <string> #include <vector> #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_vector.h" #include "content/common/content_export.h" @@ -44,7 +44,7 @@ // If enough data is available, reads and removes the first complete chunk // from the buffer. Returns a NULL pointer if no complete chunk is available. - scoped_ptr<std::vector<uint8_t>> PopChunk(); + std::unique_ptr<std::vector<uint8_t>> PopChunk(); // Clears all the content of the buffer. void Clear(); @@ -58,7 +58,7 @@ ~Chunk(); std::vector<uint8_t> header; - scoped_ptr<std::vector<uint8_t>> content; + std::unique_ptr<std::vector<uint8_t>> content; size_t ExpectedContentLength() const; private: @@ -66,7 +66,7 @@ }; ScopedVector<Chunk> chunks_; - scoped_ptr<Chunk> partial_chunk_; + std::unique_ptr<Chunk> partial_chunk_; size_t total_bytes_stored_; DISALLOW_COPY_AND_ASSIGN(ChunkedByteBuffer);
diff --git a/content/browser/speech/chunked_byte_buffer_unittest.cc b/content/browser/speech/chunked_byte_buffer_unittest.cc index 5691975..d8a5cb27 100644 --- a/content/browser/speech/chunked_byte_buffer_unittest.cc +++ b/content/browser/speech/chunked_byte_buffer_unittest.cc
@@ -42,7 +42,7 @@ EXPECT_TRUE(buffer.HasChunks()); // Remove and check chunk 1. - scoped_ptr<ByteVector> chunk; + std::unique_ptr<ByteVector> chunk; chunk = buffer.PopChunk(); EXPECT_TRUE(chunk != NULL); EXPECT_EQ(4U, chunk->size());
diff --git a/content/browser/speech/endpointer/energy_endpointer.h b/content/browser/speech/endpointer/energy_endpointer.h index 27837bb..7b0b292a 100644 --- a/content/browser/speech/endpointer/energy_endpointer.h +++ b/content/browser/speech/endpointer/energy_endpointer.h
@@ -39,10 +39,10 @@ #include <stdint.h> +#include <memory> #include <vector> #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/speech/endpointer/energy_endpointer_params.h" #include "content/common/content_export.h" @@ -125,7 +125,7 @@ float sample_rate_; // Sampling rate. // Ring buffers to hold the speech activity history. - scoped_ptr<HistoryRing> history_; + std::unique_ptr<HistoryRing> history_; // Configuration parameters. EnergyEndpointerParams params_;
diff --git a/content/browser/speech/google_one_shot_remote_engine.cc b/content/browser/speech/google_one_shot_remote_engine.cc index 97743c9..0dd5bf37 100644 --- a/content/browser/speech/google_one_shot_remote_engine.cc +++ b/content/browser/speech/google_one_shot_remote_engine.cc
@@ -49,8 +49,9 @@ // Parse the response, ignoring comments. std::string error_msg; - scoped_ptr<base::Value> response_value = base::JSONReader::ReadAndReturnError( - response_body, base::JSON_PARSE_RFC, NULL, &error_msg); + std::unique_ptr<base::Value> response_value = + base::JSONReader::ReadAndReturnError(response_body, base::JSON_PARSE_RFC, + NULL, &error_msg); if (response_value == NULL) { LOG(WARNING) << "ParseServerResponse: JSONReader failed : " << error_msg; return false;
diff --git a/content/browser/speech/google_one_shot_remote_engine.h b/content/browser/speech/google_one_shot_remote_engine.h index 22063d2..c305bee 100644 --- a/content/browser/speech/google_one_shot_remote_engine.h +++ b/content/browser/speech/google_one_shot_remote_engine.h
@@ -5,11 +5,11 @@ #ifndef CONTENT_BROWSER_SPEECH_GOOGLE_ONE_SHOT_REMOTE_ENGINE_H_ #define CONTENT_BROWSER_SPEECH_GOOGLE_ONE_SHOT_REMOTE_ENGINE_H_ +#include <memory> #include <string> #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/speech/audio_encoder.h" #include "content/browser/speech/speech_recognition_engine.h" #include "content/common/content_export.h" @@ -49,9 +49,9 @@ private: SpeechRecognitionEngineConfig config_; - scoped_ptr<net::URLFetcher> url_fetcher_; + std::unique_ptr<net::URLFetcher> url_fetcher_; scoped_refptr<net::URLRequestContextGetter> url_context_; - scoped_ptr<AudioEncoder> encoder_; + std::unique_ptr<AudioEncoder> encoder_; DISALLOW_COPY_AND_ASSIGN(GoogleOneShotRemoteEngine); };
diff --git a/content/browser/speech/google_streaming_remote_engine.h b/content/browser/speech/google_streaming_remote_engine.h index 27abe2f..e2fcf22 100644 --- a/content/browser/speech/google_streaming_remote_engine.h +++ b/content/browser/speech/google_streaming_remote_engine.h
@@ -8,12 +8,12 @@ #include <stddef.h> #include <stdint.h> +#include <memory> #include <string> #include <vector> #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/threading/non_thread_safe.h" #include "content/browser/speech/audio_encoder.h" #include "content/browser/speech/chunked_byte_buffer.h" @@ -119,7 +119,7 @@ scoped_refptr<const AudioChunk> audio_data; // In case of EVENT_DOWNSTREAM_RESPONSE, hold the current chunk bytes. - scoped_ptr<std::vector<uint8_t>> response; + std::unique_ptr<std::vector<uint8_t>> response; private: DISALLOW_COPY_AND_ASSIGN(FSMEventArgs); @@ -158,11 +158,11 @@ void UploadAudioChunk(const std::string& data, FrameType type, bool is_final); SpeechRecognitionEngineConfig config_; - scoped_ptr<net::URLFetcher> upstream_fetcher_; - scoped_ptr<net::URLFetcher> downstream_fetcher_; + std::unique_ptr<net::URLFetcher> upstream_fetcher_; + std::unique_ptr<net::URLFetcher> downstream_fetcher_; scoped_refptr<net::URLRequestContextGetter> url_context_; - scoped_ptr<AudioEncoder> encoder_; - scoped_ptr<AudioEncoder> preamble_encoder_; + std::unique_ptr<AudioEncoder> encoder_; + std::unique_ptr<AudioEncoder> preamble_encoder_; ChunkedByteBuffer chunked_byte_buffer_; size_t previous_response_length_; bool got_last_definitive_result_;
diff --git a/content/browser/speech/google_streaming_remote_engine_unittest.cc b/content/browser/speech/google_streaming_remote_engine_unittest.cc index 62631e1..ec59465f 100644 --- a/content/browser/speech/google_streaming_remote_engine_unittest.cc +++ b/content/browser/speech/google_streaming_remote_engine_unittest.cc
@@ -2,19 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/browser/speech/google_streaming_remote_engine.h" + #include <stddef.h> #include <stdint.h> +#include <memory> #include <queue> #include "base/big_endian.h" -#include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" #include "base/numerics/safe_conversions.h" #include "base/strings/utf_string_conversions.h" #include "base/sys_byteorder.h" #include "content/browser/speech/audio_buffer.h" -#include "content/browser/speech/google_streaming_remote_engine.h" #include "content/browser/speech/proto/google_streaming_api.pb.h" #include "content/public/common/speech_recognition_error.h" #include "content/public/common/speech_recognition_result.h" @@ -94,7 +95,7 @@ void ExpectFramedChunk(const std::string& chunk, uint32_t type); void CloseMockDownstream(DownstreamError error); - scoped_ptr<GoogleStreamingRemoteEngine> engine_under_test_; + std::unique_ptr<GoogleStreamingRemoteEngine> engine_under_test_; TestURLFetcherFactory url_fetcher_factory_; size_t last_number_of_upstream_chunks_seen_; base::MessageLoop message_loop_;
diff --git a/content/browser/speech/speech_recognition_browsertest.cc b/content/browser/speech/speech_recognition_browsertest.cc index 6418881..c9aa4d88 100644 --- a/content/browser/speech/speech_recognition_browsertest.cc +++ b/content/browser/speech/speech_recognition_browsertest.cc
@@ -7,10 +7,10 @@ #include <string.h> #include <list> +#include <memory> #include "base/bind.h" #include "base/location.h" -#include "base/memory/scoped_ptr.h" #include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/strings/utf_string_conversions.h" @@ -141,7 +141,7 @@ bool fill_with_noise) { DCHECK(controller.get()); const media::AudioParameters& audio_params = controller->audio_parameters(); - scoped_ptr<uint8_t[]> audio_buffer(new uint8_t[buffer_size]); + std::unique_ptr<uint8_t[]> audio_buffer(new uint8_t[buffer_size]); if (fill_with_noise) { for (size_t i = 0; i < buffer_size; ++i) audio_buffer[i] = @@ -150,7 +150,7 @@ memset(audio_buffer.get(), 0, buffer_size); } - scoped_ptr<media::AudioBus> audio_bus = + std::unique_ptr<media::AudioBus> audio_bus = media::AudioBus::Create(audio_params); audio_bus->FromInterleaved(&audio_buffer.get()[0], audio_bus->frames(), @@ -189,7 +189,7 @@ } StreamingServerState streaming_server_state_; - scoped_ptr<MockGoogleStreamingServer> mock_streaming_server_; + std::unique_ptr<MockGoogleStreamingServer> mock_streaming_server_; media::TestAudioInputControllerFactory test_audio_input_controller_factory_; };
diff --git a/content/browser/speech/speech_recognition_dispatcher_host.h b/content/browser/speech/speech_recognition_dispatcher_host.h index a7a433b..76c4e78 100644 --- a/content/browser/speech/speech_recognition_dispatcher_host.h +++ b/content/browser/speech/speech_recognition_dispatcher_host.h
@@ -5,8 +5,9 @@ #ifndef CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_DISPATCHER_HOST_H_ #define CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_DISPATCHER_HOST_H_ +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "content/common/content_export.h" #include "content/public/browser/browser_message_filter.h"
diff --git a/content/browser/speech/speech_recognition_manager_impl.cc b/content/browser/speech/speech_recognition_manager_impl.cc index 06311bb..47b5995 100644 --- a/content/browser/speech/speech_recognition_manager_impl.cc +++ b/content/browser/speech/speech_recognition_manager_impl.cc
@@ -229,7 +229,7 @@ void SpeechRecognitionManagerImpl::MediaRequestPermissionCallback( int session_id, const MediaStreamDevices& devices, - scoped_ptr<MediaStreamUIProxy> stream_ui) { + std::unique_ptr<MediaStreamUIProxy> stream_ui) { DCHECK_CURRENTLY_ON(BrowserThread::IO); SessionsTable::iterator iter = sessions_.find(session_id);
diff --git a/content/browser/speech/speech_recognition_manager_impl.h b/content/browser/speech/speech_recognition_manager_impl.h index 93e9fd85..6175db6d 100644 --- a/content/browser/speech/speech_recognition_manager_impl.h +++ b/content/browser/speech/speech_recognition_manager_impl.h
@@ -131,7 +131,7 @@ SpeechRecognitionSessionConfig config; SpeechRecognitionSessionContext context; scoped_refptr<SpeechRecognizer> recognizer; - scoped_ptr<MediaStreamUIProxy> ui; + std::unique_ptr<MediaStreamUIProxy> ui; }; // Callback issued by the SpeechRecognitionManagerDelegate for reporting @@ -143,9 +143,10 @@ // Callback to get back the result of a media request. |devices| is an array // of devices approved to be used for the request, |devices| is empty if the // users deny the request. - void MediaRequestPermissionCallback(int session_id, - const MediaStreamDevices& devices, - scoped_ptr<MediaStreamUIProxy> stream_ui); + void MediaRequestPermissionCallback( + int session_id, + const MediaStreamDevices& devices, + std::unique_ptr<MediaStreamUIProxy> stream_ui); // Entry point for pushing any external event into the session handling FSM. void DispatchEvent(int session_id, FSMEvent event); @@ -180,7 +181,7 @@ int primary_session_id_; int last_session_id_; bool is_dispatching_event_; - scoped_ptr<SpeechRecognitionManagerDelegate> delegate_; + std::unique_ptr<SpeechRecognitionManagerDelegate> delegate_; // Used for posting asynchronous tasks (on the IO thread) without worrying // about this class being destroyed in the meanwhile (due to browser shutdown)
diff --git a/content/browser/speech/speech_recognizer_impl.cc b/content/browser/speech/speech_recognizer_impl.cc index f11b5d30..271675f 100644 --- a/content/browser/speech/speech_recognizer_impl.cc +++ b/content/browser/speech/speech_recognizer_impl.cc
@@ -55,8 +55,8 @@ // parameters. AudioConverter audio_converter_; - scoped_ptr<AudioBus> input_bus_; - scoped_ptr<AudioBus> output_bus_; + std::unique_ptr<AudioBus> input_bus_; + std::unique_ptr<AudioBus> output_bus_; const AudioParameters input_parameters_; const AudioParameters output_parameters_; bool data_was_converted_;
diff --git a/content/browser/speech/speech_recognizer_impl.h b/content/browser/speech/speech_recognizer_impl.h index 007142b..074d48a 100644 --- a/content/browser/speech/speech_recognizer_impl.h +++ b/content/browser/speech/speech_recognizer_impl.h
@@ -5,8 +5,9 @@ #ifndef CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_IMPL_H_ #define CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_IMPL_H_ +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/speech/endpointer/endpointer.h" #include "content/browser/speech/speech_recognition_engine.h" #include "content/browser/speech/speech_recognizer.h" @@ -148,10 +149,10 @@ static media::AudioManager* audio_manager_for_tests_; - scoped_ptr<SpeechRecognitionEngine> recognition_engine_; + std::unique_ptr<SpeechRecognitionEngine> recognition_engine_; Endpointer endpointer_; scoped_refptr<media::AudioInputController> audio_controller_; - scoped_ptr<media::AudioLog> audio_log_; + std::unique_ptr<media::AudioLog> audio_log_; int num_samples_recorded_; float audio_level_; bool is_dispatching_event_; @@ -164,7 +165,7 @@ // Converts data between native input format and a WebSpeech specific // output format. - scoped_ptr<SpeechRecognizerImpl::OnDataConverter> audio_converter_; + std::unique_ptr<SpeechRecognizerImpl::OnDataConverter> audio_converter_; DISALLOW_COPY_AND_ASSIGN(SpeechRecognizerImpl); };
diff --git a/content/browser/speech/speech_recognizer_impl_android.h b/content/browser/speech/speech_recognizer_impl_android.h index e51a9e4..f0a940e6 100644 --- a/content/browser/speech/speech_recognizer_impl_android.h +++ b/content/browser/speech/speech_recognizer_impl_android.h
@@ -7,10 +7,11 @@ #include <jni.h> +#include <memory> + #include "base/android/scoped_java_ref.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/speech/speech_recognizer.h" #include "content/public/common/speech_recognition_error.h" #include "content/public/common/speech_recognition_result.h"
diff --git a/content/browser/speech/speech_recognizer_impl_unittest.cc b/content/browser/speech/speech_recognizer_impl_unittest.cc index 300e405..d93fdcf7 100644 --- a/content/browser/speech/speech_recognizer_impl_unittest.cc +++ b/content/browser/speech/speech_recognizer_impl_unittest.cc
@@ -185,7 +185,7 @@ base::MessageLoopForIO message_loop_; BrowserThreadImpl io_thread_; scoped_refptr<SpeechRecognizerImpl> recognizer_; - scoped_ptr<AudioManager> audio_manager_; + std::unique_ptr<AudioManager> audio_manager_; bool recognition_started_; bool recognition_ended_; bool result_received_; @@ -197,7 +197,7 @@ net::TestURLFetcherFactory url_fetcher_factory_; TestAudioInputControllerFactory audio_input_controller_factory_; std::vector<uint8_t> audio_packet_; - scoped_ptr<media::AudioBus> audio_bus_; + std::unique_ptr<media::AudioBus> audio_bus_; int bytes_per_sample_; float volume_; float noise_volume_;
diff --git a/content/browser/ssl/ssl_client_auth_handler.cc b/content/browser/ssl/ssl_client_auth_handler.cc index 9f5efae..e8c34a5 100644 --- a/content/browser/ssl/ssl_client_auth_handler.cc +++ b/content/browser/ssl/ssl_client_auth_handler.cc
@@ -62,7 +62,7 @@ const base::WeakPtr<SSLClientAuthHandler>& handler) { DCHECK_CURRENTLY_ON(BrowserThread::UI); - scoped_ptr<ClientCertificateDelegate> delegate( + std::unique_ptr<ClientCertificateDelegate> delegate( new ClientCertificateDelegateImpl(handler)); RenderFrameHost* rfh = @@ -82,7 +82,7 @@ class SSLClientAuthHandler::Core : public base::RefCountedThreadSafe<Core> { public: Core(const base::WeakPtr<SSLClientAuthHandler>& handler, - scoped_ptr<net::ClientCertStore> client_cert_store, + std::unique_ptr<net::ClientCertStore> client_cert_store, net::SSLCertRequestInfo* cert_request_info) : handler_(handler), client_cert_store_(std::move(client_cert_store)), @@ -116,12 +116,12 @@ } base::WeakPtr<SSLClientAuthHandler> handler_; - scoped_ptr<net::ClientCertStore> client_cert_store_; + std::unique_ptr<net::ClientCertStore> client_cert_store_; scoped_refptr<net::SSLCertRequestInfo> cert_request_info_; }; SSLClientAuthHandler::SSLClientAuthHandler( - scoped_ptr<net::ClientCertStore> client_cert_store, + std::unique_ptr<net::ClientCertStore> client_cert_store, net::URLRequest* request, net::SSLCertRequestInfo* cert_request_info, SSLClientAuthHandler::Delegate* delegate)
diff --git a/content/browser/ssl/ssl_client_auth_handler.h b/content/browser/ssl/ssl_client_auth_handler.h index 1deafbc..46782d73 100644 --- a/content/browser/ssl/ssl_client_auth_handler.h +++ b/content/browser/ssl/ssl_client_auth_handler.h
@@ -5,10 +5,11 @@ #ifndef CONTENT_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ #define CONTENT_BROWSER_SSL_SSL_CLIENT_AUTH_HANDLER_H_ +#include <memory> + #include "base/callback.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "content/common/content_export.h" #include "content/public/browser/browser_thread.h" @@ -49,7 +50,7 @@ // Creates a new SSLClientAuthHandler. The caller ensures that the handler // does not outlive |request| or |delegate|. - SSLClientAuthHandler(scoped_ptr<net::ClientCertStore> client_cert_store, + SSLClientAuthHandler(std::unique_ptr<net::ClientCertStore> client_cert_store, net::URLRequest* request, net::SSLCertRequestInfo* cert_request_info, Delegate* delegate);
diff --git a/content/browser/ssl/ssl_manager.h b/content/browser/ssl/ssl_manager.h index 6a837750..18c26c6 100644 --- a/content/browser/ssl/ssl_manager.h +++ b/content/browser/ssl/ssl_manager.h
@@ -5,10 +5,10 @@ #ifndef CONTENT_BROWSER_SSL_SSL_MANAGER_H_ #define CONTENT_BROWSER_SSL_SSL_MANAGER_H_ +#include <memory> #include <string> #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "content/browser/ssl/ssl_error_handler.h" #include "content/browser/ssl/ssl_policy_backend.h" @@ -104,7 +104,7 @@ SSLPolicyBackend backend_; // The SSLPolicy instance for this manager. - scoped_ptr<SSLPolicy> policy_; + std::unique_ptr<SSLPolicy> policy_; // The NavigationController that owns this SSLManager. We are responsible // for the security UI of this tab.
diff --git a/content/browser/storage_partition_impl_map.cc b/content/browser/storage_partition_impl_map.cc index 83360f39..58852c2 100644 --- a/content/browser/storage_partition_impl_map.cc +++ b/content/browser/storage_partition_impl_map.cc
@@ -94,7 +94,7 @@ const scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; const scoped_refptr<StreamContext> stream_context_; const scoped_refptr<storage::FileSystemContext> file_system_context_; - mutable scoped_ptr<storage::BlobProtocolHandler> blob_protocol_handler_; + mutable std::unique_ptr<storage::BlobProtocolHandler> blob_protocol_handler_; DISALLOW_COPY_AND_ASSIGN(BlobProtocolHandler); }; @@ -313,7 +313,7 @@ void BlockingGarbageCollect( const base::FilePath& storage_root, const scoped_refptr<base::TaskRunner>& file_access_runner, - scoped_ptr<base::hash_set<base::FilePath> > active_paths) { + std::unique_ptr<base::hash_set<base::FilePath>> active_paths) { CHECK(storage_root.IsAbsolute()); NormalizeActivePaths(storage_root, active_paths.get()); @@ -533,7 +533,7 @@ } void StoragePartitionImplMap::GarbageCollect( - scoped_ptr<base::hash_set<base::FilePath> > active_paths, + std::unique_ptr<base::hash_set<base::FilePath>> active_paths, const base::Closure& done) { // Include all paths for current StoragePartitions in the active_paths since // they cannot be deleted safely.
diff --git a/content/browser/storage_partition_impl_map.h b/content/browser/storage_partition_impl_map.h index 92427f8..00b01f1e 100644 --- a/content/browser/storage_partition_impl_map.h +++ b/content/browser/storage_partition_impl_map.h
@@ -51,8 +51,9 @@ // // The |done| closure is executed on the calling thread when garbage // collection is complete. - void GarbageCollect(scoped_ptr<base::hash_set<base::FilePath> > active_paths, - const base::Closure& done); + void GarbageCollect( + std::unique_ptr<base::hash_set<base::FilePath>> active_paths, + const base::Closure& done); void ForEach(const BrowserContext::StoragePartitionCallback& callback);
diff --git a/content/browser/storage_partition_impl_map_unittest.cc b/content/browser/storage_partition_impl_map_unittest.cc index 2659b8e3..8ec82e4 100644 --- a/content/browser/storage_partition_impl_map_unittest.cc +++ b/content/browser/storage_partition_impl_map_unittest.cc
@@ -69,7 +69,7 @@ base::MessageLoop message_loop; StoragePartitionImplMap storage_partition_impl_map(&browser_context); - scoped_ptr<base::hash_set<base::FilePath> > active_paths( + std::unique_ptr<base::hash_set<base::FilePath>> active_paths( new base::hash_set<base::FilePath>); base::FilePath active_path = browser_context.GetPath().Append(
diff --git a/content/browser/storage_partition_impl_unittest.cc b/content/browser/storage_partition_impl_unittest.cc index 22f0185..0d0f183 100644 --- a/content/browser/storage_partition_impl_unittest.cc +++ b/content/browser/storage_partition_impl_unittest.cc
@@ -350,7 +350,7 @@ private: content::TestBrowserThreadBundle thread_bundle_; - scoped_ptr<TestBrowserContext> browser_context_; + std::unique_ptr<TestBrowserContext> browser_context_; scoped_refptr<MockQuotaManager> quota_manager_; DISALLOW_COPY_AND_ASSIGN(StoragePartitionImplTest); @@ -395,7 +395,7 @@ private: content::TestBrowserThreadBundle thread_bundle_; - scoped_ptr<TestBrowserContext> browser_context_; + std::unique_ptr<TestBrowserContext> browser_context_; scoped_refptr<ShaderDiskCache> cache_; }; @@ -932,13 +932,13 @@ StoragePartitionImpl::CreatePredicateForHostCookies(url); base::Time now = base::Time::Now(); - std::vector<scoped_ptr<CanonicalCookie>> valid_cookies; + std::vector<std::unique_ptr<CanonicalCookie>> valid_cookies; valid_cookies.push_back(CanonicalCookie::Create(url, "A=B", now, options)); valid_cookies.push_back(CanonicalCookie::Create(url, "C=F", now, options)); // We should match a different scheme with the same host. valid_cookies.push_back(CanonicalCookie::Create(url2, "A=B", now, options)); - std::vector<scoped_ptr<CanonicalCookie>> invalid_cookies; + std::vector<std::unique_ptr<CanonicalCookie>> invalid_cookies; // We don't match domain cookies. invalid_cookies.push_back( CanonicalCookie::Create(url2, "A=B;domain=.example.com", now, options));
diff --git a/content/browser/streams/stream.cc b/content/browser/streams/stream.cc index d3a3ec4..bc560dbf 100644 --- a/content/browser/streams/stream.cc +++ b/content/browser/streams/stream.cc
@@ -165,10 +165,10 @@ return STREAM_HAS_DATA; } -scoped_ptr<StreamHandle> Stream::CreateHandle() { +std::unique_ptr<StreamHandle> Stream::CreateHandle() { CHECK(!stream_handle_); stream_handle_ = new StreamHandleImpl(weak_ptr_factory_.GetWeakPtr()); - return scoped_ptr<StreamHandle>(stream_handle_); + return std::unique_ptr<StreamHandle>(stream_handle_); } void Stream::CloseHandle() {
diff --git a/content/browser/streams/stream.h b/content/browser/streams/stream.h index 3f3d06a..1422da5 100644 --- a/content/browser/streams/stream.h +++ b/content/browser/streams/stream.h
@@ -82,7 +82,7 @@ // and STREAM_COMPLETE if the stream is finalized and all data has been read. StreamState ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read); - scoped_ptr<StreamHandle> CreateHandle(); + std::unique_ptr<StreamHandle> CreateHandle(); void CloseHandle(); // Indicates whether there is space in the buffer to add more data. @@ -123,8 +123,8 @@ // in order to check memory usage. size_t last_total_buffered_bytes_; - scoped_ptr<ByteStreamWriter> writer_; - scoped_ptr<ByteStreamReader> reader_; + std::unique_ptr<ByteStreamWriter> writer_; + std::unique_ptr<ByteStreamReader> reader_; StreamRegistry* registry_; StreamReadObserver* read_observer_;
diff --git a/content/browser/streams/stream_context.h b/content/browser/streams/stream_context.h index ad8f65c..075ae3e 100644 --- a/content/browser/streams/stream_context.h +++ b/content/browser/streams/stream_context.h
@@ -5,8 +5,9 @@ #ifndef CONTENT_BROWSER_STREAMS_STREAM_CONTEXT_H_ #define CONTENT_BROWSER_STREAMS_STREAM_CONTEXT_H_ +#include <memory> + #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/sequenced_task_runner_helpers.h" #include "content/common/content_export.h" @@ -45,7 +46,7 @@ void DeleteOnCorrectThread() const; - scoped_ptr<StreamRegistry> registry_; + std::unique_ptr<StreamRegistry> registry_; }; struct StreamContextDeleter {
diff --git a/content/browser/streams/stream_unittest.cc b/content/browser/streams/stream_unittest.cc index af2b003..2da9a36c 100644 --- a/content/browser/streams/stream_unittest.cc +++ b/content/browser/streams/stream_unittest.cc
@@ -34,7 +34,7 @@ protected: base::MessageLoop message_loop_; - scoped_ptr<StreamRegistry> registry_; + std::unique_ptr<StreamRegistry> registry_; private: int producing_seed_key_; @@ -132,9 +132,9 @@ TestStreamWriter writer2; GURL url1("blob://stream1"); GURL url2("blob://stream2"); - scoped_ptr<TestStreamObserver> observer1( + std::unique_ptr<TestStreamObserver> observer1( new TestStreamObserver(url1, registry_.get())); - scoped_ptr<TestStreamObserver> observer2( + std::unique_ptr<TestStreamObserver> observer2( new TestStreamObserver(url2, registry_.get())); scoped_refptr<Stream> stream1(new Stream(registry_.get(), &writer1, url1)); EXPECT_TRUE(observer1->registered());
diff --git a/content/browser/streams/stream_url_request_job.h b/content/browser/streams/stream_url_request_job.h index d11e6e7..0f4edbbc0 100644 --- a/content/browser/streams/stream_url_request_job.h +++ b/content/browser/streams/stream_url_request_job.h
@@ -48,7 +48,7 @@ bool headers_set_; scoped_refptr<net::IOBuffer> pending_buffer_; int pending_buffer_size_; - scoped_ptr<net::HttpResponseInfo> response_info_; + std::unique_ptr<net::HttpResponseInfo> response_info_; int total_bytes_read_; int max_range_;
diff --git a/content/browser/streams/stream_url_request_job_unittest.cc b/content/browser/streams/stream_url_request_job_unittest.cc index 354a075..0b09689 100644 --- a/content/browser/streams/stream_url_request_job_unittest.cc +++ b/content/browser/streams/stream_url_request_job_unittest.cc
@@ -2,11 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/browser/streams/stream_url_request_job.h" + +#include "base/memory/ptr_util.h" #include "base/message_loop/message_loop.h" #include "base/test/test_simple_task_runner.h" #include "content/browser/streams/stream.h" #include "content/browser/streams/stream_registry.h" -#include "content/browser/streams/stream_url_request_job.h" #include "content/browser/streams/stream_write_observer.h" #include "net/base/request_priority.h" #include "net/http/http_byte_range.h" @@ -57,7 +59,7 @@ registry_.reset(new StreamRegistry()); url_request_job_factory_.SetProtocolHandler( - "blob", make_scoped_ptr(new MockProtocolHandler(registry_.get()))); + "blob", base::WrapUnique(new MockProtocolHandler(registry_.get()))); url_request_context_.set_job_factory(&url_request_job_factory_); } @@ -93,11 +95,11 @@ protected: base::MessageLoopForIO message_loop_; - scoped_ptr<StreamRegistry> registry_; + std::unique_ptr<StreamRegistry> registry_; net::URLRequestContext url_request_context_; net::URLRequestJobFactoryImpl url_request_job_factory_; - scoped_ptr<net::URLRequest> request_; + std::unique_ptr<net::URLRequest> request_; }; TEST_F(StreamURLRequestJobTest, TestGetSimpleDataRequest) {
diff --git a/content/browser/time_zone_monitor.cc b/content/browser/time_zone_monitor.cc index 1eb72c6f..a9a5a9b 100644 --- a/content/browser/time_zone_monitor.cc +++ b/content/browser/time_zone_monitor.cc
@@ -26,13 +26,13 @@ #if defined(OS_CHROMEOS) // On CrOS, ICU's default tz is already set to a new zone. No // need to redetect it with detectHostTimeZone(). - scoped_ptr<icu::TimeZone> new_zone(icu::TimeZone::createDefault()); + std::unique_ptr<icu::TimeZone> new_zone(icu::TimeZone::createDefault()); #else icu::TimeZone* new_zone = icu::TimeZone::detectHostTimeZone(); #if defined(OS_LINUX) // We get here multiple times on Linux per a single tz change, but // want to update the ICU default zone and notify renderer only once. - scoped_ptr<icu::TimeZone> current_zone(icu::TimeZone::createDefault()); + std::unique_ptr<icu::TimeZone> current_zone(icu::TimeZone::createDefault()); if (*current_zone == *new_zone) { VLOG(1) << "timezone already updated"; delete new_zone;
diff --git a/content/browser/time_zone_monitor.h b/content/browser/time_zone_monitor.h index 6fff155..95f70a39 100644 --- a/content/browser/time_zone_monitor.h +++ b/content/browser/time_zone_monitor.h
@@ -5,8 +5,9 @@ #ifndef CONTENT_BROWSER_TIME_ZONE_MONITOR_H_ #define CONTENT_BROWSER_TIME_ZONE_MONITOR_H_ +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" namespace content { @@ -31,7 +32,7 @@ public: // Returns a new TimeZoneMonitor object (likely a subclass) specific to the // platform. - static scoped_ptr<TimeZoneMonitor> Create(); + static std::unique_ptr<TimeZoneMonitor> Create(); virtual ~TimeZoneMonitor();
diff --git a/content/browser/time_zone_monitor_android.cc b/content/browser/time_zone_monitor_android.cc index 4eb777b..b2239913 100644 --- a/content/browser/time_zone_monitor_android.cc +++ b/content/browser/time_zone_monitor_android.cc
@@ -33,8 +33,8 @@ } // static -scoped_ptr<TimeZoneMonitor> TimeZoneMonitor::Create() { - return scoped_ptr<TimeZoneMonitor>(new TimeZoneMonitorAndroid()); +std::unique_ptr<TimeZoneMonitor> TimeZoneMonitor::Create() { + return std::unique_ptr<TimeZoneMonitor>(new TimeZoneMonitorAndroid()); } } // namespace content
diff --git a/content/browser/time_zone_monitor_chromeos.cc b/content/browser/time_zone_monitor_chromeos.cc index c3a509a7..d984a60 100644 --- a/content/browser/time_zone_monitor_chromeos.cc +++ b/content/browser/time_zone_monitor_chromeos.cc
@@ -31,8 +31,8 @@ }; // static -scoped_ptr<TimeZoneMonitor> TimeZoneMonitor::Create() { - return scoped_ptr<TimeZoneMonitor>(new TimeZoneMonitorChromeOS()); +std::unique_ptr<TimeZoneMonitor> TimeZoneMonitor::Create() { + return std::unique_ptr<TimeZoneMonitor>(new TimeZoneMonitorChromeOS()); } } // namespace content
diff --git a/content/browser/time_zone_monitor_linux.cc b/content/browser/time_zone_monitor_linux.cc index ded57a4..9c96a255 100644 --- a/content/browser/time_zone_monitor_linux.cc +++ b/content/browser/time_zone_monitor_linux.cc
@@ -159,8 +159,8 @@ } // static -scoped_ptr<TimeZoneMonitor> TimeZoneMonitor::Create() { - return scoped_ptr<TimeZoneMonitor>(new TimeZoneMonitorLinux()); +std::unique_ptr<TimeZoneMonitor> TimeZoneMonitor::Create() { + return std::unique_ptr<TimeZoneMonitor>(new TimeZoneMonitorLinux()); } } // namespace content
diff --git a/content/browser/time_zone_monitor_mac.mm b/content/browser/time_zone_monitor_mac.mm index 5a381d8..a774e8d9 100644 --- a/content/browser/time_zone_monitor_mac.mm +++ b/content/browser/time_zone_monitor_mac.mm
@@ -34,8 +34,8 @@ }; // static -scoped_ptr<TimeZoneMonitor> TimeZoneMonitor::Create() { - return scoped_ptr<TimeZoneMonitor>(new TimeZoneMonitorMac()); +std::unique_ptr<TimeZoneMonitor> TimeZoneMonitor::Create() { + return std::unique_ptr<TimeZoneMonitor>(new TimeZoneMonitorMac()); } } // namespace content
diff --git a/content/browser/time_zone_monitor_win.cc b/content/browser/time_zone_monitor_win.cc index e8b84fd..f7eb54d7 100644 --- a/content/browser/time_zone_monitor_win.cc +++ b/content/browser/time_zone_monitor_win.cc
@@ -6,10 +6,11 @@ #include <windows.h> +#include <memory> + #include "base/bind.h" #include "base/bind_helpers.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "ui/gfx/win/singleton_hwnd_observer.h" namespace content { @@ -33,14 +34,14 @@ NotifyRenderers(); } - scoped_ptr<gfx::SingletonHwndObserver> singleton_hwnd_observer_; + std::unique_ptr<gfx::SingletonHwndObserver> singleton_hwnd_observer_; DISALLOW_COPY_AND_ASSIGN(TimeZoneMonitorWin); }; // static -scoped_ptr<TimeZoneMonitor> TimeZoneMonitor::Create() { - return scoped_ptr<TimeZoneMonitor>(new TimeZoneMonitorWin()); +std::unique_ptr<TimeZoneMonitor> TimeZoneMonitor::Create() { + return std::unique_ptr<TimeZoneMonitor>(new TimeZoneMonitorWin()); } } // namespace content
diff --git a/content/browser/tracing/background_tracing_config_impl.cc b/content/browser/tracing/background_tracing_config_impl.cc index 741e90e..25d6aa91 100644 --- a/content/browser/tracing/background_tracing_config_impl.cc +++ b/content/browser/tracing/background_tracing_config_impl.cc
@@ -117,9 +117,10 @@ break; } - scoped_ptr<base::ListValue> configs_list(new base::ListValue()); + std::unique_ptr<base::ListValue> configs_list(new base::ListValue()); for (const auto& it : rules_) { - scoped_ptr<base::DictionaryValue> config_dict(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> config_dict( + new base::DictionaryValue()); DCHECK(it); it->IntoDict(config_dict.get()); configs_list->Append(std::move(config_dict)); @@ -137,7 +138,7 @@ void BackgroundTracingConfigImpl::AddPreemptiveRule( const base::DictionaryValue* dict) { - scoped_ptr<BackgroundTracingRule> rule = + std::unique_ptr<BackgroundTracingRule> rule = BackgroundTracingRule::PreemptiveRuleFromDict(dict); if (rule) rules_.push_back(std::move(rule)); @@ -146,21 +147,21 @@ void BackgroundTracingConfigImpl::AddReactiveRule( const base::DictionaryValue* dict, BackgroundTracingConfigImpl::CategoryPreset category_preset) { - scoped_ptr<BackgroundTracingRule> rule = + std::unique_ptr<BackgroundTracingRule> rule = BackgroundTracingRule::ReactiveRuleFromDict(dict, category_preset); if (rule) rules_.push_back(std::move(rule)); } -scoped_ptr<BackgroundTracingConfigImpl> BackgroundTracingConfigImpl::FromDict( - const base::DictionaryValue* dict) { +std::unique_ptr<BackgroundTracingConfigImpl> +BackgroundTracingConfigImpl::FromDict(const base::DictionaryValue* dict) { DCHECK(dict); std::string mode; if (!dict->GetString(kConfigModeKey, &mode)) return nullptr; - scoped_ptr<BackgroundTracingConfigImpl> config; + std::unique_ptr<BackgroundTracingConfigImpl> config; if (mode == kConfigModePreemptive) { config = PreemptiveFromDict(dict); @@ -181,12 +182,12 @@ return config; } -scoped_ptr<BackgroundTracingConfigImpl> +std::unique_ptr<BackgroundTracingConfigImpl> BackgroundTracingConfigImpl::PreemptiveFromDict( const base::DictionaryValue* dict) { DCHECK(dict); - scoped_ptr<BackgroundTracingConfigImpl> config( + std::unique_ptr<BackgroundTracingConfigImpl> config( new BackgroundTracingConfigImpl(BackgroundTracingConfigImpl::PREEMPTIVE)); std::string category_preset_string; @@ -215,12 +216,12 @@ return config; } -scoped_ptr<BackgroundTracingConfigImpl> +std::unique_ptr<BackgroundTracingConfigImpl> BackgroundTracingConfigImpl::ReactiveFromDict( const base::DictionaryValue* dict) { DCHECK(dict); - scoped_ptr<BackgroundTracingConfigImpl> config( + std::unique_ptr<BackgroundTracingConfigImpl> config( new BackgroundTracingConfigImpl(BackgroundTracingConfigImpl::REACTIVE)); const base::ListValue* configs_list = nullptr;
diff --git a/content/browser/tracing/background_tracing_config_impl.h b/content/browser/tracing/background_tracing_config_impl.h index 0cee4b19..58c3e4d6 100644 --- a/content/browser/tracing/background_tracing_config_impl.h +++ b/content/browser/tracing/background_tracing_config_impl.h
@@ -53,12 +53,12 @@ const base::DictionaryValue* dict, BackgroundTracingConfigImpl::CategoryPreset category_preset); - static scoped_ptr<BackgroundTracingConfigImpl> PreemptiveFromDict( + static std::unique_ptr<BackgroundTracingConfigImpl> PreemptiveFromDict( const base::DictionaryValue* dict); - static scoped_ptr<BackgroundTracingConfigImpl> ReactiveFromDict( + static std::unique_ptr<BackgroundTracingConfigImpl> ReactiveFromDict( const base::DictionaryValue* dict); - static scoped_ptr<BackgroundTracingConfigImpl> FromDict( + static std::unique_ptr<BackgroundTracingConfigImpl> FromDict( const base::DictionaryValue* dict); static std::string CategoryPresetToString(
diff --git a/content/browser/tracing/background_tracing_config_unittest.cc b/content/browser/tracing/background_tracing_config_unittest.cc index 901e865..73ff081 100644 --- a/content/browser/tracing/background_tracing_config_unittest.cc +++ b/content/browser/tracing/background_tracing_config_unittest.cc
@@ -2,9 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <memory> + #include "base/json/json_reader.h" #include "base/json/json_writer.h" -#include "base/memory/scoped_ptr.h" #include "base/values.h" #include "content/browser/tracing/background_tracing_config_impl.h" #include "content/browser/tracing/background_tracing_rule.h" @@ -23,22 +24,22 @@ TestBrowserThread ui_thread_; }; -scoped_ptr<BackgroundTracingConfigImpl> ReadFromJSONString( +std::unique_ptr<BackgroundTracingConfigImpl> ReadFromJSONString( const std::string& json_text) { - scoped_ptr<base::Value> json_value(base::JSONReader::Read(json_text)); + std::unique_ptr<base::Value> json_value(base::JSONReader::Read(json_text)); base::DictionaryValue* dict = NULL; if (json_value) json_value->GetAsDictionary(&dict); - scoped_ptr<BackgroundTracingConfigImpl> config( + std::unique_ptr<BackgroundTracingConfigImpl> config( static_cast<BackgroundTracingConfigImpl*>( BackgroundTracingConfig::FromDict(dict).release())); return config; } std::string ConfigToString(const BackgroundTracingConfig* config) { - scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); config->IntoDict(dict.get()); @@ -49,7 +50,7 @@ } std::string RuleToString(const BackgroundTracingRule* rule) { - scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); rule->IntoDict(dict.get()); @@ -167,7 +168,7 @@ } TEST_F(BackgroundTracingConfigTest, PreemptiveConfigFromValidString) { - scoped_ptr<BackgroundTracingConfigImpl> config; + std::unique_ptr<BackgroundTracingConfigImpl> config; config = ReadFromJSONString( "{\"mode\":\"PREEMPTIVE_TRACING_MODE\", \"category\": " @@ -270,7 +271,7 @@ } TEST_F(BackgroundTracingConfigTest, ValidPreemptiveCategoryToString) { - scoped_ptr<BackgroundTracingConfigImpl> config = ReadFromJSONString( + std::unique_ptr<BackgroundTracingConfigImpl> config = ReadFromJSONString( "{\"mode\":\"PREEMPTIVE_TRACING_MODE\", \"category\": " "\"BENCHMARK\",\"configs\": [{\"rule\": " "\"MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED\", \"trigger_name\":\"foo\"}]}"); @@ -301,14 +302,14 @@ "\"MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED\",\"trigger_name\":" "\"foo\"}],\"mode\":\"PREEMPTIVE_TRACING_MODE\"}"); EXPECT_EQ(ConfigToString(config.get()), expected.c_str()); - scoped_ptr<BackgroundTracingConfigImpl> config2 = + std::unique_ptr<BackgroundTracingConfigImpl> config2 = ReadFromJSONString(expected); EXPECT_EQ(config->category_preset(), config2->category_preset()); } } TEST_F(BackgroundTracingConfigTest, ReactiveConfigFromValidString) { - scoped_ptr<BackgroundTracingConfigImpl> config; + std::unique_ptr<BackgroundTracingConfigImpl> config; config = ReadFromJSONString( "{\"mode\":\"REACTIVE_TRACING_MODE\",\"configs\": [{\"rule\": " @@ -378,7 +379,7 @@ } TEST_F(BackgroundTracingConfigTest, ValidPreemptiveConfigToString) { - scoped_ptr<BackgroundTracingConfigImpl> config( + std::unique_ptr<BackgroundTracingConfigImpl> config( new BackgroundTracingConfigImpl(BackgroundTracingConfig::PREEMPTIVE)); // Default values @@ -397,7 +398,7 @@ new BackgroundTracingConfigImpl(BackgroundTracingConfig::PREEMPTIVE)); config->set_category_preset(BackgroundTracingConfigImpl::BENCHMARK_DEEP); - scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); dict->SetString("rule", "MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED"); dict->SetString("trigger_name", "foo"); config->AddPreemptiveRule(dict.get()); @@ -413,7 +414,7 @@ new BackgroundTracingConfigImpl(BackgroundTracingConfig::PREEMPTIVE)); config->set_category_preset(BackgroundTracingConfigImpl::BENCHMARK_DEEP); - scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); dict->SetString("rule", "MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED"); dict->SetString("trigger_name", "foo"); dict->SetDouble("trigger_chance", 0.5); @@ -431,7 +432,7 @@ new BackgroundTracingConfigImpl(BackgroundTracingConfig::PREEMPTIVE)); config->set_category_preset(BackgroundTracingConfigImpl::BENCHMARK_DEEP); - scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); dict->SetString("rule", "MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED"); dict->SetString("trigger_name", "foo1"); config->AddPreemptiveRule(dict.get()); @@ -451,7 +452,8 @@ config.reset( new BackgroundTracingConfigImpl(BackgroundTracingConfig::PREEMPTIVE)); - scoped_ptr<base::DictionaryValue> second_dict(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> second_dict( + new base::DictionaryValue()); second_dict->SetString( "rule", "MONITOR_AND_DUMP_WHEN_SPECIFIC_HISTOGRAM_AND_VALUE"); second_dict->SetString("histogram_name", "foo"); @@ -471,7 +473,8 @@ config.reset( new BackgroundTracingConfigImpl(BackgroundTracingConfig::PREEMPTIVE)); - scoped_ptr<base::DictionaryValue> second_dict(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> second_dict( + new base::DictionaryValue()); second_dict->SetString( "rule", "MONITOR_AND_DUMP_WHEN_SPECIFIC_HISTOGRAM_AND_VALUE"); second_dict->SetString("histogram_name", "foo"); @@ -493,7 +496,7 @@ new BackgroundTracingConfigImpl(BackgroundTracingConfig::PREEMPTIVE)); config->set_category_preset(BackgroundTracingConfigImpl::BENCHMARK_DEEP); - scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); dict->SetString("rule", "MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED"); dict->SetString("trigger_name", "foo1"); config->AddPreemptiveRule(dict.get()); @@ -513,13 +516,13 @@ } TEST_F(BackgroundTracingConfigTest, InvalidPreemptiveConfigToString) { - scoped_ptr<BackgroundTracingConfigImpl> config; + std::unique_ptr<BackgroundTracingConfigImpl> config; { config.reset( new BackgroundTracingConfigImpl(BackgroundTracingConfig::PREEMPTIVE)); - scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); dict->SetString("rule", "MONITOR_AND_DUMP_WHEN_BROWSER_STARTUP_COMPLETE"); config->AddPreemptiveRule(dict.get()); @@ -532,7 +535,8 @@ config.reset( new BackgroundTracingConfigImpl(BackgroundTracingConfig::PREEMPTIVE)); - scoped_ptr<base::DictionaryValue> second_dict(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> second_dict( + new base::DictionaryValue()); second_dict->SetString( "rule", "MONITOR_AND_DUMP_WHEN_SPECIFIC_HISTOGRAM_AND_VALUE"); second_dict->SetString("histogram_name", "foo"); @@ -547,7 +551,8 @@ config.reset( new BackgroundTracingConfigImpl(BackgroundTracingConfig::PREEMPTIVE)); - scoped_ptr<base::DictionaryValue> second_dict(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> second_dict( + new base::DictionaryValue()); second_dict->SetString( "rule", "MONITOR_AND_DUMP_WHEN_SPECIFIC_HISTOGRAM_AND_VALUE"); second_dict->SetString("histogram_name", "foo"); @@ -561,7 +566,7 @@ } TEST_F(BackgroundTracingConfigTest, ValidReactiveConfigToString) { - scoped_ptr<BackgroundTracingConfigImpl> config( + std::unique_ptr<BackgroundTracingConfigImpl> config( new BackgroundTracingConfigImpl(BackgroundTracingConfig::REACTIVE)); // Default values @@ -572,7 +577,7 @@ config.reset( new BackgroundTracingConfigImpl(BackgroundTracingConfig::REACTIVE)); - scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); dict->SetString("rule", "TRACE_ON_NAVIGATION_UNTIL_TRIGGER_OR_FULL"); dict->SetString("trigger_name", "foo"); config->AddReactiveRule(dict.get(), @@ -588,7 +593,7 @@ config.reset( new BackgroundTracingConfigImpl(BackgroundTracingConfig::REACTIVE)); - scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); dict->SetString("rule", "TRACE_ON_NAVIGATION_UNTIL_TRIGGER_OR_FULL"); dict->SetString("trigger_name", "foo1"); config->AddReactiveRule(dict.get(),
diff --git a/content/browser/tracing/background_tracing_manager_browsertest.cc b/content/browser/tracing/background_tracing_manager_browsertest.cc index e0001b8..1ca3fe9d 100644 --- a/content/browser/tracing/background_tracing_manager_browsertest.cc +++ b/content/browser/tracing/background_tracing_manager_browsertest.cc
@@ -39,7 +39,7 @@ } void Upload(const scoped_refptr<base::RefCountedString>& file_contents, - scoped_ptr<const base::DictionaryValue> metadata, + std::unique_ptr<const base::DictionaryValue> metadata, base::Callback<void()> done_callback) { receive_count_ += 1; EXPECT_TRUE(file_contents); @@ -97,36 +97,38 @@ callback.Run(); } -scoped_ptr<BackgroundTracingConfig> CreatePreemptiveConfig() { +std::unique_ptr<BackgroundTracingConfig> CreatePreemptiveConfig() { base::DictionaryValue dict; dict.SetString("mode", "PREEMPTIVE_TRACING_MODE"); dict.SetString("category", "BENCHMARK"); - scoped_ptr<base::ListValue> rules_list(new base::ListValue()); + std::unique_ptr<base::ListValue> rules_list(new base::ListValue()); { - scoped_ptr<base::DictionaryValue> rules_dict(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> rules_dict( + new base::DictionaryValue()); rules_dict->SetString("rule", "MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED"); rules_dict->SetString("trigger_name", "preemptive_test"); rules_list->Append(std::move(rules_dict)); } dict.Set("configs", std::move(rules_list)); - scoped_ptr<BackgroundTracingConfig> config( + std::unique_ptr<BackgroundTracingConfig> config( BackgroundTracingConfigImpl::FromDict(&dict)); EXPECT_TRUE(config); return config; } -scoped_ptr<BackgroundTracingConfig> CreateReactiveConfig() { +std::unique_ptr<BackgroundTracingConfig> CreateReactiveConfig() { base::DictionaryValue dict; dict.SetString("mode", "REACTIVE_TRACING_MODE"); - scoped_ptr<base::ListValue> rules_list(new base::ListValue()); + std::unique_ptr<base::ListValue> rules_list(new base::ListValue()); { - scoped_ptr<base::DictionaryValue> rules_dict(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> rules_dict( + new base::DictionaryValue()); rules_dict->SetString("rule", "TRACE_ON_NAVIGATION_UNTIL_TRIGGER_OR_FULL"); rules_dict->SetString("trigger_name", "reactive_test"); rules_dict->SetString("category", "BENCHMARK"); @@ -134,7 +136,7 @@ } dict.Set("configs", std::move(rules_list)); - scoped_ptr<BackgroundTracingConfig> config( + std::unique_ptr<BackgroundTracingConfig> config( BackgroundTracingConfigImpl::FromDict(&dict)); EXPECT_TRUE(config); @@ -162,7 +164,7 @@ BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( run_loop.QuitClosure()); - scoped_ptr<BackgroundTracingConfig> config = CreatePreemptiveConfig(); + std::unique_ptr<BackgroundTracingConfig> config = CreatePreemptiveConfig(); BackgroundTracingManager::TriggerHandle handle = BackgroundTracingManager:: @@ -194,7 +196,7 @@ BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( run_loop.QuitClosure()); - scoped_ptr<BackgroundTracingConfig> config = CreatePreemptiveConfig(); + std::unique_ptr<BackgroundTracingConfig> config = CreatePreemptiveConfig(); content::BackgroundTracingManager::TriggerHandle handle = content::BackgroundTracingManager::GetInstance()->RegisterTriggerType( @@ -246,7 +248,7 @@ BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( wait_for_upload.QuitClosure()); - scoped_ptr<BackgroundTracingConfig> config = CreatePreemptiveConfig(); + std::unique_ptr<BackgroundTracingConfig> config = CreatePreemptiveConfig(); content::BackgroundTracingManager::TriggerHandle handle = content::BackgroundTracingManager::GetInstance()->RegisterTriggerType( @@ -290,7 +292,7 @@ BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( wait_for_upload.QuitClosure()); - scoped_ptr<BackgroundTracingConfig> config = CreatePreemptiveConfig(); + std::unique_ptr<BackgroundTracingConfig> config = CreatePreemptiveConfig(); content::BackgroundTracingManager::TriggerHandle handle = content::BackgroundTracingManager::GetInstance()->RegisterTriggerType( @@ -334,7 +336,7 @@ BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( wait_for_upload.QuitClosure()); - scoped_ptr<BackgroundTracingConfig> config = CreatePreemptiveConfig(); + std::unique_ptr<BackgroundTracingConfig> config = CreatePreemptiveConfig(); content::BackgroundTracingManager::TriggerHandle handle = content::BackgroundTracingManager::GetInstance()->RegisterTriggerType( @@ -379,15 +381,17 @@ dict.SetString("mode", "PREEMPTIVE_TRACING_MODE"); dict.SetString("category", "BENCHMARK"); - scoped_ptr<base::ListValue> rules_list(new base::ListValue()); + std::unique_ptr<base::ListValue> rules_list(new base::ListValue()); { - scoped_ptr<base::DictionaryValue> rules_dict(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> rules_dict( + new base::DictionaryValue()); rules_dict->SetString("rule", "MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED"); rules_dict->SetString("trigger_name", "test1"); rules_list->Append(std::move(rules_dict)); } { - scoped_ptr<base::DictionaryValue> rules_dict(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> rules_dict( + new base::DictionaryValue()); rules_dict->SetString("rule", "MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED"); rules_dict->SetString("trigger_name", "test2"); rules_list->Append(std::move(rules_dict)); @@ -395,7 +399,7 @@ dict.Set("configs", std::move(rules_list)); - scoped_ptr<BackgroundTracingConfig> config( + std::unique_ptr<BackgroundTracingConfig> config( BackgroundTracingConfigImpl::FromDict(&dict)); EXPECT_TRUE(config); @@ -438,9 +442,10 @@ dict.SetString("mode", "PREEMPTIVE_TRACING_MODE"); dict.SetString("category", "BENCHMARK"); - scoped_ptr<base::ListValue> rules_list(new base::ListValue()); + std::unique_ptr<base::ListValue> rules_list(new base::ListValue()); { - scoped_ptr<base::DictionaryValue> rules_dict(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> rules_dict( + new base::DictionaryValue()); rules_dict->SetString("rule", "MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED"); rules_dict->SetString("trigger_name", "test2"); rules_list->Append(std::move(rules_dict)); @@ -449,7 +454,7 @@ dict.Set("configs", std::move(rules_list)); dict.SetString("enable_blink_features", "FasterWeb1,FasterWeb2"); dict.SetString("disable_blink_features", "SlowerWeb1,SlowerWeb2"); - scoped_ptr<BackgroundTracingConfig> config( + std::unique_ptr<BackgroundTracingConfig> config( BackgroundTracingConfigImpl::FromDict(&dict)); EXPECT_TRUE(config); @@ -485,9 +490,10 @@ dict.SetString("mode", "PREEMPTIVE_TRACING_MODE"); dict.SetString("category", "BENCHMARK"); - scoped_ptr<base::ListValue> rules_list(new base::ListValue()); + std::unique_ptr<base::ListValue> rules_list(new base::ListValue()); { - scoped_ptr<base::DictionaryValue> rules_dict(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> rules_dict( + new base::DictionaryValue()); rules_dict->SetString("rule", "MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED"); rules_dict->SetString("trigger_name", "test2"); rules_list->Append(std::move(rules_dict)); @@ -496,7 +502,7 @@ dict.Set("configs", std::move(rules_list)); dict.SetString("enable_blink_features", "FasterWeb1,FasterWeb2"); dict.SetString("disable_blink_features", "SlowerWeb1,SlowerWeb2"); - scoped_ptr<BackgroundTracingConfig> config( + std::unique_ptr<BackgroundTracingConfig> config( BackgroundTracingConfigImpl::FromDict(&dict)); EXPECT_TRUE(config); @@ -526,9 +532,10 @@ dict.SetString("mode", "PREEMPTIVE_TRACING_MODE"); dict.SetString("category", "BENCHMARK"); - scoped_ptr<base::ListValue> rules_list(new base::ListValue()); + std::unique_ptr<base::ListValue> rules_list(new base::ListValue()); { - scoped_ptr<base::DictionaryValue> rules_dict(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> rules_dict( + new base::DictionaryValue()); rules_dict->SetString( "rule", "MONITOR_AND_DUMP_WHEN_SPECIFIC_HISTOGRAM_AND_VALUE"); rules_dict->SetString("histogram_name", "fake"); @@ -539,7 +546,7 @@ dict.Set("configs", std::move(rules_list)); - scoped_ptr<BackgroundTracingConfig> config( + std::unique_ptr<BackgroundTracingConfig> config( BackgroundTracingConfigImpl::FromDict(&dict)); EXPECT_TRUE(config); @@ -586,7 +593,7 @@ BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( (base::Closure())); - scoped_ptr<BackgroundTracingConfig> config = CreatePreemptiveConfig(); + std::unique_ptr<BackgroundTracingConfig> config = CreatePreemptiveConfig(); content::BackgroundTracingManager::TriggerHandle handle = content::BackgroundTracingManager::GetInstance()->RegisterTriggerType( @@ -613,7 +620,7 @@ BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( (base::Closure())); - scoped_ptr<BackgroundTracingConfig> config = CreatePreemptiveConfig(); + std::unique_ptr<BackgroundTracingConfig> config = CreatePreemptiveConfig(); content::BackgroundTracingManager::TriggerHandle handle = content::BackgroundTracingManager::GetInstance()->RegisterTriggerType( @@ -646,7 +653,7 @@ BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( (base::Closure())); - scoped_ptr<BackgroundTracingConfig> config = CreatePreemptiveConfig(); + std::unique_ptr<BackgroundTracingConfig> config = CreatePreemptiveConfig(); content::BackgroundTracingManager::TriggerHandle handle = content::BackgroundTracingManager::GetInstance()->RegisterTriggerType( @@ -687,9 +694,10 @@ dict.SetString("mode", "PREEMPTIVE_TRACING_MODE"); dict.SetString("category", "BENCHMARK"); - scoped_ptr<base::ListValue> rules_list(new base::ListValue()); + std::unique_ptr<base::ListValue> rules_list(new base::ListValue()); { - scoped_ptr<base::DictionaryValue> rules_dict(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> rules_dict( + new base::DictionaryValue()); rules_dict->SetString("rule", "MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED"); rules_dict->SetString("trigger_name", "preemptive_test"); rules_dict->SetDouble("trigger_chance", 0.0); @@ -697,7 +705,7 @@ } dict.Set("configs", std::move(rules_list)); - scoped_ptr<BackgroundTracingConfig> config( + std::unique_ptr<BackgroundTracingConfig> config( BackgroundTracingConfigImpl::FromDict(&dict)); EXPECT_TRUE(config); @@ -737,9 +745,10 @@ dict.SetString("mode", "REACTIVE_TRACING_MODE"); - scoped_ptr<base::ListValue> rules_list(new base::ListValue()); + std::unique_ptr<base::ListValue> rules_list(new base::ListValue()); { - scoped_ptr<base::DictionaryValue> rules_dict(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> rules_dict( + new base::DictionaryValue()); rules_dict->SetString("rule", "TRACE_ON_NAVIGATION_UNTIL_TRIGGER_OR_FULL"); rules_dict->SetString("trigger_name", "reactive_test1"); @@ -750,7 +759,7 @@ } dict.Set("configs", std::move(rules_list)); - scoped_ptr<BackgroundTracingConfig> config( + std::unique_ptr<BackgroundTracingConfig> config( BackgroundTracingConfigImpl::FromDict(&dict)); EXPECT_TRUE(config); @@ -791,9 +800,10 @@ dict.SetString("mode", "PREEMPTIVE_TRACING_MODE"); dict.SetString("category", "BENCHMARK"); - scoped_ptr<base::ListValue> rules_list(new base::ListValue()); + std::unique_ptr<base::ListValue> rules_list(new base::ListValue()); { - scoped_ptr<base::DictionaryValue> rules_dict(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> rules_dict( + new base::DictionaryValue()); rules_dict->SetString( "rule", "MONITOR_AND_DUMP_WHEN_SPECIFIC_HISTOGRAM_AND_VALUE"); rules_dict->SetString("histogram_name", "fake"); @@ -803,7 +813,7 @@ dict.Set("configs", std::move(rules_list)); - scoped_ptr<BackgroundTracingConfig> config( + std::unique_ptr<BackgroundTracingConfig> config( BackgroundTracingConfigImpl::FromDict(&dict)); EXPECT_TRUE(config); @@ -835,9 +845,10 @@ dict.SetString("mode", "PREEMPTIVE_TRACING_MODE"); dict.SetString("category", "BENCHMARK"); - scoped_ptr<base::ListValue> rules_list(new base::ListValue()); + std::unique_ptr<base::ListValue> rules_list(new base::ListValue()); { - scoped_ptr<base::DictionaryValue> rules_dict(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> rules_dict( + new base::DictionaryValue()); rules_dict->SetString( "rule", "MONITOR_AND_DUMP_WHEN_SPECIFIC_HISTOGRAM_AND_VALUE"); rules_dict->SetString("histogram_name", "fake"); @@ -847,7 +858,7 @@ dict.Set("configs", std::move(rules_list)); - scoped_ptr<BackgroundTracingConfig> config( + std::unique_ptr<BackgroundTracingConfig> config( BackgroundTracingConfigImpl::FromDict(&dict)); EXPECT_TRUE(config); @@ -880,9 +891,10 @@ dict.SetString("mode", "PREEMPTIVE_TRACING_MODE"); dict.SetString("category", "BENCHMARK"); - scoped_ptr<base::ListValue> rules_list(new base::ListValue()); + std::unique_ptr<base::ListValue> rules_list(new base::ListValue()); { - scoped_ptr<base::DictionaryValue> rules_dict(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> rules_dict( + new base::DictionaryValue()); rules_dict->SetString( "rule", "MONITOR_AND_DUMP_WHEN_SPECIFIC_HISTOGRAM_AND_VALUE"); rules_dict->SetString("histogram_name", "fake"); @@ -893,7 +905,7 @@ dict.Set("configs", std::move(rules_list)); - scoped_ptr<BackgroundTracingConfig> config( + std::unique_ptr<BackgroundTracingConfig> config( BackgroundTracingConfigImpl::FromDict(&dict)); EXPECT_TRUE(config); @@ -924,16 +936,17 @@ dict.SetString("mode", "PREEMPTIVE_TRACING_MODE"); dict.SetString("category", "BENCHMARK"); - scoped_ptr<base::ListValue> rules_list(new base::ListValue()); + std::unique_ptr<base::ListValue> rules_list(new base::ListValue()); { - scoped_ptr<base::DictionaryValue> rules_dict(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> rules_dict( + new base::DictionaryValue()); rules_dict->SetString("rule", "INVALID_RULE"); rules_list->Append(std::move(rules_dict)); } dict.Set("configs", std::move(rules_list)); - scoped_ptr<BackgroundTracingConfig> config( + std::unique_ptr<BackgroundTracingConfig> config( BackgroundTracingConfigImpl::FromDict(&dict)); // An invalid config should always return a nullptr here. EXPECT_FALSE(config); @@ -950,7 +963,7 @@ BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( run_loop.QuitClosure()); - scoped_ptr<BackgroundTracingConfig> config = CreateReactiveConfig(); + std::unique_ptr<BackgroundTracingConfig> config = CreateReactiveConfig(); BackgroundTracingManager::TriggerHandle handle = BackgroundTracingManager:: @@ -984,7 +997,7 @@ BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( run_loop.QuitClosure()); - scoped_ptr<BackgroundTracingConfig> config = CreateReactiveConfig(); + std::unique_ptr<BackgroundTracingConfig> config = CreateReactiveConfig(); BackgroundTracingManager::TriggerHandle handle = BackgroundTracingManager:: @@ -1022,9 +1035,10 @@ base::DictionaryValue dict; dict.SetString("mode", "REACTIVE_TRACING_MODE"); - scoped_ptr<base::ListValue> rules_list(new base::ListValue()); + std::unique_ptr<base::ListValue> rules_list(new base::ListValue()); { - scoped_ptr<base::DictionaryValue> rules_dict(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> rules_dict( + new base::DictionaryValue()); rules_dict->SetString("rule", "TRACE_ON_NAVIGATION_UNTIL_TRIGGER_OR_FULL"); rules_dict->SetString("trigger_name", "reactive_test1"); @@ -1032,7 +1046,8 @@ rules_list->Append(std::move(rules_dict)); } { - scoped_ptr<base::DictionaryValue> rules_dict(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> rules_dict( + new base::DictionaryValue()); rules_dict->SetString("rule", "TRACE_ON_NAVIGATION_UNTIL_TRIGGER_OR_FULL"); rules_dict->SetString("trigger_name", "reactive_test2"); @@ -1041,7 +1056,7 @@ } dict.Set("configs", std::move(rules_list)); - scoped_ptr<BackgroundTracingConfig> config( + std::unique_ptr<BackgroundTracingConfig> config( BackgroundTracingConfigImpl::FromDict(&dict)); BackgroundTracingManager::TriggerHandle handle1 = @@ -1086,7 +1101,7 @@ BackgroundTracingManagerUploadConfigWrapper upload_config_wrapper( run_loop.QuitClosure()); - scoped_ptr<BackgroundTracingConfig> config = CreateReactiveConfig(); + std::unique_ptr<BackgroundTracingConfig> config = CreateReactiveConfig(); BackgroundTracingManager::TriggerHandle handle = BackgroundTracingManager::
diff --git a/content/browser/tracing/background_tracing_manager_impl.cc b/content/browser/tracing/background_tracing_manager_impl.cc index ca39488..32fac32 100644 --- a/content/browser/tracing/background_tracing_manager_impl.cc +++ b/content/browser/tracing/background_tracing_manager_impl.cc
@@ -101,7 +101,7 @@ } bool BackgroundTracingManagerImpl::SetActiveScenario( - scoped_ptr<BackgroundTracingConfig> config, + std::unique_ptr<BackgroundTracingConfig> config, const BackgroundTracingManager::ReceiveCallback& receive_callback, DataFiltering data_filtering) { CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); @@ -136,7 +136,7 @@ base::Unretained(this))); } - scoped_ptr<const content::BackgroundTracingConfigImpl> config_impl( + std::unique_ptr<const content::BackgroundTracingConfigImpl> config_impl( static_cast<BackgroundTracingConfigImpl*>(config.release())); base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); @@ -400,7 +400,7 @@ } void BackgroundTracingManagerImpl::OnFinalizeStarted( - scoped_ptr<const base::DictionaryValue> metadata, + std::unique_ptr<const base::DictionaryValue> metadata, base::RefCountedString* file_contents) { CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); @@ -452,7 +452,8 @@ TracingControllerImpl::TraceDataSink* trace_data_sink) const { base::DictionaryValue metadata_dict; - scoped_ptr<base::DictionaryValue> config_dict(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> config_dict( + new base::DictionaryValue()); config_->IntoDict(config_dict.get()); metadata_dict.Set("config", std::move(config_dict));
diff --git a/content/browser/tracing/background_tracing_manager_impl.h b/content/browser/tracing/background_tracing_manager_impl.h index f1d88f2..bcb25a42 100644 --- a/content/browser/tracing/background_tracing_manager_impl.h +++ b/content/browser/tracing/background_tracing_manager_impl.h
@@ -5,10 +5,11 @@ #ifndef CONTENT_BROWSER_TRACING_BACKGROUND_TRACING_MANAGER_IMPL_H_ #define CONTENT_BROWSER_TRACING_BACKGROUND_TRACING_MANAGER_IMPL_H_ +#include <memory> + #include "base/lazy_instance.h" #include "base/macros.h" #include "base/memory/ref_counted_memory.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/metrics/histogram.h" #include "content/browser/tracing/background_tracing_config_impl.h" @@ -25,7 +26,7 @@ public: static CONTENT_EXPORT BackgroundTracingManagerImpl* GetInstance(); - bool SetActiveScenario(scoped_ptr<BackgroundTracingConfig>, + bool SetActiveScenario(std::unique_ptr<BackgroundTracingConfig>, const ReceiveCallback&, DataFiltering data_filtering) override; void WhenIdle(IdleCallback idle_callback) override; @@ -55,9 +56,8 @@ void StartTracing(std::string, base::trace_event::TraceRecordMode); void StartTracingIfConfigNeedsIt(); - void OnFinalizeStarted( - scoped_ptr<const base::DictionaryValue> metadata, - base::RefCountedString*); + void OnFinalizeStarted(std::unique_ptr<const base::DictionaryValue> metadata, + base::RefCountedString*); void OnFinalizeComplete(); void BeginFinalizing(StartedFinalizingCallback); void ValidateStartupScenario(); @@ -90,10 +90,10 @@ StartedFinalizingCallback callback_; }; - scoped_ptr<TracingDelegate> delegate_; - scoped_ptr<const content::BackgroundTracingConfigImpl> config_; + std::unique_ptr<TracingDelegate> delegate_; + std::unique_ptr<const content::BackgroundTracingConfigImpl> config_; std::map<TriggerHandle, std::string> trigger_handles_; - scoped_ptr<TracingTimer> tracing_timer_; + std::unique_ptr<TracingTimer> tracing_timer_; ReceiveCallback receive_callback_; bool is_gathering_;
diff --git a/content/browser/tracing/background_tracing_rule.cc b/content/browser/tracing/background_tracing_rule.cc index f09608a..cf11772 100644 --- a/content/browser/tracing/background_tracing_rule.cc +++ b/content/browser/tracing/background_tracing_rule.cc
@@ -92,13 +92,13 @@ : named_event_(named_event) {} public: - static scoped_ptr<BackgroundTracingRule> Create( + static std::unique_ptr<BackgroundTracingRule> Create( const base::DictionaryValue* dict) { std::string trigger_name; if (!dict->GetString(kConfigRuleTriggerNameKey, &trigger_name)) return nullptr; - return scoped_ptr<BackgroundTracingRule>( + return std::unique_ptr<BackgroundTracingRule>( new NamedTriggerRule(trigger_name)); } @@ -132,7 +132,7 @@ trigger_delay_(trigger_delay) {} public: - static scoped_ptr<BackgroundTracingRule> Create( + static std::unique_ptr<BackgroundTracingRule> Create( const base::DictionaryValue* dict) { std::string histogram_name; if (!dict->GetString(kConfigRuleHistogramNameKey, &histogram_name)) @@ -161,7 +161,7 @@ int trigger_delay = -1; dict->GetInteger(kConfigRuleTriggerDelay, &trigger_delay); - return scoped_ptr<BackgroundTracingRule>( + return std::unique_ptr<BackgroundTracingRule>( new HistogramRule(histogram_name, histogram_lower_value, histogram_upper_value, repeat, trigger_delay)); } @@ -263,14 +263,14 @@ : named_event_(named_event), category_preset_(category_preset) {} public: - static scoped_ptr<BackgroundTracingRule> Create( + static std::unique_ptr<BackgroundTracingRule> Create( const base::DictionaryValue* dict, BackgroundTracingConfigImpl::CategoryPreset category_preset) { std::string trigger_name; if (!dict->GetString(kConfigRuleTriggerNameKey, &trigger_name)) return nullptr; - return scoped_ptr<BackgroundTracingRule>( + return std::unique_ptr<BackgroundTracingRule>( new ReactiveTraceForNSOrTriggerOrFullRule(trigger_name, category_preset)); } @@ -318,7 +318,7 @@ } public: - static scoped_ptr<BackgroundTracingRule> Create( + static std::unique_ptr<BackgroundTracingRule> Create( const base::DictionaryValue* dict, BackgroundTracingConfigImpl::CategoryPreset category_preset) { int timeout_min; @@ -332,7 +332,7 @@ if (timeout_min > timeout_max) return nullptr; - return scoped_ptr<BackgroundTracingRule>( + return std::unique_ptr<BackgroundTracingRule>( new ReactiveTraceAtRandomIntervalsRule(category_preset, timeout_min, timeout_max)); } @@ -411,7 +411,8 @@ } // namespace -scoped_ptr<BackgroundTracingRule> BackgroundTracingRule::PreemptiveRuleFromDict( +std::unique_ptr<BackgroundTracingRule> +BackgroundTracingRule::PreemptiveRuleFromDict( const base::DictionaryValue* dict) { DCHECK(dict); @@ -419,7 +420,7 @@ if (!dict->GetString(kConfigRuleKey, &type)) return nullptr; - scoped_ptr<BackgroundTracingRule> tracing_rule; + std::unique_ptr<BackgroundTracingRule> tracing_rule; if (type == kPreemptiveConfigRuleMonitorNamed) tracing_rule = NamedTriggerRule::Create(dict); else if (type == kPreemptiveConfigRuleMonitorHistogram) @@ -431,7 +432,8 @@ return tracing_rule; } -scoped_ptr<BackgroundTracingRule> BackgroundTracingRule::ReactiveRuleFromDict( +std::unique_ptr<BackgroundTracingRule> +BackgroundTracingRule::ReactiveRuleFromDict( const base::DictionaryValue* dict, BackgroundTracingConfigImpl::CategoryPreset category_preset) { DCHECK(dict); @@ -440,7 +442,7 @@ if (!dict->GetString(kConfigRuleKey, &type)) return nullptr; - scoped_ptr<BackgroundTracingRule> tracing_rule; + std::unique_ptr<BackgroundTracingRule> tracing_rule; if (type == kReactiveConfigRuleTraceOnNavigationUntilTriggerOrFull) { tracing_rule =
diff --git a/content/browser/tracing/background_tracing_rule.h b/content/browser/tracing/background_tracing_rule.h index 3277716b..236ef91 100644 --- a/content/browser/tracing/background_tracing_rule.h +++ b/content/browser/tracing/background_tracing_rule.h
@@ -33,10 +33,10 @@ // Probability that we should allow a tigger to happen. double trigger_chance() const { return trigger_chance_; } - static scoped_ptr<BackgroundTracingRule> PreemptiveRuleFromDict( + static std::unique_ptr<BackgroundTracingRule> PreemptiveRuleFromDict( const base::DictionaryValue* dict); - static scoped_ptr<BackgroundTracingRule> ReactiveRuleFromDict( + static std::unique_ptr<BackgroundTracingRule> ReactiveRuleFromDict( const base::DictionaryValue* dict, BackgroundTracingConfigImpl::CategoryPreset category_preset);
diff --git a/content/browser/tracing/etw_system_event_consumer_win.cc b/content/browser/tracing/etw_system_event_consumer_win.cc index 09d81f7..ede14ced 100644 --- a/content/browser/tracing/etw_system_event_consumer_win.cc +++ b/content/browser/tracing/etw_system_event_consumer_win.cc
@@ -166,7 +166,7 @@ now_in_us.QuadPart = now.ToInternalValue(); // Add fields to the event. - scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); value->Set("guid", new base::StringValue("ClockSync")); value->Set("walltime", new base::StringValue( base::StringPrintf("%08X%08X", @@ -184,7 +184,7 @@ void EtwSystemEventConsumer::AppendEventToBuffer(EVENT_TRACE* event) { using base::FundamentalValue; - scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); // Add header fields to the event. LARGE_INTEGER ts_us; @@ -230,7 +230,7 @@ void EtwSystemEventConsumer::FlushOnThread( const StopAgentTracingCallback& callback) { // Add the header information to the stream. - scoped_ptr<base::DictionaryValue> header(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> header(new base::DictionaryValue()); header->Set("name", new base::StringValue("ETW")); // Release and pass the events buffer.
diff --git a/content/browser/tracing/etw_system_event_consumer_win.h b/content/browser/tracing/etw_system_event_consumer_win.h index f14a37e..35d7d4c 100644 --- a/content/browser/tracing/etw_system_event_consumer_win.h +++ b/content/browser/tracing/etw_system_event_consumer_win.h
@@ -5,10 +5,11 @@ #ifndef CONTENT_BROWSER_TRACING_ETW_SYSTEM_EVENT_CONSUMER_WIN_H_ #define CONTENT_BROWSER_TRACING_ETW_SYSTEM_EVENT_CONSUMER_WIN_H_ +#include <memory> + #include "base/bind.h" #include "base/macros.h" #include "base/memory/ref_counted_memory.h" -#include "base/memory/scoped_ptr.h" #include "base/threading/thread.h" #include "base/trace_event/tracing_agent.h" #include "base/values.h" @@ -69,7 +70,7 @@ void TraceAndConsumeOnThread(); void FlushOnThread(const StopAgentTracingCallback& callback); - scoped_ptr<base::ListValue> events_; + std::unique_ptr<base::ListValue> events_; base::Thread thread_; TRACEHANDLE session_handle_; base::win::EtwTraceProperties properties_;
diff --git a/content/browser/tracing/memory_tracing_browsertest.cc b/content/browser/tracing/memory_tracing_browsertest.cc index 13b0923..cec3bb82 100644 --- a/content/browser/tracing/memory_tracing_browsertest.cc +++ b/content/browser/tracing/memory_tracing_browsertest.cc
@@ -126,7 +126,7 @@ } base::Closure on_memory_dump_complete_closure_; - scoped_ptr<MockDumpProvider> mock_dump_provider_; + std::unique_ptr<MockDumpProvider> mock_dump_provider_; uint32_t callback_call_count_; uint64_t last_callback_dump_guid_; bool last_callback_success_;
diff --git a/content/browser/tracing/power_tracing_agent.h b/content/browser/tracing/power_tracing_agent.h index 0fa97fe..ae5079e4 100644 --- a/content/browser/tracing/power_tracing_agent.h +++ b/content/browser/tracing/power_tracing_agent.h
@@ -5,9 +5,10 @@ #ifndef CONTENT_BROWSER_TRACING_POWER_TRACING_AGENT_H_ #define CONTENT_BROWSER_TRACING_POWER_TRACING_AGENT_H_ +#include <memory> + #include "base/macros.h" #include "base/memory/ref_counted_memory.h" -#include "base/memory/scoped_ptr.h" #include "base/threading/thread.h" #include "base/trace_event/tracing_agent.h" #include "content/public/browser/browser_thread.h" @@ -68,7 +69,7 @@ // All interactions with the BattOrAgent (after construction) must happen on // the IO thread. - scoped_ptr<battor::BattOrAgent, BrowserThread::DeleteOnIOThread> + std::unique_ptr<battor::BattOrAgent, BrowserThread::DeleteOnIOThread> battor_agent_; StartAgentTracingCallback start_tracing_callback_;
diff --git a/content/browser/tracing/tracing_controller_browsertest.cc b/content/browser/tracing/tracing_controller_browsertest.cc index 8cafbd7d..29fbba1 100644 --- a/content/browser/tracing/tracing_controller_browsertest.cc +++ b/content/browser/tracing/tracing_controller_browsertest.cc
@@ -59,7 +59,7 @@ : public TracingController::TraceDataEndpoint { public: TracingControllerTestEndpoint( - base::Callback<void(scoped_ptr<const base::DictionaryValue>, + base::Callback<void(std::unique_ptr<const base::DictionaryValue>, base::RefCountedString*)> done_callback) : done_callback_(done_callback) {} @@ -69,7 +69,7 @@ } void ReceiveTraceFinalContents( - scoped_ptr<const base::DictionaryValue> metadata, + std::unique_ptr<const base::DictionaryValue> metadata, const std::string& contents) override { EXPECT_EQ(trace_, contents); @@ -87,8 +87,9 @@ ~TracingControllerTestEndpoint() override {} std::string trace_; - base::Callback<void(scoped_ptr<const base::DictionaryValue>, - base::RefCountedString*)> done_callback_; + base::Callback<void(std::unique_ptr<const base::DictionaryValue>, + base::RefCountedString*)> + done_callback_; }; class TracingControllerTest : public ContentBrowserTest { @@ -122,7 +123,7 @@ void StopTracingStringDoneCallbackTest( base::Closure quit_callback, - scoped_ptr<const base::DictionaryValue> metadata, + std::unique_ptr<const base::DictionaryValue> metadata, base::RefCountedString* data) { disable_recording_done_callback_count_++; last_metadata_.reset(metadata.release()); @@ -186,11 +187,11 @@ { base::RunLoop run_loop; - base::Callback<void(scoped_ptr<const base::DictionaryValue>, - base::RefCountedString*)> callback = base::Bind( - &TracingControllerTest::StopTracingStringDoneCallbackTest, - base::Unretained(this), - run_loop.QuitClosure()); + base::Callback<void(std::unique_ptr<const base::DictionaryValue>, + base::RefCountedString*)> + callback = base::Bind( + &TracingControllerTest::StopTracingStringDoneCallbackTest, + base::Unretained(this), run_loop.QuitClosure()); bool result = controller->StopTracing( TracingController::CreateStringSink(callback)); ASSERT_TRUE(result); @@ -224,11 +225,11 @@ { base::RunLoop run_loop; - base::Callback<void(scoped_ptr<const base::DictionaryValue>, - base::RefCountedString*)> callback = base::Bind( - &TracingControllerTest::StopTracingStringDoneCallbackTest, - base::Unretained(this), - run_loop.QuitClosure()); + base::Callback<void(std::unique_ptr<const base::DictionaryValue>, + base::RefCountedString*)> + callback = base::Bind( + &TracingControllerTest::StopTracingStringDoneCallbackTest, + base::Unretained(this), run_loop.QuitClosure()); scoped_refptr<TracingController::TraceDataSink> trace_data_sink = TracingController::CreateStringSink(callback); @@ -264,10 +265,11 @@ { base::RunLoop run_loop; - base::Callback<void(scoped_ptr<const base::DictionaryValue>, - base::RefCountedString*)> callback = base::Bind( - &TracingControllerTest::StopTracingStringDoneCallbackTest, - base::Unretained(this), run_loop.QuitClosure()); + base::Callback<void(std::unique_ptr<const base::DictionaryValue>, + base::RefCountedString*)> + callback = base::Bind( + &TracingControllerTest::StopTracingStringDoneCallbackTest, + base::Unretained(this), run_loop.QuitClosure()); bool result = controller->StopTracing( TracingController::CreateCompressedStringSink( new TracingControllerTestEndpoint(callback))); @@ -347,7 +349,7 @@ int enable_recording_done_callback_count_; int disable_recording_done_callback_count_; base::FilePath last_actual_recording_file_path_; - scoped_ptr<const base::DictionaryValue> last_metadata_; + std::unique_ptr<const base::DictionaryValue> last_metadata_; std::string last_data_; };
diff --git a/content/browser/tracing/tracing_controller_impl.cc b/content/browser/tracing/tracing_controller_impl.cc index 06ef7c8f..aba7a75 100644 --- a/content/browser/tracing/tracing_controller_impl.cc +++ b/content/browser/tracing/tracing_controller_impl.cc
@@ -108,8 +108,9 @@ return std::string(); } -scoped_ptr<base::DictionaryValue> GenerateTracingMetadataDict() { - scoped_ptr<base::DictionaryValue> metadata_dict(new base::DictionaryValue()); +std::unique_ptr<base::DictionaryValue> GenerateTracingMetadataDict() { + std::unique_ptr<base::DictionaryValue> metadata_dict( + new base::DictionaryValue()); metadata_dict->SetString("network-type", GetNetworkTypeString()); metadata_dict->SetString("product-version", GetContentClient()->GetProduct()); @@ -158,7 +159,7 @@ metadata_dict->SetString("gpu-gl-renderer", gpu_info.gl_renderer); #endif - scoped_ptr<TracingDelegate> delegate( + std::unique_ptr<TracingDelegate> delegate( GetContentClient()->browser()->GetTracingDelegate()); if (delegate) delegate->GenerateMetadataDict(metadata_dict.get()); @@ -348,7 +349,7 @@ if (trace_data_sink) { if (TraceLog::GetInstance()->GetCurrentTraceConfig() .IsArgumentFilterEnabled()) { - scoped_ptr<TracingDelegate> delegate( + std::unique_ptr<TracingDelegate> delegate( GetContentClient()->browser()->GetTracingDelegate()); if (delegate) { trace_data_sink->SetMetadataFilterPredicate(
diff --git a/content/browser/tracing/tracing_controller_impl.h b/content/browser/tracing/tracing_controller_impl.h index 7a6c17b..eb7761e 100644 --- a/content/browser/tracing/tracing_controller_impl.h +++ b/content/browser/tracing/tracing_controller_impl.h
@@ -171,7 +171,7 @@ int pending_start_tracing_ack_count_; base::OneShotTimer start_tracing_timer_; StartTracingDoneCallback start_tracing_done_callback_; - scoped_ptr<base::trace_event::TraceConfig> start_tracing_trace_config_; + std::unique_ptr<base::trace_event::TraceConfig> start_tracing_trace_config_; // Pending acks for StopTracing. int pending_stop_tracing_ack_count_;
diff --git a/content/browser/tracing/tracing_controller_impl_data_sinks.cc b/content/browser/tracing/tracing_controller_impl_data_sinks.cc index 1ee63278..4020df1 100644 --- a/content/browser/tracing/tracing_controller_impl_data_sinks.cc +++ b/content/browser/tracing/tracing_controller_impl_data_sinks.cc
@@ -21,14 +21,15 @@ class StringTraceDataEndpoint : public TracingController::TraceDataEndpoint { public: - typedef base::Callback<void(scoped_ptr<const base::DictionaryValue>, - base::RefCountedString*)> CompletionCallback; + typedef base::Callback<void(std::unique_ptr<const base::DictionaryValue>, + base::RefCountedString*)> + CompletionCallback; explicit StringTraceDataEndpoint(CompletionCallback callback) : completion_callback_(callback) {} void ReceiveTraceFinalContents( - scoped_ptr<const base::DictionaryValue> metadata, + std::unique_ptr<const base::DictionaryValue> metadata, const std::string& contents) override { std::string tmp = contents; scoped_refptr<base::RefCountedString> str = @@ -66,9 +67,8 @@ chunk_ptr)); } - void ReceiveTraceFinalContents( - scoped_ptr<const base::DictionaryValue> , - const std::string& contents) override { + void ReceiveTraceFinalContents(std::unique_ptr<const base::DictionaryValue>, + const std::string& contents) override { BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, base::Bind(&FileTraceDataEndpoint::CloseOnFileThread, this)); @@ -288,7 +288,7 @@ } scoped_refptr<TracingController::TraceDataEndpoint> endpoint_; - scoped_ptr<z_stream> stream_; + std::unique_ptr<z_stream> stream_; bool already_tried_open_; std::string compressed_trace_data_; @@ -324,12 +324,13 @@ metadata_filter_predicate_ = metadata_filter_predicate; } -scoped_ptr<const base::DictionaryValue> - TracingController::TraceDataSink::GetMetadataCopy() const { +std::unique_ptr<const base::DictionaryValue> +TracingController::TraceDataSink::GetMetadataCopy() const { if (metadata_filter_predicate_.is_null()) - return scoped_ptr<const base::DictionaryValue>(metadata_.DeepCopy()); + return std::unique_ptr<const base::DictionaryValue>(metadata_.DeepCopy()); - scoped_ptr<base::DictionaryValue> metadata_copy(new base::DictionaryValue); + std::unique_ptr<base::DictionaryValue> metadata_copy( + new base::DictionaryValue); for (base::DictionaryValue::Iterator it(metadata_); !it.IsAtEnd(); it.Advance()) { if (metadata_filter_predicate_.Run(it.key())) @@ -342,7 +343,7 @@ scoped_refptr<TracingController::TraceDataSink> TracingController::CreateStringSink( - const base::Callback<void(scoped_ptr<const base::DictionaryValue>, + const base::Callback<void(std::unique_ptr<const base::DictionaryValue>, base::RefCountedString*)>& callback) { return new StringTraceDataSink(new StringTraceDataEndpoint(callback)); } @@ -361,9 +362,9 @@ } scoped_refptr<TracingController::TraceDataEndpoint> -TracingController::CreateCallbackEndpoint(const base::Callback< - void(scoped_ptr<const base::DictionaryValue>, - base::RefCountedString*)>& callback) { +TracingController::CreateCallbackEndpoint( + const base::Callback<void(std::unique_ptr<const base::DictionaryValue>, + base::RefCountedString*)>& callback) { return new StringTraceDataEndpoint(callback); }
diff --git a/content/browser/tracing/tracing_ui.cc b/content/browser/tracing/tracing_ui.cc index 074a771..04452c4 100644 --- a/content/browser/tracing/tracing_ui.cc +++ b/content/browser/tracing/tracing_ui.cc
@@ -6,6 +6,7 @@ #include <stddef.h> +#include <memory> #include <set> #include <string> #include <vector> @@ -17,7 +18,6 @@ #include "base/format_macros.h" #include "base/json/json_reader.h" #include "base/json/json_writer.h" -#include "base/memory/scoped_ptr.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_split.h" #include "base/strings/string_util.h" @@ -62,7 +62,7 @@ return false; } - scoped_ptr<base::Value> optionsRaw = base::JSONReader::Read(data); + std::unique_ptr<base::Value> optionsRaw = base::JSONReader::Read(data); if (!optionsRaw) { LOG(ERROR) << "Options were not valid JSON"; return false; @@ -147,7 +147,7 @@ void TracingCallbackWrapperBase64( const WebUIDataSource::GotDataCallback& callback, - scoped_ptr<const base::DictionaryValue> metadata, + std::unique_ptr<const base::DictionaryValue> metadata, base::RefCountedString* data) { base::RefCountedString* data_base64 = new base::RefCountedString(); base::Base64Encode(data->data(), &data_base64->data());
diff --git a/content/browser/tracing/tracing_ui.h b/content/browser/tracing/tracing_ui.h index 4e65de1..fdbe0c19 100644 --- a/content/browser/tracing/tracing_ui.h +++ b/content/browser/tracing/tracing_ui.h
@@ -33,8 +33,8 @@ void DoUpload(const base::ListValue* args); void DoUploadBase64Encoded(const base::ListValue* args); - scoped_ptr<TracingDelegate> delegate_; - scoped_ptr<TraceUploader> trace_uploader_; + std::unique_ptr<TracingDelegate> delegate_; + std::unique_ptr<TraceUploader> trace_uploader_; base::WeakPtrFactory<TracingUI> weak_factory_; DISALLOW_COPY_AND_ASSIGN(TracingUI);
diff --git a/content/browser/utility_process_host_impl.cc b/content/browser/utility_process_host_impl.cc index 0ad33097..7e275aca 100644 --- a/content/browser/utility_process_host_impl.cc +++ b/content/browser/utility_process_host_impl.cc
@@ -248,8 +248,10 @@ return true; bool mojo_result = mojo_application_host_->Init(); - if (!mojo_result) + if (!mojo_result) { + NotifyAndDelete(); return false; + } // Name must be set or metrics_service will crash in any test which // launches a UtilityProcessHost. @@ -257,8 +259,10 @@ process_->SetName(name_); std::string channel_id = process_->GetHost()->CreateChannel(); - if (channel_id.empty()) + if (channel_id.empty()) { + NotifyAndDelete(); return false; + } if (RenderProcessHost::run_renderer_in_process()) { DCHECK(g_utility_main_thread_factory); @@ -403,4 +407,21 @@ mojo_application_host_->Activate(this, handle); } +void UtilityProcessHostImpl::NotifyAndDelete() { + BrowserThread::PostTask( + BrowserThread::IO, FROM_HERE, + base::Bind(&UtilityProcessHostImpl::NotifyLaunchFailedAndDelete, + weak_ptr_factory_.GetWeakPtr())); +} + +// static +void UtilityProcessHostImpl::NotifyLaunchFailedAndDelete( + base::WeakPtr<UtilityProcessHostImpl> host) { + if (!host) + return; + + host->OnProcessLaunchFailed(); + delete host.get(); +} + } // namespace content
diff --git a/content/browser/utility_process_host_impl.h b/content/browser/utility_process_host_impl.h index 2597495..4bf0c3d 100644 --- a/content/browser/utility_process_host_impl.h +++ b/content/browser/utility_process_host_impl.h
@@ -5,6 +5,7 @@ #ifndef CONTENT_BROWSER_UTILITY_PROCESS_HOST_IMPL_H_ #define CONTENT_BROWSER_UTILITY_PROCESS_HOST_IMPL_H_ +#include <memory> #include <string> #include <vector> @@ -12,7 +13,6 @@ #include "base/files/file_path.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "build/build_config.h" #include "content/public/browser/browser_child_process_host_delegate.h" @@ -79,6 +79,13 @@ void OnProcessCrashed(int exit_code) override; void OnProcessLaunched() override; + // Cleans up |this| as a result of a failed Start(). + void NotifyAndDelete(); + + // Notifies the client that the launch failed and deletes |host|. + static void NotifyLaunchFailedAndDelete( + base::WeakPtr<UtilityProcessHostImpl> host); + // A pointer to our client interface, who will be informed of progress. scoped_refptr<UtilityProcessHostClient> client_; scoped_refptr<base::SequencedTaskRunner> client_task_runner_; @@ -105,14 +112,14 @@ // process in the task manager. base::string16 name_; - scoped_ptr<BrowserChildProcessHostImpl> process_; + std::unique_ptr<BrowserChildProcessHostImpl> process_; // Used in single-process mode instead of process_. - scoped_ptr<base::Thread> in_process_thread_; + std::unique_ptr<base::Thread> in_process_thread_; // Browser-side Mojo endpoint which sets up a Mojo channel with the child // process and contains the browser's ServiceRegistry. - scoped_ptr<MojoApplicationHost> mojo_application_host_; + std::unique_ptr<MojoApplicationHost> mojo_application_host_; // Used to vend weak pointers, and should always be declared last. base::WeakPtrFactory<UtilityProcessHostImpl> weak_ptr_factory_;
diff --git a/content/browser/vr/android/cardboard/cardboard_vr_device_provider.h b/content/browser/vr/android/cardboard/cardboard_vr_device_provider.h index b041316..d8133f4 100644 --- a/content/browser/vr/android/cardboard/cardboard_vr_device_provider.h +++ b/content/browser/vr/android/cardboard/cardboard_vr_device_provider.h
@@ -6,9 +6,9 @@ #define CONTENT_BROWSER_VR_CARDBOARD_VR_DEVICE_PROVIDER_H #include <map> +#include <memory> #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/vr/vr_device.h" #include "content/browser/vr/vr_device_provider.h" @@ -23,7 +23,7 @@ void Initialize() override; private: - scoped_ptr<VRDevice> cardboard_device_; + std::unique_ptr<VRDevice> cardboard_device_; DISALLOW_COPY_AND_ASSIGN(CardboardVRDeviceProvider); };
diff --git a/content/browser/vr/vr_device_manager.cc b/content/browser/vr/vr_device_manager.cc index 181f48d..644522a 100644 --- a/content/browser/vr/vr_device_manager.cc +++ b/content/browser/vr/vr_device_manager.cc
@@ -27,13 +27,13 @@ base::Bind(&VRDeviceManager::OnConnectionError, base::Unretained(this))); // Register VRDeviceProviders for the current platform #if defined(OS_ANDROID) - scoped_ptr<VRDeviceProvider> cardboard_provider( + std::unique_ptr<VRDeviceProvider> cardboard_provider( new CardboardVRDeviceProvider()); RegisterProvider(std::move(cardboard_provider)); #endif } -VRDeviceManager::VRDeviceManager(scoped_ptr<VRDeviceProvider> provider) +VRDeviceManager::VRDeviceManager(std::unique_ptr<VRDeviceProvider> provider) : vr_initialized_(false), keep_alive_(true) { thread_checker_.DetachFromThread(); RegisterProvider(std::move(provider)); @@ -127,7 +127,8 @@ vr_initialized_ = true; } -void VRDeviceManager::RegisterProvider(scoped_ptr<VRDeviceProvider> provider) { +void VRDeviceManager::RegisterProvider( + std::unique_ptr<VRDeviceProvider> provider) { providers_.push_back(make_linked_ptr(provider.release())); }
diff --git a/content/browser/vr/vr_device_manager.h b/content/browser/vr/vr_device_manager.h index f1dc81b0..9431eddf 100644 --- a/content/browser/vr/vr_device_manager.h +++ b/content/browser/vr/vr_device_manager.h
@@ -8,11 +8,11 @@ #include <stdint.h> #include <map> +#include <memory> #include <vector> #include "base/macros.h" #include "base/memory/linked_ptr.h" -#include "base/memory/scoped_ptr.h" #include "base/threading/thread_checker.h" #include "content/browser/vr/vr_device.h" #include "content/browser/vr/vr_device_provider.h" @@ -39,13 +39,13 @@ VRDeviceManager(); // Constructor for testing. - explicit VRDeviceManager(scoped_ptr<VRDeviceProvider> provider); + explicit VRDeviceManager(std::unique_ptr<VRDeviceProvider> provider); static void SetInstance(VRDeviceManager* service); static bool HasInstance(); void InitializeProviders(); - void RegisterProvider(scoped_ptr<VRDeviceProvider> provider); + void RegisterProvider(std::unique_ptr<VRDeviceProvider> provider); // mojom::VRService implementation void GetDevices(const GetDevicesCallback& callback) override;
diff --git a/content/browser/vr/vr_device_manager_unittest.cc b/content/browser/vr/vr_device_manager_unittest.cc index 86f35ae..93c2ada4 100644 --- a/content/browser/vr/vr_device_manager_unittest.cc +++ b/content/browser/vr/vr_device_manager_unittest.cc
@@ -2,14 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/browser/vr/vr_device_manager.h" + +#include <memory> #include <utility> #include "base/macros.h" #include "base/memory/linked_ptr.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/vr/test/fake_vr_device.h" #include "content/browser/vr/test/fake_vr_device_provider.h" -#include "content/browser/vr/vr_device_manager.h" #include "content/browser/vr/vr_device_provider.h" #include "testing/gtest/include/gtest/gtest.h" @@ -26,7 +27,7 @@ protected: FakeVRDeviceProvider* provider_; - scoped_ptr<VRDeviceManager> device_manager_; + std::unique_ptr<VRDeviceManager> device_manager_; DISALLOW_COPY_AND_ASSIGN(VRDeviceManagerTest); }; @@ -38,7 +39,7 @@ } void VRDeviceManagerTest::SetUp() { - scoped_ptr<FakeVRDeviceProvider> provider(new FakeVRDeviceProvider()); + std::unique_ptr<FakeVRDeviceProvider> provider(new FakeVRDeviceProvider()); provider_ = provider.get(); device_manager_.reset(new VRDeviceManager(std::move(provider))); } @@ -67,7 +68,7 @@ VRDevice* queried_device = device_manager_->GetDevice(1); EXPECT_EQ(nullptr, queried_device); - scoped_ptr<FakeVRDevice> device1(new FakeVRDevice(provider_)); + std::unique_ptr<FakeVRDevice> device1(new FakeVRDevice(provider_)); provider_->AddDevice(device1.get()); webvr_devices = device_manager_->GetVRDevices(); // Should have successfully returned one device. @@ -75,7 +76,7 @@ // The WebVRDevice index should match the device id. EXPECT_EQ(webvr_devices[0]->index, device1->id()); - scoped_ptr<FakeVRDevice> device2(new FakeVRDevice(provider_)); + std::unique_ptr<FakeVRDevice> device2(new FakeVRDevice(provider_)); provider_->AddDevice(device2.get()); webvr_devices = device_manager_->GetVRDevices(); // Should have successfully returned two devices.
diff --git a/content/browser/wake_lock/wake_lock_service_context.h b/content/browser/wake_lock/wake_lock_service_context.h index 73527dc..f27461c 100644 --- a/content/browser/wake_lock/wake_lock_service_context.h +++ b/content/browser/wake_lock/wake_lock_service_context.h
@@ -5,11 +5,11 @@ #ifndef CONTENT_BROWSER_WAKE_LOCK_WAKE_LOCK_SERVICE_CONTEXT_H_ #define CONTENT_BROWSER_WAKE_LOCK_WAKE_LOCK_SERVICE_CONTEXT_H_ +#include <memory> #include <set> #include <utility> #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "content/browser/wake_lock/wake_lock_service_impl.h" #include "content/common/content_export.h" @@ -56,7 +56,7 @@ std::set<std::pair<int, int>> frames_requesting_lock_; // The actual power save blocker for screen. - scoped_ptr<PowerSaveBlocker> wake_lock_; + std::unique_ptr<PowerSaveBlocker> wake_lock_; base::WeakPtrFactory<WakeLockServiceContext> weak_factory_;
diff --git a/content/browser/wake_lock/wake_lock_service_context_unittest.cc b/content/browser/wake_lock/wake_lock_service_context_unittest.cc index 4921158..4802109 100644 --- a/content/browser/wake_lock/wake_lock_service_context_unittest.cc +++ b/content/browser/wake_lock/wake_lock_service_context_unittest.cc
@@ -4,7 +4,8 @@ #include "content/browser/wake_lock/wake_lock_service_context.h" -#include "base/memory/scoped_ptr.h" +#include <memory> + #include "base/process/kill.h" #include "content/browser/web_contents/web_contents_impl.h" #include "content/public/browser/render_frame_host.h"
diff --git a/content/browser/web_contents/aura/gesture_nav_simple.cc b/content/browser/web_contents/aura/gesture_nav_simple.cc index debe711..4ff4abe5 100644 --- a/content/browser/web_contents/aura/gesture_nav_simple.cc +++ b/content/browser/web_contents/aura/gesture_nav_simple.cc
@@ -51,7 +51,7 @@ template <class T> class DeleteAfterAnimation : public ui::ImplicitAnimationObserver { public: - explicit DeleteAfterAnimation(scoped_ptr<T> object) + explicit DeleteAfterAnimation(std::unique_ptr<T> object) : object_(std::move(object)) {} private: @@ -67,7 +67,7 @@ BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, this); } - scoped_ptr<T> object_; + std::unique_ptr<T> object_; DISALLOW_COPY_AND_ASSIGN(DeleteAfterAnimation); };
diff --git a/content/browser/web_contents/aura/gesture_nav_simple.h b/content/browser/web_contents/aura/gesture_nav_simple.h index 999ef262..d2c5937 100644 --- a/content/browser/web_contents/aura/gesture_nav_simple.h +++ b/content/browser/web_contents/aura/gesture_nav_simple.h
@@ -5,8 +5,9 @@ #ifndef CONTENT_BROWSER_WEB_CONTENTS_AURA_GESTURE_NAV_SIMPLE_H_ #define CONTENT_BROWSER_WEB_CONTENTS_AURA_GESTURE_NAV_SIMPLE_H_ +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/renderer_host/overscroll_controller_delegate.h" namespace gfx { @@ -44,9 +45,9 @@ OverscrollMode new_mode) override; WebContentsImpl* web_contents_; - scoped_ptr<ui::Layer> clip_layer_; - scoped_ptr<ui::Layer> arrow_; - scoped_ptr<ArrowLayerDelegate> arrow_delegate_; + std::unique_ptr<ui::Layer> clip_layer_; + std::unique_ptr<ui::Layer> arrow_; + std::unique_ptr<ArrowLayerDelegate> arrow_delegate_; float completion_threshold_; DISALLOW_COPY_AND_ASSIGN(GestureNavSimple);
diff --git a/content/browser/web_contents/aura/overscroll_navigation_overlay.cc b/content/browser/web_contents/aura/overscroll_navigation_overlay.cc index b05feedb..56e4a42 100644 --- a/content/browser/web_contents/aura/overscroll_navigation_overlay.cc +++ b/content/browser/web_contents/aura/overscroll_navigation_overlay.cc
@@ -53,7 +53,7 @@ : public ui::LayerAnimationObserver { public: // Takes ownership of the layer. - explicit OverlayDismissAnimator(scoped_ptr<ui::Layer> layer) + explicit OverlayDismissAnimator(std::unique_ptr<ui::Layer> layer) : layer_(std::move(layer)) { CHECK(layer_.get()); } @@ -85,7 +85,7 @@ private: ~OverlayDismissAnimator() override {} - scoped_ptr<ui::Layer> layer_; + std::unique_ptr<ui::Layer> layer_; DISALLOW_COPY_AND_ASSIGN(OverlayDismissAnimator); }; @@ -133,7 +133,7 @@ // OverlayDismissAnimator deletes the dismiss layer and itself when the // animation completes. - scoped_ptr<ui::Layer> dismiss_layer = window_->AcquireLayer(); + std::unique_ptr<ui::Layer> dismiss_layer = window_->AcquireLayer(); window_.reset(); (new OverlayDismissAnimator(std::move(dismiss_layer)))->Animate(); Observe(nullptr); @@ -141,13 +141,13 @@ loading_complete_ = false; } -scoped_ptr<aura::Window> OverscrollNavigationOverlay::CreateOverlayWindow( +std::unique_ptr<aura::Window> OverscrollNavigationOverlay::CreateOverlayWindow( const gfx::Rect& bounds) { UMA_HISTOGRAM_ENUMERATION( "Overscroll.Started2", direction_, NAVIGATION_COUNT); OverscrollWindowDelegate* overscroll_delegate = new OverscrollWindowDelegate( owa_.get(), GetImageForDirection(direction_)); - scoped_ptr<aura::Window> window(new aura::Window(overscroll_delegate)); + std::unique_ptr<aura::Window> window(new aura::Window(overscroll_delegate)); window->set_owned_by_parent(false); window->SetTransparent(true); window->Init(ui::LAYER_TEXTURED); @@ -182,7 +182,7 @@ return gfx::Image(); } -scoped_ptr<aura::Window> OverscrollNavigationOverlay::CreateFrontWindow( +std::unique_ptr<aura::Window> OverscrollNavigationOverlay::CreateFrontWindow( const gfx::Rect& bounds) { if (!web_contents_->GetController().CanGoForward()) return nullptr; @@ -190,7 +190,7 @@ return CreateOverlayWindow(bounds); } -scoped_ptr<aura::Window> OverscrollNavigationOverlay::CreateBackWindow( +std::unique_ptr<aura::Window> OverscrollNavigationOverlay::CreateBackWindow( const gfx::Rect& bounds) { if (!web_contents_->GetController().CanGoBack()) return nullptr; @@ -214,7 +214,7 @@ } void OverscrollNavigationOverlay::OnOverscrollCompleted( - scoped_ptr<aura::Window> window) { + std::unique_ptr<aura::Window> window) { DCHECK(direction_ != NONE); aura::Window* main_window = GetMainWindow(); if (!main_window) {
diff --git a/content/browser/web_contents/aura/overscroll_navigation_overlay.h b/content/browser/web_contents/aura/overscroll_navigation_overlay.h index 32c9409..2488d88 100644 --- a/content/browser/web_contents/aura/overscroll_navigation_overlay.h +++ b/content/browser/web_contents/aura/overscroll_navigation_overlay.h
@@ -73,18 +73,20 @@ // Creates a window that shows a history-screenshot and is stacked relative to // the current overscroll |direction_| with the given |bounds|. - scoped_ptr<aura::Window> CreateOverlayWindow(const gfx::Rect& bounds); + std::unique_ptr<aura::Window> CreateOverlayWindow(const gfx::Rect& bounds); // Returns an image with the history-screenshot for the previous or next page, // according to the given |direction|. const gfx::Image GetImageForDirection(NavigationDirection direction) const; // Overridden from OverscrollWindowAnimation::Delegate: - scoped_ptr<aura::Window> CreateFrontWindow(const gfx::Rect& bounds) override; - scoped_ptr<aura::Window> CreateBackWindow(const gfx::Rect& bounds) override; + std::unique_ptr<aura::Window> CreateFrontWindow( + const gfx::Rect& bounds) override; + std::unique_ptr<aura::Window> CreateBackWindow( + const gfx::Rect& bounds) override; aura::Window* GetMainWindow() const override; void OnOverscrollCompleting() override; - void OnOverscrollCompleted(scoped_ptr<aura::Window> window) override; + void OnOverscrollCompleted(std::unique_ptr<aura::Window> window) override; void OnOverscrollCancelled() override; // Overridden from WebContentsObserver: @@ -99,7 +101,7 @@ // The overlay window that shows a screenshot during an overscroll gesture and // handles overscroll events during the second overscroll case. - scoped_ptr<aura::Window> window_; + std::unique_ptr<aura::Window> window_; bool loading_complete_; bool received_paint_update_; @@ -110,7 +112,7 @@ GURL pending_entry_url_; // Manages the overscroll animations. - scoped_ptr<OverscrollWindowAnimation> owa_; + std::unique_ptr<OverscrollWindowAnimation> owa_; // The window that hosts the web contents. aura::Window* web_contents_window_;
diff --git a/content/browser/web_contents/aura/overscroll_navigation_overlay_unittest.cc b/content/browser/web_contents/aura/overscroll_navigation_overlay_unittest.cc index 93f166e..69777eb 100644 --- a/content/browser/web_contents/aura/overscroll_navigation_overlay_unittest.cc +++ b/content/browser/web_contents/aura/overscroll_navigation_overlay_unittest.cc
@@ -39,8 +39,8 @@ static OverscrollTestWebContents* Create( BrowserContext* browser_context, scoped_refptr<SiteInstance> instance, - scoped_ptr<aura::Window> fake_native_view, - scoped_ptr<aura::Window> fake_contents_window) { + std::unique_ptr<aura::Window> fake_native_view, + std::unique_ptr<aura::Window> fake_contents_window) { OverscrollTestWebContents* web_contents = new OverscrollTestWebContents( browser_context, std::move(fake_native_view), std::move(fake_contents_window)); @@ -66,16 +66,16 @@ protected: explicit OverscrollTestWebContents( BrowserContext* browser_context, - scoped_ptr<aura::Window> fake_native_view, - scoped_ptr<aura::Window> fake_contents_window) + std::unique_ptr<aura::Window> fake_native_view, + std::unique_ptr<aura::Window> fake_contents_window) : TestWebContents(browser_context), fake_native_view_(std::move(fake_native_view)), fake_contents_window_(std::move(fake_contents_window)), is_being_destroyed_(false) {} private: - scoped_ptr<aura::Window> fake_native_view_; - scoped_ptr<aura::Window> fake_contents_window_; + std::unique_ptr<aura::Window> fake_native_view_; + std::unique_ptr<aura::Window> fake_contents_window_; bool is_being_destroyed_; }; @@ -111,7 +111,7 @@ void PerformBackNavigationViaSliderCallbacks() { // Sets slide direction to BACK, sets screenshot from NavEntry at // offset -1 on layer_delegate_. - scoped_ptr<aura::Window> window( + std::unique_ptr<aura::Window> window( GetOverlay()->CreateBackWindow(GetBackSlideWindowBounds())); bool window_created = !!window; // Performs BACK navigation, sets image from layer_delegate_ on @@ -155,13 +155,14 @@ RenderViewHostImplTestHarness::SetUp(); // Set up the fake web contents native view. - scoped_ptr<aura::Window> fake_native_view(new aura::Window(nullptr)); + std::unique_ptr<aura::Window> fake_native_view(new aura::Window(nullptr)); fake_native_view->Init(ui::LAYER_SOLID_COLOR); root_window()->AddChild(fake_native_view.get()); fake_native_view->SetBounds(gfx::Rect(root_window()->bounds().size())); // Set up the fake contents window. - scoped_ptr<aura::Window> fake_contents_window(new aura::Window(nullptr)); + std::unique_ptr<aura::Window> fake_contents_window( + new aura::Window(nullptr)); fake_contents_window->Init(ui::LAYER_SOLID_COLOR); root_window()->AddChild(fake_contents_window.get()); fake_contents_window->SetBounds(gfx::Rect(root_window()->bounds().size())); @@ -216,7 +217,7 @@ const GURL third_; const GURL fourth_; - scoped_ptr<OverscrollNavigationOverlay> overlay_; + std::unique_ptr<OverscrollNavigationOverlay> overlay_; DISALLOW_COPY_AND_ASSIGN(OverscrollNavigationOverlayTest); }; @@ -250,7 +251,7 @@ // Tests that if a navigation is cancelled, no navigation is performed and the // state is restored. TEST_F(OverscrollNavigationOverlayTest, CancelNavigation) { - scoped_ptr<aura::Window> window = + std::unique_ptr<aura::Window> window = GetOverlay()->CreateBackWindow(GetBackSlideWindowBounds()); EXPECT_EQ(GetOverlay()->direction_, OverscrollNavigationOverlay::BACK); @@ -263,7 +264,7 @@ // first one worked correctly. TEST_F(OverscrollNavigationOverlayTest, CancelAfterSuccessfulNavigation) { PerformBackNavigationViaSliderCallbacks(); - scoped_ptr<aura::Window> wrapper = + std::unique_ptr<aura::Window> wrapper = GetOverlay()->CreateBackWindow(GetBackSlideWindowBounds()); EXPECT_EQ(GetOverlay()->direction_, OverscrollNavigationOverlay::BACK);
diff --git a/content/browser/web_contents/aura/overscroll_window_animation.h b/content/browser/web_contents/aura/overscroll_window_animation.h index 9295290..87819780 100644 --- a/content/browser/web_contents/aura/overscroll_window_animation.h +++ b/content/browser/web_contents/aura/overscroll_window_animation.h
@@ -5,8 +5,9 @@ #ifndef CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_WINDOW_ANIMATION_H_ #define CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_WINDOW_ANIMATION_H_ +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/renderer_host/overscroll_controller_delegate.h" #include "content/common/content_export.h" #include "ui/compositor/layer_animation_observer.h" @@ -48,9 +49,9 @@ virtual ~Delegate() {} // Create a slide window with the given |bounds| relative to its parent. - virtual scoped_ptr<aura::Window> CreateFrontWindow( + virtual std::unique_ptr<aura::Window> CreateFrontWindow( const gfx::Rect& bounds) = 0; - virtual scoped_ptr<aura::Window> CreateBackWindow( + virtual std::unique_ptr<aura::Window> CreateBackWindow( const gfx::Rect& bounds) = 0; // Returns the main window that participates in the animation. The delegate @@ -63,7 +64,8 @@ // Called when the animation has been completed. The slide window is // transferred to the delegate. - virtual void OnOverscrollCompleted(scoped_ptr<aura::Window> window) = 0; + virtual void OnOverscrollCompleted( + std::unique_ptr<aura::Window> window) = 0; // Called when the overscroll gesture has been cancelled, after the cancel // animation finishes. @@ -107,10 +109,10 @@ void OnImplicitAnimationsCompleted() override; // We own the window created for the animation. - scoped_ptr<aura::Window> slide_window_; + std::unique_ptr<aura::Window> slide_window_; // Shadow shown under the animated layer. - scoped_ptr<ShadowLayerDelegate> shadow_; + std::unique_ptr<ShadowLayerDelegate> shadow_; // Delegate that provides the animation target and is notified of the // animation state.
diff --git a/content/browser/web_contents/aura/overscroll_window_animation_unittest.cc b/content/browser/web_contents/aura/overscroll_window_animation_unittest.cc index a34c41b8..c8006b1 100644 --- a/content/browser/web_contents/aura/overscroll_window_animation_unittest.cc +++ b/content/browser/web_contents/aura/overscroll_window_animation_unittest.cc
@@ -66,11 +66,13 @@ } // OverscrollWindowAnimation::Delegate: - scoped_ptr<aura::Window> CreateFrontWindow(const gfx::Rect& bounds) override { + std::unique_ptr<aura::Window> CreateFrontWindow( + const gfx::Rect& bounds) override { return CreateSlideWindow(bounds); } - scoped_ptr<aura::Window> CreateBackWindow(const gfx::Rect& bounds) override { + std::unique_ptr<aura::Window> CreateBackWindow( + const gfx::Rect& bounds) override { return CreateSlideWindow(bounds); } @@ -78,7 +80,7 @@ void OnOverscrollCompleting() override { overscroll_completing_ = true; } - void OnOverscrollCompleted(scoped_ptr<aura::Window> window) override { + void OnOverscrollCompleted(std::unique_ptr<aura::Window> window) override { overscroll_completed_ = true; } @@ -86,12 +88,12 @@ private: // The overscroll window animation under test. - scoped_ptr<OverscrollWindowAnimation> owa_; + std::unique_ptr<OverscrollWindowAnimation> owa_; - scoped_ptr<aura::Window> CreateSlideWindow(const gfx::Rect& bounds) { + std::unique_ptr<aura::Window> CreateSlideWindow(const gfx::Rect& bounds) { overscroll_started_ = true; if (create_window_) { - scoped_ptr<aura::Window> window( + std::unique_ptr<aura::Window> window( CreateNormalWindow(++last_window_id_, root_window(), nullptr)); window->SetBounds(bounds); return window; @@ -111,7 +113,7 @@ int last_window_id_; // The dummy target window we provide. - scoped_ptr<aura::Window> main_window_; + std::unique_ptr<aura::Window> main_window_; DISALLOW_COPY_AND_ASSIGN(OverscrollWindowAnimationTest); };
diff --git a/content/browser/web_contents/aura/overscroll_window_delegate_unittest.cc b/content/browser/web_contents/aura/overscroll_window_delegate_unittest.cc index 6b1b546..8a76f29 100644 --- a/content/browser/web_contents/aura/overscroll_window_delegate_unittest.cc +++ b/content/browser/web_contents/aura/overscroll_window_delegate_unittest.cc
@@ -98,7 +98,7 @@ } // Window in which the overscroll window delegate is installed. - scoped_ptr<aura::Window> window_; + std::unique_ptr<aura::Window> window_; // State flags. bool overscroll_complete_;
diff --git a/content/browser/web_contents/aura/shadow_layer_delegate.h b/content/browser/web_contents/aura/shadow_layer_delegate.h index 3f47759..6c1729f 100644 --- a/content/browser/web_contents/aura/shadow_layer_delegate.h +++ b/content/browser/web_contents/aura/shadow_layer_delegate.h
@@ -5,9 +5,10 @@ #ifndef CONTENT_BROWSER_WEB_CONTENTS_AURA_SHADOW_LAYER_DELEGATE_H_ #define CONTENT_BROWSER_WEB_CONTENTS_AURA_SHADOW_LAYER_DELEGATE_H_ +#include <memory> + #include "base/compiler_specific.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "ui/compositor/layer_delegate.h" namespace aura { @@ -38,7 +39,7 @@ void OnDeviceScaleFactorChanged(float device_scale_factor) override; base::Closure PrepareForLayerBoundsChange() override; - scoped_ptr<ui::Layer> layer_; + std::unique_ptr<ui::Layer> layer_; DISALLOW_COPY_AND_ASSIGN(ShadowLayerDelegate); };
diff --git a/content/browser/web_contents/web_contents_android.cc b/content/browser/web_contents/web_contents_android.cc index defe5abd..f62338c 100644 --- a/content/browser/web_contents/web_contents_android.cc +++ b/content/browser/web_contents/web_contents_android.cc
@@ -164,7 +164,7 @@ Java_WebContentsImpl_onAccessibilitySnapshot(env, nullptr, callback.obj()); return; } - scoped_ptr<BrowserAccessibilityManagerAndroid> manager( + std::unique_ptr<BrowserAccessibilityManagerAndroid> manager( static_cast<BrowserAccessibilityManagerAndroid*>( BrowserAccessibilityManager::Create(result, nullptr))); manager->set_prune_tree_for_screen_reader(false);
diff --git a/content/browser/web_contents/web_contents_android.h b/content/browser/web_contents/web_contents_android.h index 0dc47fd..065b421b 100644 --- a/content/browser/web_contents/web_contents_android.h +++ b/content/browser/web_contents/web_contents_android.h
@@ -7,11 +7,12 @@ #include <jni.h> +#include <memory> + #include "base/android/jni_android.h" #include "base/android/scoped_java_ref.h" #include "base/compiler_specific.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/supports_user_data.h" #include "content/browser/frame_host/navigation_controller_android.h"
diff --git a/content/browser/web_contents/web_contents_delegate_unittest.cc b/content/browser/web_contents/web_contents_delegate_unittest.cc index 0de5919..90358587 100644 --- a/content/browser/web_contents/web_contents_delegate_unittest.cc +++ b/content/browser/web_contents/web_contents_delegate_unittest.cc
@@ -2,11 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/public/browser/web_contents_delegate.h" + +#include <memory> + #include "base/compiler_specific.h" -#include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" #include "content/browser/web_contents/web_contents_impl.h" -#include "content/public/browser/web_contents_delegate.h" #include "content/public/test/test_browser_context.h" #include "content/test/test_render_view_host.h" #include "testing/gtest/include/gtest/gtest.h" @@ -20,14 +22,15 @@ }; TEST_F(WebContentsDelegateTest, UnregisterInDestructor) { - scoped_ptr<WebContentsImpl> contents_a(static_cast<WebContentsImpl*>( + std::unique_ptr<WebContentsImpl> contents_a(static_cast<WebContentsImpl*>( WebContents::Create(WebContents::CreateParams(browser_context())))); - scoped_ptr<WebContentsImpl> contents_b(static_cast<WebContentsImpl*>( + std::unique_ptr<WebContentsImpl> contents_b(static_cast<WebContentsImpl*>( WebContents::Create(WebContents::CreateParams(browser_context())))); EXPECT_EQ(NULL, contents_a->GetDelegate()); EXPECT_EQ(NULL, contents_b->GetDelegate()); - scoped_ptr<MockWebContentsDelegate> delegate(new MockWebContentsDelegate()); + std::unique_ptr<MockWebContentsDelegate> delegate( + new MockWebContentsDelegate()); // Setting a delegate should work correctly. contents_a->SetDelegate(delegate.get());
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index 61d8bf3..37d88b0b 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc
@@ -422,11 +422,11 @@ if (root->pending_frame_host()) { root->pending_frame_host()->SetRenderFrameCreated(false); root->pending_frame_host()->SetNavigationHandle( - scoped_ptr<NavigationHandleImpl>()); + std::unique_ptr<NavigationHandleImpl>()); } root->current_frame_host()->SetRenderFrameCreated(false); root->current_frame_host()->SetNavigationHandle( - scoped_ptr<NavigationHandleImpl>()); + std::unique_ptr<NavigationHandleImpl>()); // PlzNavigate: clear up state specific to browser-side navigation. if (IsBrowserSideNavigationEnabled()) { @@ -435,7 +435,7 @@ if (root->speculative_frame_host()) { root->speculative_frame_host()->SetRenderFrameCreated(false); root->speculative_frame_host()->SetNavigationHandle( - scoped_ptr<NavigationHandleImpl>()); + std::unique_ptr<NavigationHandleImpl>()); } } @@ -514,7 +514,7 @@ // static std::vector<WebContentsImpl*> WebContentsImpl::GetAllWebContents() { std::vector<WebContentsImpl*> result; - scoped_ptr<RenderWidgetHostIterator> widgets( + std::unique_ptr<RenderWidgetHostIterator> widgets( RenderWidgetHostImpl::GetRenderWidgetHosts()); while (RenderWidgetHost* rwh = widgets->GetNextHost()) { RenderViewHost* rvh = RenderViewHost::From(rwh); @@ -2151,9 +2151,8 @@ if (delegate_) { delegate_->RequestMediaAccessPermission(this, request, callback); } else { - callback.Run(MediaStreamDevices(), - MEDIA_DEVICE_FAILED_DUE_TO_SHUTDOWN, - scoped_ptr<MediaStreamUI>()); + callback.Run(MediaStreamDevices(), MEDIA_DEVICE_FAILED_DUE_TO_SHUTDOWN, + std::unique_ptr<MediaStreamUI>()); } } @@ -2708,7 +2707,7 @@ if (entry) post_id = entry->GetPostID(); } - scoped_ptr<DownloadUrlParameters> params( + std::unique_ptr<DownloadUrlParameters> params( DownloadUrlParameters::FromWebContents(this, url)); params->set_referrer(referrer); params->set_post_id(post_id); @@ -4181,7 +4180,7 @@ } void WebContentsImpl::DidStopLoading() { - scoped_ptr<LoadNotificationDetails> details; + std::unique_ptr<LoadNotificationDetails> details; // Use the last committed entry rather than the active one, in case a // pending entry has been created. @@ -4585,10 +4584,10 @@ return GetController(); } -scoped_ptr<WebUIImpl> WebContentsImpl::CreateWebUIForRenderFrameHost( +std::unique_ptr<WebUIImpl> WebContentsImpl::CreateWebUIForRenderFrameHost( const GURL& url) { - return scoped_ptr<WebUIImpl>(static_cast<WebUIImpl*>(CreateWebUI( - url, std::string()))); + return std::unique_ptr<WebUIImpl>( + static_cast<WebUIImpl*>(CreateWebUI(url, std::string()))); } NavigationEntry*
diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h index 75eb253..a1e6bbb1 100644 --- a/content/browser/web_contents/web_contents_impl.h +++ b/content/browser/web_contents/web_contents_impl.h
@@ -9,6 +9,7 @@ #include <functional> #include <map> +#include <memory> #include <set> #include <string> @@ -16,7 +17,6 @@ #include "base/containers/scoped_ptr_hash_map.h" #include "base/gtest_prod_util.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/observer_list.h" #include "base/process/process.h" #include "base/values.h" @@ -442,7 +442,8 @@ RenderFrameHost* target_rfh, SiteInstance* source_site_instance) const override; void EnsureOpenerProxiesExist(RenderFrameHost* source_rfh) override; - scoped_ptr<WebUIImpl> CreateWebUIForRenderFrameHost(const GURL& url) override; + std::unique_ptr<WebUIImpl> CreateWebUIForRenderFrameHost( + const GURL& url) override; // RenderViewHostDelegate ---------------------------------------------------- RenderViewHostDelegateView* GetDelegateView() override; @@ -1046,7 +1047,7 @@ NavigationControllerImpl controller_; // The corresponding view. - scoped_ptr<WebContentsView> view_; + std::unique_ptr<WebContentsView> view_; // The view of the RVHD. Usually this is our WebContentsView implementation, // but if an embedder uses a different WebContentsView, they'll need to @@ -1083,7 +1084,7 @@ // If this WebContents is part of a "tree of WebContents", then this contains // information about the structure. - scoped_ptr<WebContentsTreeNode> node_; + std::unique_ptr<WebContentsTreeNode> node_; // SavePackage, lazily created. scoped_refptr<SavePackage> save_package_; @@ -1217,7 +1218,7 @@ #if defined(OS_ANDROID) // Date time chooser opened by this tab. // Only used in Android since all other platforms use a multi field UI. - scoped_ptr<DateTimeChooserAndroid> date_time_chooser_; + std::unique_ptr<DateTimeChooserAndroid> date_time_chooser_; #endif // Holds information about a current color chooser dialog, if one is visible. @@ -1232,7 +1233,7 @@ int render_frame_id; // Color chooser that was opened by this tab. - scoped_ptr<ColorChooser> chooser; + std::unique_ptr<ColorChooser> chooser; // A unique identifier for the current color chooser. Identifiers are // unique across a renderer process. This avoids race conditions in @@ -1244,18 +1245,19 @@ int identifier; }; - scoped_ptr<ColorChooserInfo> color_chooser_info_; + std::unique_ptr<ColorChooserInfo> color_chooser_info_; // Manages the embedder state for browser plugins, if this WebContents is an // embedder; NULL otherwise. - scoped_ptr<BrowserPluginEmbedder> browser_plugin_embedder_; + std::unique_ptr<BrowserPluginEmbedder> browser_plugin_embedder_; // Manages the guest state for browser plugin, if this WebContents is a guest; // NULL otherwise. - scoped_ptr<BrowserPluginGuest> browser_plugin_guest_; + std::unique_ptr<BrowserPluginGuest> browser_plugin_guest_; #if defined(ENABLE_PLUGINS) // Manages the whitelist of plugin content origins exempt from power saving. - scoped_ptr<PluginContentOriginWhitelist> plugin_content_origin_whitelist_; + std::unique_ptr<PluginContentOriginWhitelist> + plugin_content_origin_whitelist_; #endif // This must be at the end, or else we might get notifications and use other @@ -1287,7 +1289,7 @@ // When a new tab is created asynchronously, stores the OpenURLParams needed // to continue loading the page once the tab is ready. - scoped_ptr<OpenURLParams> delayed_open_url_params_; + std::unique_ptr<OpenURLParams> delayed_open_url_params_; // Whether overscroll should be unconditionally disabled. bool force_disable_overscroll_content_; @@ -1295,14 +1297,14 @@ // Whether the last JavaScript dialog shown was suppressed. Used for testing. bool last_dialog_suppressed_; - scoped_ptr<GeolocationServiceContext> geolocation_service_context_; + std::unique_ptr<GeolocationServiceContext> geolocation_service_context_; - scoped_ptr<WakeLockServiceContext> wake_lock_service_context_; + std::unique_ptr<WakeLockServiceContext> wake_lock_service_context_; - scoped_ptr<ScreenOrientationDispatcherHost> + std::unique_ptr<ScreenOrientationDispatcherHost> screen_orientation_dispatcher_host_; - scoped_ptr<ManifestManagerHost> manifest_manager_host_; + std::unique_ptr<ManifestManagerHost> manifest_manager_host_; // The accessibility mode for all frames. This is queried when each frame // is created, and broadcast to all frames when it changes. @@ -1312,19 +1314,19 @@ AudioStreamMonitor audio_stream_monitor_; // Created on-demand to mute all audio output from this WebContents. - scoped_ptr<WebContentsAudioMuter> audio_muter_; + std::unique_ptr<WebContentsAudioMuter> audio_muter_; size_t bluetooth_connected_device_count_; bool virtual_keyboard_requested_; // Notifies ResourceDispatcherHostImpl of various events related to loading. - scoped_ptr<LoaderIOThreadNotifier> loader_io_thread_notifier_; + std::unique_ptr<LoaderIOThreadNotifier> loader_io_thread_notifier_; // Manages media players, CDMs, and power save blockers for media. - scoped_ptr<MediaWebContentsObserver> media_web_contents_observer_; + std::unique_ptr<MediaWebContentsObserver> media_web_contents_observer_; - scoped_ptr<RenderWidgetHostInputEventRouter> rwh_input_event_router_; + std::unique_ptr<RenderWidgetHostInputEventRouter> rwh_input_event_router_; PageImportanceSignals page_importance_signals_; @@ -1335,7 +1337,7 @@ // A copy of the text input state from |view_with_active_text_input_| when // there exists one, or empty (type == ui::TEXT_INPUT_TYPE_NONE) if otherwise. - scoped_ptr<TextInputState> text_input_state_; + std::unique_ptr<TextInputState> text_input_state_; base::WeakPtrFactory<WebContentsImpl> loading_weak_factory_; base::WeakPtrFactory<WebContentsImpl> weak_factory_;
diff --git a/content/browser/web_contents/web_contents_impl_browsertest.cc b/content/browser/web_contents/web_contents_impl_browsertest.cc index 6534b14..55e00c56 100644 --- a/content/browser/web_contents/web_contents_impl_browsertest.cc +++ b/content/browser/web_contents/web_contents_impl_browsertest.cc
@@ -283,7 +283,8 @@ https_server.ServeFilesFromSourceDirectory("content/test/data"); ASSERT_TRUE(https_server.Start()); - scoped_ptr<RenderViewSizeDelegate> delegate(new RenderViewSizeDelegate()); + std::unique_ptr<RenderViewSizeDelegate> delegate( + new RenderViewSizeDelegate()); shell()->web_contents()->SetDelegate(delegate.get()); ASSERT_TRUE(shell()->web_contents()->GetDelegate() == delegate.get()); @@ -468,7 +469,7 @@ IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, LoadingStateChangedForSameDocumentNavigation) { ASSERT_TRUE(embedded_test_server()->Start()); - scoped_ptr<LoadingStateChangedDelegate> delegate( + std::unique_ptr<LoadingStateChangedDelegate> delegate( new LoadingStateChangedDelegate()); shell()->web_contents()->SetDelegate(delegate.get()); @@ -547,7 +548,7 @@ IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, LoadProgress) { ASSERT_TRUE(embedded_test_server()->Start()); - scoped_ptr<LoadProgressDelegateAndObserver> delegate( + std::unique_ptr<LoadProgressDelegateAndObserver> delegate( new LoadProgressDelegateAndObserver(shell())); NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html")); @@ -569,7 +570,7 @@ IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, LoadProgressWithFrames) { ASSERT_TRUE(embedded_test_server()->Start()); - scoped_ptr<LoadProgressDelegateAndObserver> delegate( + std::unique_ptr<LoadProgressDelegateAndObserver> delegate( new LoadProgressDelegateAndObserver(shell())); NavigateToURL(shell(), @@ -604,7 +605,7 @@ const GURL kURL2 = embedded_test_server()->GetURL("/title2.html"); NavigationStallDelegate stall_delegate(kURL2); ResourceDispatcherHost::Get()->SetDelegate(&stall_delegate); - scoped_ptr<LoadProgressDelegateAndObserver> delegate( + std::unique_ptr<LoadProgressDelegateAndObserver> delegate( new LoadProgressDelegateAndObserver(shell())); shell()->LoadURL(kURL2); EXPECT_TRUE(delegate->did_start_loading); @@ -664,7 +665,7 @@ IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, MAYBE_FirstVisuallyNonEmptyPaint) { ASSERT_TRUE(embedded_test_server()->Start()); - scoped_ptr<FirstVisuallyNonEmptyPaintObserver> observer( + std::unique_ptr<FirstVisuallyNonEmptyPaintObserver> observer( new FirstVisuallyNonEmptyPaintObserver(shell())); NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html"));
diff --git a/content/browser/web_contents/web_contents_impl_unittest.cc b/content/browser/web_contents/web_contents_impl_unittest.cc index ef96953..78ac81f 100644 --- a/content/browser/web_contents/web_contents_impl_unittest.cc +++ b/content/browser/web_contents/web_contents_impl_unittest.cc
@@ -687,7 +687,7 @@ ui::PAGE_TRANSITION_TYPED); // Open a new contents with the same SiteInstance, navigated to the same site. - scoped_ptr<TestWebContents> contents2( + std::unique_ptr<TestWebContents> contents2( TestWebContents::Create(browser_context(), instance1)); contents2->GetController().LoadURL(url, Referrer(), ui::PAGE_TRANSITION_TYPED, @@ -848,8 +848,8 @@ // SiteInstance. browser_client.set_assign_site_for_url(false); const GURL native_url("non-site-url://stuffandthings"); - std::vector<scoped_ptr<NavigationEntry>> entries; - scoped_ptr<NavigationEntry> new_entry = + std::vector<std::unique_ptr<NavigationEntry>> entries; + std::unique_ptr<NavigationEntry> new_entry = NavigationControllerImpl::CreateNavigationEntry( native_url, Referrer(), ui::PAGE_TRANSITION_LINK, false, std::string(), browser_context()); @@ -898,8 +898,8 @@ // ShouldAssignSiteForUrl override is disabled (i.e. returns true). browser_client.set_assign_site_for_url(true); const GURL regular_url("http://www.yahoo.com"); - std::vector<scoped_ptr<NavigationEntry>> entries; - scoped_ptr<NavigationEntry> new_entry = + std::vector<std::unique_ptr<NavigationEntry>> entries; + std::unique_ptr<NavigationEntry> new_entry = NavigationControllerImpl::CreateNavigationEntry( regular_url, Referrer(), ui::PAGE_TRANSITION_LINK, false, std::string(), browser_context()); @@ -960,7 +960,7 @@ // While it is still pending, simulate opening a new tab with the first tab // as its opener. This will call CreateOpenerProxies on the opener to ensure // that an RVH exists. - scoped_ptr<TestWebContents> popup( + std::unique_ptr<TestWebContents> popup( TestWebContents::Create(browser_context(), instance)); popup->SetOpener(contents()); contents()->GetRenderManager()->CreateOpenerProxies(instance, nullptr); @@ -999,7 +999,7 @@ ui::PAGE_TRANSITION_TYPED); // Open a related contents to a second site. - scoped_ptr<TestWebContents> contents2( + std::unique_ptr<TestWebContents> contents2( TestWebContents::Create(browser_context(), instance1)); const GURL url2("http://www.yahoo.com"); contents2->GetController().LoadURL(url2, Referrer(), @@ -2544,7 +2544,7 @@ // Create another NavigationController. GURL url3("http://foo2"); - scoped_ptr<TestWebContents> other_contents( + std::unique_ptr<TestWebContents> other_contents( static_cast<TestWebContents*>(CreateTestWebContents())); NavigationControllerImpl& other_controller = other_contents->GetController(); other_contents->NavigateAndCommit(url3); @@ -2569,7 +2569,7 @@ contents()->NavigateAndCommit(url1); // Create another NavigationController. - scoped_ptr<TestWebContents> other_contents( + std::unique_ptr<TestWebContents> other_contents( static_cast<TestWebContents*>(CreateTestWebContents())); NavigationControllerImpl& other_controller = other_contents->GetController(); @@ -2619,7 +2619,7 @@ EXPECT_EQ(url_normalized, observer.last_url()); // Create and navigate another WebContents. - scoped_ptr<TestWebContents> other_contents( + std::unique_ptr<TestWebContents> other_contents( static_cast<TestWebContents*>(CreateTestWebContents())); TestWebContentsObserver other_observer(other_contents.get()); other_contents->NavigateAndCommit(url_normalized); @@ -2633,7 +2633,7 @@ // Test that if a pending contents is deleted before it is shown, we don't // crash. TEST_F(WebContentsImplTest, PendingContents) { - scoped_ptr<TestWebContents> other_contents( + std::unique_ptr<TestWebContents> other_contents( static_cast<TestWebContents*>(CreateTestWebContents())); contents()->AddPendingContents(other_contents.get()); int route_id = other_contents->GetRenderViewHost()->GetRoutingID(); @@ -2793,7 +2793,7 @@ TEST_F(WebContentsImplTest, HandleWheelEvent) { using blink::WebInputEvent; - scoped_ptr<ContentsZoomChangedDelegate> delegate( + std::unique_ptr<ContentsZoomChangedDelegate> delegate( new ContentsZoomChangedDelegate()); contents()->SetDelegate(delegate.get()); @@ -2873,12 +2873,12 @@ EXPECT_EQ(0u, instance1->GetRelatedActiveContentsCount()); EXPECT_EQ(0u, instance2->GetRelatedActiveContentsCount()); - scoped_ptr<TestWebContents> contents1( + std::unique_ptr<TestWebContents> contents1( TestWebContents::Create(browser_context(), instance1.get())); EXPECT_EQ(1u, instance1->GetRelatedActiveContentsCount()); EXPECT_EQ(1u, instance2->GetRelatedActiveContentsCount()); - scoped_ptr<TestWebContents> contents2( + std::unique_ptr<TestWebContents> contents2( TestWebContents::Create(browser_context(), instance1.get())); EXPECT_EQ(2u, instance1->GetRelatedActiveContentsCount()); EXPECT_EQ(2u, instance2->GetRelatedActiveContentsCount()); @@ -2900,7 +2900,7 @@ EXPECT_EQ(0u, instance->GetRelatedActiveContentsCount()); - scoped_ptr<TestWebContents> contents( + std::unique_ptr<TestWebContents> contents( TestWebContents::Create(browser_context(), instance.get())); EXPECT_EQ(1u, instance->GetRelatedActiveContentsCount()); @@ -2948,7 +2948,7 @@ EXPECT_EQ(0u, instance->GetRelatedActiveContentsCount()); - scoped_ptr<TestWebContents> contents( + std::unique_ptr<TestWebContents> contents( TestWebContents::Create(browser_context(), instance.get())); EXPECT_EQ(1u, instance->GetRelatedActiveContentsCount());
diff --git a/content/browser/web_contents/web_contents_user_data_unittest.cc b/content/browser/web_contents/web_contents_user_data_unittest.cc index eeb2acb..c7e908a 100644 --- a/content/browser/web_contents/web_contents_user_data_unittest.cc +++ b/content/browser/web_contents/web_contents_user_data_unittest.cc
@@ -4,7 +4,8 @@ #include "content/public/browser/web_contents_user_data.h" -#include "base/memory/scoped_ptr.h" +#include <memory> + #include "content/public/browser/web_contents.h" #include "content/public/test/test_renderer_host.h" #include "content/public/test/web_contents_tester.h" @@ -64,7 +65,7 @@ TEST_F(WebContentsUserDataTest, TwoInstancesOneAttachment) { WebContents* contents1 = web_contents(); - scoped_ptr<WebContents> contents2( + std::unique_ptr<WebContents> contents2( WebContentsTester::CreateTestWebContents(browser_context(), NULL)); WebContentsAttachedClass1* one_class =
diff --git a/content/browser/web_contents/web_contents_view_android.h b/content/browser/web_contents/web_contents_view_android.h index 6b135dc2..925f5bb 100644 --- a/content/browser/web_contents/web_contents_view_android.h +++ b/content/browser/web_contents/web_contents_view_android.h
@@ -5,8 +5,9 @@ #ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_ANDROID_H_ #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_ANDROID_H_ +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/renderer_host/render_view_host_delegate_view.h" #include "content/browser/web_contents/web_contents_view.h" #include "content/public/browser/web_contents_view_delegate.h" @@ -83,7 +84,7 @@ ContentViewCoreImpl* content_view_core_; // Interface for extensions to WebContentsView. Used to show the context menu. - scoped_ptr<WebContentsViewDelegate> delegate_; + std::unique_ptr<WebContentsViewDelegate> delegate_; DISALLOW_COPY_AND_ASSIGN(WebContentsViewAndroid); };
diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc index 7053c50b..c11eefb0 100644 --- a/content/browser/web_contents/web_contents_view_aura.cc +++ b/content/browser/web_contents/web_contents_view_aura.cc
@@ -830,7 +830,7 @@ if (!image.isNull()) drag_utils::SetDragImageOnDataObject(image, image_offset, &data); - scoped_ptr<WebDragSourceAura> drag_source( + std::unique_ptr<WebDragSourceAura> drag_source( new WebDragSourceAura(GetNativeView(), web_contents_)); // We need to enable recursive tasks on the message loop so we can get
diff --git a/content/browser/web_contents/web_contents_view_aura.h b/content/browser/web_contents/web_contents_view_aura.h index 2c4b41d..1395f61a 100644 --- a/content/browser/web_contents/web_contents_view_aura.h +++ b/content/browser/web_contents/web_contents_view_aura.h
@@ -5,12 +5,12 @@ #ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_AURA_H_ #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_AURA_H_ +#include <memory> #include <vector> #include "base/gtest_prod_util.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/renderer_host/overscroll_controller_delegate.h" #include "content/browser/renderer_host/render_view_host_delegate_view.h" #include "content/browser/web_contents/web_contents_view.h" @@ -162,18 +162,18 @@ FRIEND_TEST_ALL_PREFIXES(WebContentsViewAuraTest, EnableDisableOverscroll); - scoped_ptr<aura::Window> window_; + std::unique_ptr<aura::Window> window_; - scoped_ptr<WindowObserver> window_observer_; + std::unique_ptr<WindowObserver> window_observer_; // The WebContentsImpl whose contents we display. WebContentsImpl* web_contents_; - scoped_ptr<WebContentsViewDelegate> delegate_; + std::unique_ptr<WebContentsViewDelegate> delegate_; blink::WebDragOperationsMask current_drag_op_; - scoped_ptr<DropData> current_drop_data_; + std::unique_ptr<DropData> current_drop_data_; WebDragDestDelegate* drag_dest_delegate_; @@ -192,9 +192,9 @@ // This manages the overlay window that shows the screenshot during a history // navigation triggered by the overscroll gesture. - scoped_ptr<OverscrollNavigationOverlay> navigation_overlay_; + std::unique_ptr<OverscrollNavigationOverlay> navigation_overlay_; - scoped_ptr<GestureNavSimple> gesture_nav_simple_; + std::unique_ptr<GestureNavSimple> gesture_nav_simple_; DISALLOW_COPY_AND_ASSIGN(WebContentsViewAura); };
diff --git a/content/browser/web_contents/web_contents_view_aura_browsertest.cc b/content/browser/web_contents/web_contents_view_aura_browsertest.cc index b896035..9dbab457 100644 --- a/content/browser/web_contents/web_contents_view_aura_browsertest.cc +++ b/content/browser/web_contents/web_contents_view_aura_browsertest.cc
@@ -9,6 +9,7 @@ #include "base/command_line.h" #include "base/location.h" #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/strings/utf_string_conversions.h" @@ -248,7 +249,7 @@ // Executes the javascript synchronously and makes sure the returned value is // freed properly. void ExecuteSyncJSFunction(RenderFrameHost* rfh, const std::string& jscript) { - scoped_ptr<base::Value> value = + std::unique_ptr<base::Value> value = content::ExecuteScriptAndGetValue(rfh, jscript); } @@ -269,7 +270,7 @@ NavigationControllerImpl* controller = &web_contents->GetController(); screenshot_manager_ = new ScreenshotTracker(controller); - controller->SetScreenshotManager(make_scoped_ptr(screenshot_manager_)); + controller->SetScreenshotManager(base::WrapUnique(screenshot_manager_)); frame_watcher_ = new FrameWatcher(); frame_watcher_->AttachTo(shell()->web_contents()); @@ -290,7 +291,7 @@ EXPECT_FALSE(controller.CanGoBack()); EXPECT_FALSE(controller.CanGoForward()); int index = -1; - scoped_ptr<base::Value> value = + std::unique_ptr<base::Value> value = content::ExecuteScriptAndGetValue(main_frame, "get_current()"); ASSERT_TRUE(value->GetAsInteger(&index)); EXPECT_EQ(0, index); @@ -372,7 +373,7 @@ static_cast<WebContentsImpl*>(shell()->web_contents()); RenderFrameHost* main_frame = web_contents->GetMainFrame(); int index = -1; - scoped_ptr<base::Value> value; + std::unique_ptr<base::Value> value; value = content::ExecuteScriptAndGetValue(main_frame, "get_current()"); if (!value->GetAsInteger(&index)) index = -1; @@ -765,7 +766,7 @@ DISABLED_ContentWindowReparent) { ASSERT_NO_FATAL_FAILURE(StartTestWithPage("/overscroll_navigation.html")); - scoped_ptr<aura::Window> window(new aura::Window(NULL)); + std::unique_ptr<aura::Window> window(new aura::Window(NULL)); window->Init(ui::LAYER_NOT_DRAWN); WebContentsImpl* web_contents = @@ -888,7 +889,7 @@ IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest, WebContentsViewReparent) { ASSERT_NO_FATAL_FAILURE(StartTestWithPage("/overscroll_navigation.html")); - scoped_ptr<aura::Window> window(new aura::Window(NULL)); + std::unique_ptr<aura::Window> window(new aura::Window(NULL)); window->Init(ui::LAYER_NOT_DRAWN); RenderWidgetHostViewAura* rwhva =
diff --git a/content/browser/web_contents/web_contents_view_guest.cc b/content/browser/web_contents/web_contents_view_guest.cc index 5f6b51821..f6d6cf41 100644 --- a/content/browser/web_contents/web_contents_view_guest.cc +++ b/content/browser/web_contents/web_contents_view_guest.cc
@@ -36,7 +36,7 @@ WebContentsViewGuest::WebContentsViewGuest( WebContentsImpl* web_contents, BrowserPluginGuest* guest, - scoped_ptr<WebContentsView> platform_view, + std::unique_ptr<WebContentsView> platform_view, RenderViewHostDelegateView** delegate_view) : web_contents_(web_contents), guest_(guest),
diff --git a/content/browser/web_contents/web_contents_view_guest.h b/content/browser/web_contents/web_contents_view_guest.h index 7f2df7f9..e814410 100644 --- a/content/browser/web_contents/web_contents_view_guest.h +++ b/content/browser/web_contents/web_contents_view_guest.h
@@ -5,10 +5,10 @@ #ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_GUEST_H_ #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_GUEST_H_ +#include <memory> #include <vector> #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "build/build_config.h" #include "content/browser/renderer_host/render_view_host_delegate_view.h" #include "content/browser/web_contents/web_contents_view.h" @@ -31,7 +31,7 @@ // |platform_view|. WebContentsViewGuest(WebContentsImpl* web_contents, BrowserPluginGuest* guest, - scoped_ptr<WebContentsView> platform_view, + std::unique_ptr<WebContentsView> platform_view, RenderViewHostDelegateView** delegate_view); ~WebContentsViewGuest() override; @@ -89,7 +89,7 @@ BrowserPluginGuest* guest_; // The platform dependent view backing this WebContentsView. // Calls to this WebContentsViewGuest are forwarded to |platform_view_|. - scoped_ptr<WebContentsView> platform_view_; + std::unique_ptr<WebContentsView> platform_view_; gfx::Size size_; // Delegate view for guest's platform view.
diff --git a/content/browser/web_contents/web_contents_view_mac.h b/content/browser/web_contents/web_contents_view_mac.h index bcd6a26c..b4e597b 100644 --- a/content/browser/web_contents/web_contents_view_mac.h +++ b/content/browser/web_contents/web_contents_view_mac.h
@@ -7,12 +7,12 @@ #import <Cocoa/Cocoa.h> +#include <memory> #include <string> #include <vector> #include "base/mac/scoped_nsobject.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/renderer_host/render_view_host_delegate_view.h" #include "content/browser/web_contents/web_contents_view.h" #include "content/common/content_export.h" @@ -144,12 +144,12 @@ base::scoped_nsobject<FocusTracker> focus_tracker_; // Our optional delegate. - scoped_ptr<WebContentsViewDelegate> delegate_; + std::unique_ptr<WebContentsViewDelegate> delegate_; // Whether to allow other views. bool allow_other_views_; - scoped_ptr<PopupMenuHelper> popup_menu_helper_; + std::unique_ptr<PopupMenuHelper> popup_menu_helper_; DISALLOW_COPY_AND_ASSIGN(WebContentsViewMac); };
diff --git a/content/browser/web_contents/web_contents_view_mus.h b/content/browser/web_contents/web_contents_view_mus.h index 05d51d1a..fab1165 100644 --- a/content/browser/web_contents/web_contents_view_mus.h +++ b/content/browser/web_contents/web_contents_view_mus.h
@@ -5,10 +5,10 @@ #ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_MUS_H_ #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_MUS_H_ +#include <memory> #include <vector> #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "build/build_config.h" #include "components/mus/public/cpp/scoped_window_ptr.h" #include "components/mus/public/cpp/window.h" @@ -107,9 +107,9 @@ // The WebContentsImpl whose contents we display. WebContentsImpl* web_contents_; - scoped_ptr<WebContentsViewDelegate> delegate_; - scoped_ptr<aura::Window> aura_window_; - scoped_ptr<mus::ScopedWindowPtr> mus_window_; + std::unique_ptr<WebContentsViewDelegate> delegate_; + std::unique_ptr<aura::Window> aura_window_; + std::unique_ptr<mus::ScopedWindowPtr> mus_window_; DISALLOW_COPY_AND_ASSIGN(WebContentsViewMus); };
diff --git a/content/browser/web_contents/web_contents_view_overscroll_animator_slider_mac.h b/content/browser/web_contents/web_contents_view_overscroll_animator_slider_mac.h index 2cc87ec..326c868 100644 --- a/content/browser/web_contents/web_contents_view_overscroll_animator_slider_mac.h +++ b/content/browser/web_contents/web_contents_view_overscroll_animator_slider_mac.h
@@ -7,8 +7,9 @@ #import <Cocoa/Cocoa.h> +#include <memory> + #include "base/mac/scoped_nsobject.h" -#include "base/memory/scoped_ptr.h" #include "content/browser/web_contents/web_contents_view_overscroll_animator_mac.h" namespace overscroll_animator { @@ -52,7 +53,7 @@ // An observer that reports the first non-empty paint of a WebContents. This // is used when completing an overscroll animation. - scoped_ptr<overscroll_animator::WebContentsPaintObserver> observer_; + std::unique_ptr<overscroll_animator::WebContentsPaintObserver> observer_; } @end
diff --git a/content/browser/web_contents/web_drag_dest_mac.h b/content/browser/web_contents/web_drag_dest_mac.h index 63a9efa..2598ee0 100644 --- a/content/browser/web_contents/web_drag_dest_mac.h +++ b/content/browser/web_contents/web_drag_dest_mac.h
@@ -4,7 +4,8 @@ #import <Cocoa/Cocoa.h> -#include "base/memory/scoped_ptr.h" +#include <memory> + #include "base/strings/string16.h" #include "content/common/content_export.h" #include "content/public/common/drop_data.h" @@ -39,7 +40,7 @@ RenderViewHostIdentifier currentRVH_; // The data for the current drag, or NULL if none is in progress. - scoped_ptr<content::DropData> dropData_; + std::unique_ptr<content::DropData> dropData_; // True if the drag has been canceled. bool canceled_;
diff --git a/content/browser/web_contents/web_drag_dest_mac.mm b/content/browser/web_contents/web_drag_dest_mac.mm index 452bfc8..ec3b0003 100644 --- a/content/browser/web_contents/web_drag_dest_mac.mm +++ b/content/browser/web_contents/web_drag_dest_mac.mm
@@ -126,7 +126,7 @@ currentRVH_ = webContents_->GetRenderViewHost(); // Fill out a DropData from pasteboard. - scoped_ptr<DropData> dropData; + std::unique_ptr<DropData> dropData; dropData.reset(new DropData()); [self populateDropData:dropData.get() fromPasteboard:[info draggingPasteboard]];
diff --git a/content/browser/web_contents/web_drag_source_mac.h b/content/browser/web_contents/web_drag_source_mac.h index 49dad89cc..97590f8 100644 --- a/content/browser/web_contents/web_drag_source_mac.h +++ b/content/browser/web_contents/web_drag_source_mac.h
@@ -4,10 +4,11 @@ #import <Cocoa/Cocoa.h> +#include <memory> + #include "base/files/file_path.h" #include "base/mac/scoped_cftyperef.h" #include "base/mac/scoped_nsobject.h" -#include "base/memory/scoped_ptr.h" #include "content/common/content_export.h" #include "url/gurl.h" @@ -32,7 +33,7 @@ NSView* contentsView_; // Our drop data. Should only be initialized once. - scoped_ptr<content::DropData> dropData_; + std::unique_ptr<content::DropData> dropData_; // The image to show as drag image. Can be nil. base::scoped_nsobject<NSImage> dragImage_;
diff --git a/content/browser/web_contents/web_drag_source_mac_unittest.mm b/content/browser/web_contents/web_drag_source_mac_unittest.mm index edc1888..6f46e4f 100644 --- a/content/browser/web_contents/web_drag_source_mac_unittest.mm +++ b/content/browser/web_contents/web_drag_source_mac_unittest.mm
@@ -17,11 +17,11 @@ typedef RenderViewHostTestHarness WebDragSourceMacTest; TEST_F(WebDragSourceMacTest, DragInvalidlyEscapedBookmarklet) { - scoped_ptr<WebContents> contents(CreateTestWebContents()); + std::unique_ptr<WebContents> contents(CreateTestWebContents()); base::scoped_nsobject<NSView> view( [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 10, 10)]); - scoped_ptr<DropData> dropData(new DropData); + std::unique_ptr<DropData> dropData(new DropData); dropData->url = GURL("javascript:%"); WebContentsImpl* contentsImpl = static_cast<WebContentsImpl*>(contents.get());
diff --git a/content/browser/webui/url_data_manager_backend.cc b/content/browser/webui/url_data_manager_backend.cc index 7dfd7575..0e5ee0c4 100644 --- a/content/browser/webui/url_data_manager_backend.cc +++ b/content/browser/webui/url_data_manager_backend.cc
@@ -13,6 +13,7 @@ #include "base/lazy_instance.h" #include "base/location.h" #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/memory/ref_counted.h" #include "base/memory/ref_counted_memory.h" #include "base/memory/weak_ptr.h" @@ -45,7 +46,6 @@ #include "net/url_request/url_request_error_job.h" #include "net/url_request/url_request_job.h" #include "net/url_request/url_request_job_factory.h" - #include "url/url_util.h" namespace content { @@ -458,7 +458,7 @@ namespace { bool IsValidNetworkErrorCode(int error_code) { - scoped_ptr<base::DictionaryValue> error_codes = net::GetNetConstants(); + std::unique_ptr<base::DictionaryValue> error_codes = net::GetNetConstants(); const base::DictionaryValue* net_error_codes_dict = nullptr; for (base::DictionaryValue::Iterator itr(*error_codes); !itr.IsAtEnd(); @@ -573,13 +573,13 @@ } // static -scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> +std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler> URLDataManagerBackend::CreateProtocolHandler( content::ResourceContext* resource_context, bool is_incognito, ChromeBlobStorageContext* blob_storage_context) { DCHECK(resource_context); - return make_scoped_ptr(new ChromeProtocolHandler( + return base::WrapUnique(new ChromeProtocolHandler( resource_context, is_incognito, blob_storage_context)); }
diff --git a/content/browser/webui/url_data_manager_backend.h b/content/browser/webui/url_data_manager_backend.h index 0e312aa..fc8d702a 100644 --- a/content/browser/webui/url_data_manager_backend.h +++ b/content/browser/webui/url_data_manager_backend.h
@@ -6,12 +6,12 @@ #define CONTENT_BROWSER_WEBUI_URL_DATA_MANAGER_BACKEND_H_ #include <map> +#include <memory> #include <string> #include <vector> #include "base/compiler_specific.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/supports_user_data.h" #include "content/browser/webui/url_data_manager.h" #include "content/public/browser/url_data_source.h" @@ -43,7 +43,8 @@ // Invoked to create the protocol handler for chrome://. |is_incognito| should // be set for incognito profiles. Called on the UI thread. - CONTENT_EXPORT static scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> + CONTENT_EXPORT static std::unique_ptr< + net::URLRequestJobFactory::ProtocolHandler> CreateProtocolHandler(content::ResourceContext* resource_context, bool is_incognito, ChromeBlobStorageContext* blob_storage_context);
diff --git a/content/browser/webui/url_data_manager_backend_unittest.cc b/content/browser/webui/url_data_manager_backend_unittest.cc index f8fefe5..f52c808 100644 --- a/content/browser/webui/url_data_manager_backend_unittest.cc +++ b/content/browser/webui/url_data_manager_backend_unittest.cc
@@ -2,10 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/macros.h" -#include "base/memory/scoped_ptr.h" -#include "base/run_loop.h" #include "content/browser/webui/url_data_manager_backend.h" + +#include <memory> + +#include "base/macros.h" +#include "base/run_loop.h" #include "content/public/test/mock_resource_context.h" #include "content/public/test/test_browser_thread_bundle.h" #include "net/http/http_response_headers.h" @@ -49,11 +51,14 @@ url_request_context_.set_job_factory(&url_request_job_factory_); } - scoped_ptr<net::URLRequest> CreateRequest(net::URLRequest::Delegate* delegate, - const char* origin) { - scoped_ptr<net::URLRequest> request = url_request_context_.CreateRequest( - GURL("chrome://resources/polymer/v1_0/polymer/polymer-extracted.js"), - net::HIGHEST, delegate); + std::unique_ptr<net::URLRequest> CreateRequest( + net::URLRequest::Delegate* delegate, + const char* origin) { + std::unique_ptr<net::URLRequest> request = + url_request_context_.CreateRequest( + GURL( + "chrome://resources/polymer/v1_0/polymer/polymer-extracted.js"), + net::HIGHEST, delegate); request->SetExtraRequestHeaderByName("Origin", origin, true); return request; } @@ -67,7 +72,7 @@ }; TEST_F(UrlDataManagerBackendTest, AccessControlAllowOriginChromeUrl) { - scoped_ptr<net::URLRequest> request( + std::unique_ptr<net::URLRequest> request( CreateRequest(&delegate_, "chrome://webui")); request->Start(); base::RunLoop().RunUntilIdle(); @@ -76,7 +81,7 @@ } TEST_F(UrlDataManagerBackendTest, AccessControlAllowOriginNonChromeUrl) { - scoped_ptr<net::URLRequest> request( + std::unique_ptr<net::URLRequest> request( CreateRequest(&delegate_, "http://www.example.com")); request->Start(); base::RunLoop().RunUntilIdle(); @@ -86,7 +91,7 @@ // Check that the URLRequest isn't passed headers after cancellation. TEST_F(UrlDataManagerBackendTest, CancelBeforeResponseStarts) { - scoped_ptr<net::URLRequest> request( + std::unique_ptr<net::URLRequest> request( CreateRequest(&delegate_, "chrome://webui")); request->Start(); request->Cancel(); @@ -98,7 +103,7 @@ // Check that the URLRequest isn't passed data after cancellation. TEST_F(UrlDataManagerBackendTest, CancelAfterFirstReadStarted) { CancelAfterFirstReadURLRequestDelegate cancel_delegate; - scoped_ptr<net::URLRequest> request( + std::unique_ptr<net::URLRequest> request( CreateRequest(&cancel_delegate, "chrome://webui")); request->Start(); base::RunLoop().RunUntilIdle(); @@ -110,9 +115,9 @@ // Check for a network error page request via chrome://network-error/. TEST_F(UrlDataManagerBackendTest, ChromeNetworkErrorPageRequest) { - scoped_ptr<net::URLRequest> error_request = - url_request_context_.CreateRequest( - GURL("chrome://network-error/-105"), net::HIGHEST, &delegate_); + std::unique_ptr<net::URLRequest> error_request = + url_request_context_.CreateRequest(GURL("chrome://network-error/-105"), + net::HIGHEST, &delegate_); error_request->Start(); base::RunLoop().Run(); EXPECT_EQ(net::URLRequestStatus::FAILED, error_request->status().status()); @@ -121,9 +126,9 @@ // Check for an invalid network error page request via chrome://network-error/. TEST_F(UrlDataManagerBackendTest, ChromeNetworkErrorPageRequestFailed) { - scoped_ptr<net::URLRequest> error_request = - url_request_context_.CreateRequest( - GURL("chrome://network-error/-123456789"), net::HIGHEST, &delegate_); + std::unique_ptr<net::URLRequest> error_request = + url_request_context_.CreateRequest( + GURL("chrome://network-error/-123456789"), net::HIGHEST, &delegate_); error_request->Start(); base::RunLoop().Run(); EXPECT_EQ(net::URLRequestStatus::FAILED, error_request->status().status());
diff --git a/content/browser/webui/url_data_source_impl.h b/content/browser/webui/url_data_source_impl.h index 723c1baf2..5776577 100644 --- a/content/browser/webui/url_data_source_impl.h +++ b/content/browser/webui/url_data_source_impl.h
@@ -5,8 +5,9 @@ #ifndef CONTENT_BROWSER_WEBUI_URL_DATA_SOURCE_IMPL_H_ #define CONTENT_BROWSER_WEBUI_URL_DATA_SOURCE_IMPL_H_ +#include <memory> + #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/sequenced_task_runner_helpers.h" #include "content/browser/webui/url_data_manager.h" #include "content/common/content_export.h" @@ -90,7 +91,7 @@ // source. URLDataManagerBackend* backend_; - scoped_ptr<URLDataSource> source_; + std::unique_ptr<URLDataSource> source_; }; } // namespace content
diff --git a/content/browser/webui/web_ui_impl.h b/content/browser/webui/web_ui_impl.h index 1c812a56..a372a40 100644 --- a/content/browser/webui/web_ui_impl.h +++ b/content/browser/webui/web_ui_impl.h
@@ -6,11 +6,11 @@ #define CONTENT_BROWSER_WEBUI_WEB_UI_IMPL_H_ #include <map> +#include <memory> #include <set> #include "base/compiler_specific.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_vector.h" #include "base/memory/weak_ptr.h" #include "content/public/browser/web_ui.h" @@ -117,7 +117,7 @@ // is used. const std::string frame_name_; - scoped_ptr<WebUIController> controller_; + std::unique_ptr<WebUIController> controller_; DISALLOW_COPY_AND_ASSIGN(WebUIImpl); };
diff --git a/content/browser/webui/web_ui_mojo_browsertest.cc b/content/browser/webui/web_ui_mojo_browsertest.cc index 920f8916..a9d0a90 100644 --- a/content/browser/webui/web_ui_mojo_browsertest.cc +++ b/content/browser/webui/web_ui_mojo_browsertest.cc
@@ -104,7 +104,7 @@ protected: base::RunLoop* run_loop_; - scoped_ptr<BrowserTargetImpl> browser_target_; + std::unique_ptr<BrowserTargetImpl> browser_target_; private: DISALLOW_COPY_AND_ASSIGN(TestWebUIController);
diff --git a/content/browser/zygote_host/zygote_communication_linux.cc b/content/browser/zygote_host/zygote_communication_linux.cc index 54f5176a..39f7b79 100644 --- a/content/browser/zygote_host/zygote_communication_linux.cc +++ b/content/browser/zygote_host/zygote_communication_linux.cc
@@ -106,9 +106,10 @@ return HANDLE_EINTR(read(control_fd_, buf, buf_len)); } -pid_t ZygoteCommunication::ForkRequest(const std::vector<std::string>& argv, - scoped_ptr<FileDescriptorInfo> mapping, - const std::string& process_type) { +pid_t ZygoteCommunication::ForkRequest( + const std::vector<std::string>& argv, + std::unique_ptr<FileDescriptorInfo> mapping, + const std::string& process_type) { DCHECK(init_); base::Pickle pickle; @@ -309,7 +310,7 @@ base::ScopedFD dummy_fd; if (using_suid_sandbox) { - scoped_ptr<sandbox::SetuidSandboxHost> sandbox_host( + std::unique_ptr<sandbox::SetuidSandboxHost> sandbox_host( sandbox::SetuidSandboxHost::Create()); sandbox_host->PrependWrapper(&cmd_line); sandbox_host->SetupLaunchOptions(&options, &fds_to_map, &dummy_fd);
diff --git a/content/browser/zygote_host/zygote_communication_linux.h b/content/browser/zygote_host/zygote_communication_linux.h index d3f4403..5bb80962 100644 --- a/content/browser/zygote_host/zygote_communication_linux.h +++ b/content/browser/zygote_host/zygote_communication_linux.h
@@ -5,10 +5,10 @@ #ifndef CONTENT_BROWSER_ZYGOTE_HOST_ZYGOTE_COMMUNICATION_LINUX_H_ #define CONTENT_BROWSER_ZYGOTE_HOST_ZYGOTE_COMMUNICATION_LINUX_H_ +#include <memory> #include <set> #include <vector> -#include "base/memory/scoped_ptr.h" #include "base/process/kill.h" #include "base/synchronization/lock.h" #include "content/common/content_export.h" @@ -26,7 +26,7 @@ // Tries to start a process of type indicated by process_type. // Returns its pid on success, otherwise base::kNullProcessHandle; pid_t ForkRequest(const std::vector<std::string>& command_line, - scoped_ptr<FileDescriptorInfo> mapping, + std::unique_ptr<FileDescriptorInfo> mapping, const std::string& process_type); void EnsureProcessTerminated(pid_t process);
diff --git a/content/common/android/address_parser_unittest.cc b/content/common/android/address_parser_unittest.cc index b15c1a6..c67fd49 100644 --- a/content/common/android/address_parser_unittest.cc +++ b/content/common/android/address_parser_unittest.cc
@@ -2,13 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/common/android/address_parser.h" + #include <stddef.h> +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" -#include "content/common/android/address_parser.h" #include "content/common/android/address_parser_internal.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/content/common/android/gin_java_bridge_value.cc b/content/common/android/gin_java_bridge_value.cc index 1574ab6..c06ac84 100644 --- a/content/common/android/gin_java_bridge_value.cc +++ b/content/common/android/gin_java_bridge_value.cc
@@ -4,6 +4,8 @@ #include "content/common/android/gin_java_bridge_value.h" +#include "base/memory/ptr_util.h" + namespace content { namespace { @@ -26,31 +28,31 @@ } // static -scoped_ptr<base::BinaryValue> GinJavaBridgeValue::CreateUndefinedValue() { +std::unique_ptr<base::BinaryValue> GinJavaBridgeValue::CreateUndefinedValue() { GinJavaBridgeValue gin_value(TYPE_UNDEFINED); - return make_scoped_ptr(gin_value.SerializeToBinaryValue()); + return base::WrapUnique(gin_value.SerializeToBinaryValue()); } // static -scoped_ptr<base::BinaryValue> GinJavaBridgeValue::CreateNonFiniteValue( +std::unique_ptr<base::BinaryValue> GinJavaBridgeValue::CreateNonFiniteValue( float in_value) { GinJavaBridgeValue gin_value(TYPE_NONFINITE); gin_value.pickle_.WriteFloat(in_value); - return make_scoped_ptr(gin_value.SerializeToBinaryValue()); + return base::WrapUnique(gin_value.SerializeToBinaryValue()); } // static -scoped_ptr<base::BinaryValue> GinJavaBridgeValue::CreateNonFiniteValue( +std::unique_ptr<base::BinaryValue> GinJavaBridgeValue::CreateNonFiniteValue( double in_value) { return CreateNonFiniteValue(static_cast<float>(in_value)); } // static -scoped_ptr<base::BinaryValue> GinJavaBridgeValue::CreateObjectIDValue( +std::unique_ptr<base::BinaryValue> GinJavaBridgeValue::CreateObjectIDValue( int32_t in_value) { GinJavaBridgeValue gin_value(TYPE_OBJECT_ID); gin_value.pickle_.WriteInt(in_value); - return make_scoped_ptr(gin_value.SerializeToBinaryValue()); + return base::WrapUnique(gin_value.SerializeToBinaryValue()); } // static @@ -71,9 +73,9 @@ } // static -scoped_ptr<const GinJavaBridgeValue> GinJavaBridgeValue::FromValue( +std::unique_ptr<const GinJavaBridgeValue> GinJavaBridgeValue::FromValue( const base::Value* value) { - return scoped_ptr<const GinJavaBridgeValue>( + return std::unique_ptr<const GinJavaBridgeValue>( value->IsType(base::Value::TYPE_BINARY) ? new GinJavaBridgeValue( reinterpret_cast<const base::BinaryValue*>(value))
diff --git a/content/common/android/gin_java_bridge_value.h b/content/common/android/gin_java_bridge_value.h index 11a06ca6a..b5090c3 100644 --- a/content/common/android/gin_java_bridge_value.h +++ b/content/common/android/gin_java_bridge_value.h
@@ -7,8 +7,9 @@ #include <stdint.h> +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/pickle.h" #include "base/values.h" #include "content/common/content_export.h" @@ -33,18 +34,19 @@ }; // Serialization - CONTENT_EXPORT static scoped_ptr<base::BinaryValue> CreateUndefinedValue(); - CONTENT_EXPORT static scoped_ptr<base::BinaryValue> CreateNonFiniteValue( + CONTENT_EXPORT static std::unique_ptr<base::BinaryValue> + CreateUndefinedValue(); + CONTENT_EXPORT static std::unique_ptr<base::BinaryValue> CreateNonFiniteValue( float in_value); - CONTENT_EXPORT static scoped_ptr<base::BinaryValue> CreateNonFiniteValue( + CONTENT_EXPORT static std::unique_ptr<base::BinaryValue> CreateNonFiniteValue( double in_value); - CONTENT_EXPORT static scoped_ptr<base::BinaryValue> CreateObjectIDValue( + CONTENT_EXPORT static std::unique_ptr<base::BinaryValue> CreateObjectIDValue( int32_t in_value); // De-serialization CONTENT_EXPORT static bool ContainsGinJavaBridgeValue( const base::Value* value); - CONTENT_EXPORT static scoped_ptr<const GinJavaBridgeValue> FromValue( + CONTENT_EXPORT static std::unique_ptr<const GinJavaBridgeValue> FromValue( const base::Value* value); CONTENT_EXPORT Type GetType() const;
diff --git a/content/common/android/gin_java_bridge_value_unittest.cc b/content/common/android/gin_java_bridge_value_unittest.cc index 1a64cd92..7f20294 100644 --- a/content/common/android/gin_java_bridge_value_unittest.cc +++ b/content/common/android/gin_java_bridge_value_unittest.cc
@@ -2,12 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/common/android/gin_java_bridge_value.h" + #include <stdint.h> #include <cmath> +#include <memory> -#include "base/memory/scoped_ptr.h" -#include "content/common/android/gin_java_bridge_value.h" #include "testing/gtest/include/gtest/gtest.h" namespace content { @@ -19,11 +20,11 @@ float native_float; int32_t native_object_id; - scoped_ptr<base::BinaryValue> undefined( + std::unique_ptr<base::BinaryValue> undefined( GinJavaBridgeValue::CreateUndefinedValue()); ASSERT_TRUE(undefined.get()); EXPECT_TRUE(GinJavaBridgeValue::ContainsGinJavaBridgeValue(undefined.get())); - scoped_ptr<const GinJavaBridgeValue> undefined_value( + std::unique_ptr<const GinJavaBridgeValue> undefined_value( GinJavaBridgeValue::FromValue(undefined.get())); ASSERT_TRUE(undefined_value.get()); EXPECT_TRUE(undefined_value->IsType(GinJavaBridgeValue::TYPE_UNDEFINED)); @@ -31,13 +32,13 @@ EXPECT_FALSE(undefined_value->GetAsNonFinite(&native_float)); EXPECT_FALSE(undefined_value->GetAsObjectID(&native_object_id)); - scoped_ptr<base::BinaryValue> float_infinity( + std::unique_ptr<base::BinaryValue> float_infinity( GinJavaBridgeValue::CreateNonFiniteValue( std::numeric_limits<float>::infinity())); ASSERT_TRUE(float_infinity.get()); EXPECT_TRUE( GinJavaBridgeValue::ContainsGinJavaBridgeValue(float_infinity.get())); - scoped_ptr<const GinJavaBridgeValue> float_infinity_value( + std::unique_ptr<const GinJavaBridgeValue> float_infinity_value( GinJavaBridgeValue::FromValue(float_infinity.get())); ASSERT_TRUE(float_infinity_value.get()); EXPECT_TRUE(float_infinity_value->IsType(GinJavaBridgeValue::TYPE_NONFINITE)); @@ -46,13 +47,13 @@ EXPECT_FALSE(undefined_value->GetAsObjectID(&native_object_id)); - scoped_ptr<base::BinaryValue> double_infinity( + std::unique_ptr<base::BinaryValue> double_infinity( GinJavaBridgeValue::CreateNonFiniteValue( std::numeric_limits<double>::infinity())); ASSERT_TRUE(double_infinity.get()); EXPECT_TRUE( GinJavaBridgeValue::ContainsGinJavaBridgeValue(double_infinity.get())); - scoped_ptr<const GinJavaBridgeValue> double_infinity_value( + std::unique_ptr<const GinJavaBridgeValue> double_infinity_value( GinJavaBridgeValue::FromValue(double_infinity.get())); ASSERT_TRUE(double_infinity_value.get()); EXPECT_TRUE( @@ -62,11 +63,11 @@ EXPECT_FALSE(undefined_value->GetAsObjectID(&native_object_id)); - scoped_ptr<base::BinaryValue> object_id( + std::unique_ptr<base::BinaryValue> object_id( GinJavaBridgeValue::CreateObjectIDValue(42)); ASSERT_TRUE(object_id.get()); EXPECT_TRUE(GinJavaBridgeValue::ContainsGinJavaBridgeValue(object_id.get())); - scoped_ptr<const GinJavaBridgeValue> object_id_value( + std::unique_ptr<const GinJavaBridgeValue> object_id_value( GinJavaBridgeValue::FromValue(object_id.get())); ASSERT_TRUE(object_id_value.get()); EXPECT_TRUE(object_id_value->IsType(GinJavaBridgeValue::TYPE_OBJECT_ID)); @@ -77,12 +78,12 @@ } TEST_F(GinJavaBridgeValueTest, BrokenValues) { - scoped_ptr<base::Value> non_binary(new base::FundamentalValue(42)); + std::unique_ptr<base::Value> non_binary(new base::FundamentalValue(42)); EXPECT_FALSE( GinJavaBridgeValue::ContainsGinJavaBridgeValue(non_binary.get())); const char dummy_data[] = "\000\001\002\003\004\005\006\007\010\011\012\013"; - scoped_ptr<base::BinaryValue> broken_binary( + std::unique_ptr<base::BinaryValue> broken_binary( base::BinaryValue::CreateWithCopiedBuffer(dummy_data, sizeof(dummy_data))); EXPECT_FALSE(
diff --git a/content/common/cc_messages.cc b/content/common/cc_messages.cc index f5c688eb..27e01e23 100644 --- a/content/common/cc_messages.cc +++ b/content/common/cc_messages.cc
@@ -672,10 +672,9 @@ quad_list_size > kMaxQuadListSize || shared_quad_state_list_size > kMaxSharedQuadStateListSize) return false; - scoped_ptr<cc::RenderPass> render_pass = - cc::RenderPass::Create( - static_cast<size_t>(shared_quad_state_list_size), - static_cast<size_t>(quad_list_size)); + std::unique_ptr<cc::RenderPass> render_pass = + cc::RenderPass::Create(static_cast<size_t>(shared_quad_state_list_size), + static_cast<size_t>(quad_list_size)); if (!ReadParam(m, iter, render_pass.get())) return false; // Validate that each RenderPassDrawQuad points at a valid RenderPass
diff --git a/content/common/cc_messages_perftest.cc b/content/common/cc_messages_perftest.cc index cec2a78..1741b25 100644 --- a/content/common/cc_messages_perftest.cc +++ b/content/common/cc_messages_perftest.cc
@@ -65,9 +65,9 @@ }; TEST_F(CCMessagesPerfTest, DelegatedFrame_ManyQuads_1_4000) { - scoped_ptr<CompositorFrame> frame(new CompositorFrame); + std::unique_ptr<CompositorFrame> frame(new CompositorFrame); - scoped_ptr<RenderPass> render_pass = RenderPass::Create(); + std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); render_pass->CreateAndAppendSharedQuadState(); for (int i = 0; i < 4000; ++i) { PictureDrawQuad* quad = @@ -83,9 +83,9 @@ } TEST_F(CCMessagesPerfTest, DelegatedFrame_ManyQuads_1_100000) { - scoped_ptr<CompositorFrame> frame(new CompositorFrame); + std::unique_ptr<CompositorFrame> frame(new CompositorFrame); - scoped_ptr<RenderPass> render_pass = RenderPass::Create(); + std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); render_pass->CreateAndAppendSharedQuadState(); for (int i = 0; i < 100000; ++i) { PictureDrawQuad* quad = @@ -101,9 +101,9 @@ } TEST_F(CCMessagesPerfTest, DelegatedFrame_ManyQuads_4000_4000) { - scoped_ptr<CompositorFrame> frame(new CompositorFrame); + std::unique_ptr<CompositorFrame> frame(new CompositorFrame); - scoped_ptr<RenderPass> render_pass = RenderPass::Create(); + std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); for (int i = 0; i < 4000; ++i) { render_pass->CreateAndAppendSharedQuadState(); PictureDrawQuad* quad = @@ -119,9 +119,9 @@ } TEST_F(CCMessagesPerfTest, DelegatedFrame_ManyQuads_100000_100000) { - scoped_ptr<CompositorFrame> frame(new CompositorFrame); + std::unique_ptr<CompositorFrame> frame(new CompositorFrame); - scoped_ptr<RenderPass> render_pass = RenderPass::Create(); + std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); for (int i = 0; i < 100000; ++i) { render_pass->CreateAndAppendSharedQuadState(); PictureDrawQuad* quad = @@ -138,11 +138,11 @@ TEST_F(CCMessagesPerfTest, DelegatedFrame_ManyRenderPasses_10000_100) { - scoped_ptr<CompositorFrame> frame(new CompositorFrame); + std::unique_ptr<CompositorFrame> frame(new CompositorFrame); frame->delegated_frame_data.reset(new DelegatedFrameData); for (int i = 0; i < 1000; ++i) { - scoped_ptr<RenderPass> render_pass = RenderPass::Create(); + std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); for (int j = 0; j < 100; ++j) { render_pass->CreateAndAppendSharedQuadState(); PictureDrawQuad* quad =
diff --git a/content/common/cc_messages_unittest.cc b/content/common/cc_messages_unittest.cc index 423bfff..c9c45d25 100644 --- a/content/common/cc_messages_unittest.cc +++ b/content/common/cc_messages_unittest.cc
@@ -291,15 +291,15 @@ arbitrary_filters2.Append(FilterOperation::CreateBrightnessFilter( arbitrary_float2)); - scoped_ptr<RenderPass> child_pass_in = RenderPass::Create(); + std::unique_ptr<RenderPass> child_pass_in = RenderPass::Create(); child_pass_in->SetAll(child_id, arbitrary_rect2, arbitrary_rect3, arbitrary_matrix2, arbitrary_bool2); - scoped_ptr<RenderPass> child_pass_cmp = RenderPass::Create(); + std::unique_ptr<RenderPass> child_pass_cmp = RenderPass::Create(); child_pass_cmp->SetAll(child_id, arbitrary_rect2, arbitrary_rect3, arbitrary_matrix2, arbitrary_bool2); - scoped_ptr<RenderPass> pass_in = RenderPass::Create(); + std::unique_ptr<RenderPass> pass_in = RenderPass::Create(); pass_in->SetAll(root_id, arbitrary_rect1, arbitrary_rect2, arbitrary_matrix1, arbitrary_bool1); @@ -308,7 +308,7 @@ arbitrary_rect2, arbitrary_bool1, arbitrary_float1, arbitrary_blend_mode1, arbitrary_context_id1); - scoped_ptr<RenderPass> pass_cmp = RenderPass::Create(); + std::unique_ptr<RenderPass> pass_cmp = RenderPass::Create(); pass_cmp->SetAll(root_id, arbitrary_rect1, arbitrary_rect2, arbitrary_matrix1, arbitrary_bool1); @@ -479,12 +479,13 @@ &iter, &frame_out)); // Make sure the out and cmp RenderPasses match. - scoped_ptr<RenderPass> child_pass_out = + std::unique_ptr<RenderPass> child_pass_out = std::move(frame_out.render_pass_list[0]); Compare(child_pass_cmp.get(), child_pass_out.get()); ASSERT_EQ(0u, child_pass_out->shared_quad_state_list.size()); ASSERT_EQ(0u, child_pass_out->quad_list.size()); - scoped_ptr<RenderPass> pass_out = std::move(frame_out.render_pass_list[1]); + std::unique_ptr<RenderPass> pass_out = + std::move(frame_out.render_pass_list[1]); Compare(pass_cmp.get(), pass_out.get()); ASSERT_EQ(3u, pass_out->shared_quad_state_list.size()); ASSERT_EQ(9u, pass_out->quad_list.size()); @@ -513,7 +514,7 @@ } TEST_F(CCMessagesTest, UnusedSharedQuadStates) { - scoped_ptr<RenderPass> pass_in = RenderPass::Create(); + std::unique_ptr<RenderPass> pass_in = RenderPass::Create(); pass_in->SetAll(RenderPassId(1, 1), gfx::Rect(100, 100), gfx::Rect(), @@ -599,7 +600,8 @@ EXPECT_TRUE( IPC::ParamTraits<DelegatedFrameData>::Read(&msg, &iter, &frame_out)); - scoped_ptr<RenderPass> pass_out = std::move(frame_out.render_pass_list[0]); + std::unique_ptr<RenderPass> pass_out = + std::move(frame_out.render_pass_list[0]); // 2 SharedQuadStates come out. The first and fourth SharedQuadStates were // used by quads, and so serialized. Others were not. @@ -656,7 +658,7 @@ arbitrary_resource2.mailbox_holder.sync_token = arbitrary_token2; arbitrary_resource2.is_overlay_candidate = false; - scoped_ptr<RenderPass> renderpass_in = RenderPass::Create(); + std::unique_ptr<RenderPass> renderpass_in = RenderPass::Create(); renderpass_in->SetNew( RenderPassId(1, 1), gfx::Rect(), gfx::Rect(), gfx::Transform());
diff --git a/content/common/child_process_host_impl.h b/content/common/child_process_host_impl.h index 6fae2f4d..18875c94 100644 --- a/content/common/child_process_host_impl.h +++ b/content/common/child_process_host_impl.h
@@ -8,17 +8,16 @@ #include <stddef.h> #include <stdint.h> +#include <memory> #include <string> #include <vector> -#include "build/build_config.h" - #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/shared_memory.h" #include "base/memory/singleton.h" #include "base/process/process.h" #include "base/strings/string16.h" +#include "build/build_config.h" #include "content/public/common/child_process_host.h" #include "ipc/ipc_listener.h" #include "ui/gfx/gpu_memory_buffer.h" @@ -113,7 +112,7 @@ ChildProcessHostDelegate* delegate_; base::Process peer_process_; bool opening_channel_; // True while we're waiting the channel to be opened. - scoped_ptr<IPC::Channel> channel_; + std::unique_ptr<IPC::Channel> channel_; std::string channel_id_; // Holds all the IPC message filters. Since this object lives on the IO
diff --git a/content/common/child_process_sandbox_support_impl_linux.cc b/content/common/child_process_sandbox_support_impl_linux.cc index b7b683e..928344a 100644 --- a/content/common/child_process_sandbox_support_impl_linux.cc +++ b/content/common/child_process_sandbox_support_impl_linux.cc
@@ -8,8 +8,8 @@ #include <sys/stat.h> #include <limits> +#include <memory> -#include "base/memory/scoped_ptr.h" #include "base/numerics/safe_conversions.h" #include "base/pickle.h" #include "base/posix/eintr_wrapper.h" @@ -158,7 +158,7 @@ // Read the table directory. static const size_t kTableEntrySize = 16; const size_t directory_size = num_tables * kTableEntrySize; - scoped_ptr<uint8_t[]> table_entries(new uint8_t[directory_size]); + std::unique_ptr<uint8_t[]> table_entries(new uint8_t[directory_size]); n = HANDLE_EINTR(pread(fd, table_entries.get(), directory_size, 12 /* skip the SFNT header */)); if (n != base::checked_cast<ssize_t>(directory_size))
diff --git a/content/common/common_param_traits_unittest.cc b/content/common/common_param_traits_unittest.cc index 546834b..7ddf001 100644 --- a/content/common/common_param_traits_unittest.cc +++ b/content/common/common_param_traits_unittest.cc
@@ -2,14 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/public/common/common_param_traits.h" + #include <stddef.h> #include <string.h> + +#include <memory> #include <utility> #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/values.h" -#include "content/public/common/common_param_traits.h" #include "content/public/common/content_constants.h" #include "ipc/ipc_message.h" #include "ipc/ipc_message_utils.h" @@ -69,7 +71,7 @@ bad_msg.WriteData(fixed_data, fixed_data_size); // Add some bogus pixel data. const size_t bogus_pixels_size = bitmap.getSize() * 2; - scoped_ptr<char[]> bogus_pixels(new char[bogus_pixels_size]); + std::unique_ptr<char[]> bogus_pixels(new char[bogus_pixels_size]); memset(bogus_pixels.get(), 'B', bogus_pixels_size); bad_msg.WriteData(bogus_pixels.get(), bogus_pixels_size); // Make sure we don't read out the bitmap! @@ -106,11 +108,11 @@ input.Set("bool", new base::FundamentalValue(true)); input.Set("int", new base::FundamentalValue(42)); - scoped_ptr<base::DictionaryValue> subdict(new base::DictionaryValue()); + std::unique_ptr<base::DictionaryValue> subdict(new base::DictionaryValue()); subdict->Set("str", new base::StringValue("forty two")); subdict->Set("bool", new base::FundamentalValue(false)); - scoped_ptr<base::ListValue> sublist(new base::ListValue()); + std::unique_ptr<base::ListValue> sublist(new base::ListValue()); sublist->Set(0, new base::FundamentalValue(42.42)); sublist->Set(1, new base::StringValue("forty")); sublist->Set(2, new base::StringValue("two"));
diff --git a/content/common/discardable_shared_memory_heap.cc b/content/common/discardable_shared_memory_heap.cc index 3e39216c..b6559af 100644 --- a/content/common/discardable_shared_memory_heap.cc +++ b/content/common/discardable_shared_memory_heap.cc
@@ -10,6 +10,7 @@ #include "base/format_macros.h" #include "base/macros.h" #include "base/memory/discardable_shared_memory.h" +#include "base/memory/ptr_util.h" #include "base/strings/stringprintf.h" #include "base/trace_event/memory_dump_manager.h" @@ -40,7 +41,7 @@ DiscardableSharedMemoryHeap::ScopedMemorySegment::ScopedMemorySegment( DiscardableSharedMemoryHeap* heap, - scoped_ptr<base::DiscardableSharedMemory> shared_memory, + std::unique_ptr<base::DiscardableSharedMemory> shared_memory, size_t size, int32_t id, const base::Closure& deleted_callback) @@ -108,8 +109,9 @@ 0); } -scoped_ptr<DiscardableSharedMemoryHeap::Span> DiscardableSharedMemoryHeap::Grow( - scoped_ptr<base::DiscardableSharedMemory> shared_memory, +std::unique_ptr<DiscardableSharedMemoryHeap::Span> +DiscardableSharedMemoryHeap::Grow( + std::unique_ptr<base::DiscardableSharedMemory> shared_memory, size_t size, int32_t id, const base::Closure& deleted_callback) { @@ -119,7 +121,7 @@ 0u); DCHECK_EQ(size & (block_size_ - 1), 0u); - scoped_ptr<Span> span( + std::unique_ptr<Span> span( new Span(shared_memory.get(), reinterpret_cast<size_t>(shared_memory->memory()) / block_size_, size / block_size_)); @@ -136,7 +138,8 @@ return span; } -void DiscardableSharedMemoryHeap::MergeIntoFreeLists(scoped_ptr<Span> span) { +void DiscardableSharedMemoryHeap::MergeIntoFreeLists( + std::unique_ptr<Span> span) { DCHECK(span->shared_memory_); // First add length of |span| to |num_free_blocks_|. @@ -145,7 +148,7 @@ // Merge with previous span if possible. SpanMap::iterator prev_it = spans_.find(span->start_ - 1); if (prev_it != spans_.end() && IsInFreeList(prev_it->second)) { - scoped_ptr<Span> prev = RemoveFromFreeList(prev_it->second); + std::unique_ptr<Span> prev = RemoveFromFreeList(prev_it->second); DCHECK_EQ(prev->start_ + prev->length_, span->start_); UnregisterSpan(prev.get()); if (span->length_ > 1) @@ -158,7 +161,7 @@ // Merge with next span if possible. SpanMap::iterator next_it = spans_.find(span->start_ + span->length_); if (next_it != spans_.end() && IsInFreeList(next_it->second)) { - scoped_ptr<Span> next = RemoveFromFreeList(next_it->second); + std::unique_ptr<Span> next = RemoveFromFreeList(next_it->second); DCHECK_EQ(next->start_, span->start_ + span->length_); UnregisterSpan(next.get()); if (span->length_ > 1) @@ -170,12 +173,12 @@ InsertIntoFreeList(std::move(span)); } -scoped_ptr<DiscardableSharedMemoryHeap::Span> +std::unique_ptr<DiscardableSharedMemoryHeap::Span> DiscardableSharedMemoryHeap::Split(Span* span, size_t blocks) { DCHECK(blocks); DCHECK_LT(blocks, span->length_); - scoped_ptr<Span> leftover(new Span( + std::unique_ptr<Span> leftover(new Span( span->shared_memory_, span->start_ + blocks, span->length_ - blocks)); DCHECK(leftover->length_ == 1 || spans_.find(leftover->start_) == spans_.end()); @@ -185,7 +188,7 @@ return leftover; } -scoped_ptr<DiscardableSharedMemoryHeap::Span> +std::unique_ptr<DiscardableSharedMemoryHeap::Span> DiscardableSharedMemoryHeap::SearchFreeLists(size_t blocks, size_t slack) { DCHECK(blocks); @@ -260,26 +263,26 @@ } void DiscardableSharedMemoryHeap::InsertIntoFreeList( - scoped_ptr<DiscardableSharedMemoryHeap::Span> span) { + std::unique_ptr<DiscardableSharedMemoryHeap::Span> span) { DCHECK(!IsInFreeList(span.get())); size_t index = std::min(span->length_, arraysize(free_spans_)) - 1; free_spans_[index].Append(span.release()); } -scoped_ptr<DiscardableSharedMemoryHeap::Span> +std::unique_ptr<DiscardableSharedMemoryHeap::Span> DiscardableSharedMemoryHeap::RemoveFromFreeList(Span* span) { DCHECK(IsInFreeList(span)); span->RemoveFromList(); - return make_scoped_ptr(span); + return base::WrapUnique(span); } -scoped_ptr<DiscardableSharedMemoryHeap::Span> +std::unique_ptr<DiscardableSharedMemoryHeap::Span> DiscardableSharedMemoryHeap::Carve(Span* span, size_t blocks) { - scoped_ptr<Span> serving = RemoveFromFreeList(span); + std::unique_ptr<Span> serving = RemoveFromFreeList(span); const int extra = serving->length_ - blocks; if (extra) { - scoped_ptr<Span> leftover( + std::unique_ptr<Span> leftover( new Span(serving->shared_memory_, serving->start_ + blocks, extra)); leftover->set_is_locked(false); DCHECK(extra == 1 || spans_.find(leftover->start_) == spans_.end());
diff --git a/content/common/discardable_shared_memory_heap.h b/content/common/discardable_shared_memory_heap.h index 010e0187..6df1a16 100644 --- a/content/common/discardable_shared_memory_heap.h +++ b/content/common/discardable_shared_memory_heap.h
@@ -8,11 +8,12 @@ #include <stddef.h> #include <stdint.h> +#include <memory> + #include "base/callback.h" #include "base/containers/hash_tables.h" #include "base/containers/linked_list.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_vector.h" #include "base/trace_event/process_memory_dump.h" #include "content/common/content_export.h" @@ -58,26 +59,27 @@ // |shared_memory| must be aligned to the block size and |size| must be a // multiple of the block size. |deleted_callback| is called when // |shared_memory| has been deleted. - scoped_ptr<Span> Grow(scoped_ptr<base::DiscardableSharedMemory> shared_memory, - size_t size, - int32_t id, - const base::Closure& deleted_callback); + std::unique_ptr<Span> Grow( + std::unique_ptr<base::DiscardableSharedMemory> shared_memory, + size_t size, + int32_t id, + const base::Closure& deleted_callback); // Merge |span| into the free lists. This will coalesce |span| with // neighboring free spans when possible. - void MergeIntoFreeLists(scoped_ptr<Span> span); + void MergeIntoFreeLists(std::unique_ptr<Span> span); // Split an allocated span into two spans, one of length |blocks| followed // by another span of length "span->length - blocks" blocks. Modifies |span| // to point to the first span of length |blocks|. Return second span. - scoped_ptr<Span> Split(Span* span, size_t blocks); + std::unique_ptr<Span> Split(Span* span, size_t blocks); // Search free lists for span that satisfies the request for |blocks| of // memory. If found, the span is removed from the free list and returned. // |slack| determines the fitness requirement. Only spans that are less // or equal to |blocks| + |slack| are considered, worse fitting spans are // ignored. - scoped_ptr<Span> SearchFreeLists(size_t blocks, size_t slack); + std::unique_ptr<Span> SearchFreeLists(size_t blocks, size_t slack); // Release free shared memory segments. void ReleaseFreeMemory(); @@ -110,11 +112,12 @@ private: class ScopedMemorySegment { public: - ScopedMemorySegment(DiscardableSharedMemoryHeap* heap, - scoped_ptr<base::DiscardableSharedMemory> shared_memory, - size_t size, - int32_t id, - const base::Closure& deleted_callback); + ScopedMemorySegment( + DiscardableSharedMemoryHeap* heap, + std::unique_ptr<base::DiscardableSharedMemory> shared_memory, + size_t size, + int32_t id, + const base::Closure& deleted_callback); ~ScopedMemorySegment(); bool IsUsed() const; @@ -133,7 +136,7 @@ private: DiscardableSharedMemoryHeap* const heap_; - scoped_ptr<base::DiscardableSharedMemory> shared_memory_; + std::unique_ptr<base::DiscardableSharedMemory> shared_memory_; const size_t size_; const int32_t id_; const base::Closure deleted_callback_; @@ -141,9 +144,9 @@ DISALLOW_COPY_AND_ASSIGN(ScopedMemorySegment); }; - void InsertIntoFreeList(scoped_ptr<Span> span); - scoped_ptr<Span> RemoveFromFreeList(Span* span); - scoped_ptr<Span> Carve(Span* span, size_t blocks); + void InsertIntoFreeList(std::unique_ptr<Span> span); + std::unique_ptr<Span> RemoveFromFreeList(Span* span); + std::unique_ptr<Span> Carve(Span* span, size_t blocks); void RegisterSpan(Span* span); void UnregisterSpan(Span* span); bool IsMemoryUsed(const base::DiscardableSharedMemory* shared_memory,
diff --git a/content/common/discardable_shared_memory_heap_perftest.cc b/content/common/discardable_shared_memory_heap_perftest.cc index 8c37a85..8dc3d588 100644 --- a/content/common/discardable_shared_memory_heap_perftest.cc +++ b/content/common/discardable_shared_memory_heap_perftest.cc
@@ -37,7 +37,7 @@ int next_discardable_shared_memory_id = 0; for (size_t i = 0; i < kSegments; ++i) { - scoped_ptr<base::DiscardableSharedMemory> memory( + std::unique_ptr<base::DiscardableSharedMemory> memory( new base::DiscardableSharedMemory); ASSERT_TRUE(memory->CreateAndMap(segment_size)); heap.MergeIntoFreeLists(heap.Grow(std::move(memory), segment_size, @@ -71,7 +71,7 @@ // Search for a perfect fit if greater than kBlocks. size_t slack = random_blocks[i] < kBlocks ? kBlocks - random_blocks[i] : 0; - scoped_ptr<DiscardableSharedMemoryHeap::Span> span = + std::unique_ptr<DiscardableSharedMemoryHeap::Span> span = heap.SearchFreeLists(random_blocks[i], slack); if (span) { spans.push_back(new base::ScopedClosureRunner(
diff --git a/content/common/discardable_shared_memory_heap_unittest.cc b/content/common/discardable_shared_memory_heap_unittest.cc index b2fc22f..6e4aac4 100644 --- a/content/common/discardable_shared_memory_heap_unittest.cc +++ b/content/common/discardable_shared_memory_heap_unittest.cc
@@ -35,12 +35,12 @@ size_t memory_size = block_size * kBlocks; int next_discardable_shared_memory_id = 0; - scoped_ptr<base::DiscardableSharedMemory> memory( + std::unique_ptr<base::DiscardableSharedMemory> memory( new base::DiscardableSharedMemory); ASSERT_TRUE(memory->CreateAndMap(memory_size)); // Create new span for memory. - scoped_ptr<DiscardableSharedMemoryHeap::Span> new_span( + std::unique_ptr<DiscardableSharedMemoryHeap::Span> new_span( heap.Grow(std::move(memory), memory_size, next_discardable_shared_memory_id++, base::Bind(NullTask))); @@ -63,7 +63,7 @@ EXPECT_FALSE(heap.SearchFreeLists(kBlocks + 1, 0)); // Free lists should contain a span that satisfies the request for kBlocks. - scoped_ptr<DiscardableSharedMemoryHeap::Span> span = + std::unique_ptr<DiscardableSharedMemoryHeap::Span> span = heap.SearchFreeLists(kBlocks, 0); ASSERT_TRUE(span); @@ -82,15 +82,15 @@ size_t memory_size = block_size * kBlocks; int next_discardable_shared_memory_id = 0; - scoped_ptr<base::DiscardableSharedMemory> memory( + std::unique_ptr<base::DiscardableSharedMemory> memory( new base::DiscardableSharedMemory); ASSERT_TRUE(memory->CreateAndMap(memory_size)); - scoped_ptr<DiscardableSharedMemoryHeap::Span> new_span( + std::unique_ptr<DiscardableSharedMemoryHeap::Span> new_span( heap.Grow(std::move(memory), memory_size, next_discardable_shared_memory_id++, base::Bind(NullTask))); // Split span into two. - scoped_ptr<DiscardableSharedMemoryHeap::Span> leftover = + std::unique_ptr<DiscardableSharedMemoryHeap::Span> leftover = heap.Split(new_span.get(), 3); ASSERT_TRUE(leftover); @@ -104,12 +104,12 @@ heap.MergeIntoFreeLists(std::move(new_span)); // Remove a 2 page span from free lists. - scoped_ptr<DiscardableSharedMemoryHeap::Span> span1 = + std::unique_ptr<DiscardableSharedMemoryHeap::Span> span1 = heap.SearchFreeLists(2, kBlocks); ASSERT_TRUE(span1); // Remove another 2 page span from free lists. - scoped_ptr<DiscardableSharedMemoryHeap::Span> span2 = + std::unique_ptr<DiscardableSharedMemoryHeap::Span> span2 = heap.SearchFreeLists(2, kBlocks); ASSERT_TRUE(span2); @@ -123,7 +123,7 @@ heap.MergeIntoFreeLists(std::move(span2)); // All memory has been returned to the free lists. - scoped_ptr<DiscardableSharedMemoryHeap::Span> large_span = + std::unique_ptr<DiscardableSharedMemoryHeap::Span> large_span = heap.SearchFreeLists(kBlocks, 0); ASSERT_TRUE(large_span); @@ -139,15 +139,15 @@ size_t memory_size = block_size * kBlocks; int next_discardable_shared_memory_id = 0; - scoped_ptr<base::DiscardableSharedMemory> memory( + std::unique_ptr<base::DiscardableSharedMemory> memory( new base::DiscardableSharedMemory); ASSERT_TRUE(memory->CreateAndMap(memory_size)); - scoped_ptr<DiscardableSharedMemoryHeap::Span> new_span( + std::unique_ptr<DiscardableSharedMemoryHeap::Span> new_span( heap.Grow(std::move(memory), memory_size, next_discardable_shared_memory_id++, base::Bind(NullTask))); // Split span into two. - scoped_ptr<DiscardableSharedMemoryHeap::Span> leftover = + std::unique_ptr<DiscardableSharedMemoryHeap::Span> leftover = heap.Split(new_span.get(), 5); ASSERT_TRUE(leftover); @@ -163,7 +163,7 @@ DiscardableSharedMemoryHeap heap(block_size); int next_discardable_shared_memory_id = 0; - scoped_ptr<base::DiscardableSharedMemory> memory1( + std::unique_ptr<base::DiscardableSharedMemory> memory1( new base::DiscardableSharedMemory); ASSERT_TRUE(memory1->CreateAndMap(block_size)); heap.MergeIntoFreeLists(heap.Grow(std::move(memory1), block_size, @@ -171,7 +171,7 @@ base::Bind(NullTask))); // Remove a span from free lists. - scoped_ptr<DiscardableSharedMemoryHeap::Span> span1 = + std::unique_ptr<DiscardableSharedMemoryHeap::Span> span1 = heap.SearchFreeLists(1, 0); EXPECT_TRUE(span1); @@ -179,7 +179,7 @@ EXPECT_FALSE(heap.SearchFreeLists(1, 0)); // Grow free lists using new memory. - scoped_ptr<base::DiscardableSharedMemory> memory2( + std::unique_ptr<base::DiscardableSharedMemory> memory2( new base::DiscardableSharedMemory); ASSERT_TRUE(memory2->CreateAndMap(block_size)); heap.MergeIntoFreeLists(heap.Grow(std::move(memory2), block_size, @@ -187,7 +187,7 @@ base::Bind(NullTask))); // Memory should now be available. - scoped_ptr<DiscardableSharedMemoryHeap::Span> span2 = + std::unique_ptr<DiscardableSharedMemoryHeap::Span> span2 = heap.SearchFreeLists(1, 0); EXPECT_TRUE(span2); @@ -201,10 +201,10 @@ DiscardableSharedMemoryHeap heap(block_size); int next_discardable_shared_memory_id = 0; - scoped_ptr<base::DiscardableSharedMemory> memory( + std::unique_ptr<base::DiscardableSharedMemory> memory( new base::DiscardableSharedMemory); ASSERT_TRUE(memory->CreateAndMap(block_size)); - scoped_ptr<DiscardableSharedMemoryHeap::Span> span = + std::unique_ptr<DiscardableSharedMemoryHeap::Span> span = heap.Grow(std::move(memory), block_size, next_discardable_shared_memory_id++, base::Bind(NullTask)); @@ -229,10 +229,10 @@ DiscardableSharedMemoryHeap heap(block_size); int next_discardable_shared_memory_id = 0; - scoped_ptr<base::DiscardableSharedMemory> memory( + std::unique_ptr<base::DiscardableSharedMemory> memory( new base::DiscardableSharedMemory); ASSERT_TRUE(memory->CreateAndMap(block_size)); - scoped_ptr<DiscardableSharedMemoryHeap::Span> span = + std::unique_ptr<DiscardableSharedMemoryHeap::Span> span = heap.Grow(std::move(memory), block_size, next_discardable_shared_memory_id++, base::Bind(NullTask)); @@ -259,7 +259,7 @@ size_t memory_size = block_size * kBlocks; int next_discardable_shared_memory_id = 0; - scoped_ptr<base::DiscardableSharedMemory> memory( + std::unique_ptr<base::DiscardableSharedMemory> memory( new base::DiscardableSharedMemory); ASSERT_TRUE(memory->CreateAndMap(memory_size)); heap.MergeIntoFreeLists(heap.Grow(std::move(memory), memory_size, @@ -275,7 +275,7 @@ // No free span that is less or equal to 1 + 4. EXPECT_FALSE(heap.SearchFreeLists(1, 4)); - scoped_ptr<DiscardableSharedMemoryHeap::Span> span = + std::unique_ptr<DiscardableSharedMemoryHeap::Span> span = heap.SearchFreeLists(1, 5); EXPECT_TRUE(span); @@ -291,11 +291,11 @@ DiscardableSharedMemoryHeap heap(block_size); int next_discardable_shared_memory_id = 0; - scoped_ptr<base::DiscardableSharedMemory> memory( + std::unique_ptr<base::DiscardableSharedMemory> memory( new base::DiscardableSharedMemory); ASSERT_TRUE(memory->CreateAndMap(block_size)); bool deleted = false; - scoped_ptr<DiscardableSharedMemoryHeap::Span> span = heap.Grow( + std::unique_ptr<DiscardableSharedMemoryHeap::Span> span = heap.Grow( std::move(memory), block_size, next_discardable_shared_memory_id++, base::Bind(OnDeleted, base::Unretained(&deleted))); @@ -310,15 +310,15 @@ DiscardableSharedMemoryHeap heap(block_size); int next_discardable_shared_memory_id = 0; - scoped_ptr<base::DiscardableSharedMemory> memory( + std::unique_ptr<base::DiscardableSharedMemory> memory( new base::DiscardableSharedMemory); ASSERT_TRUE(memory->CreateAndMap(block_size)); - scoped_ptr<DiscardableSharedMemoryHeap::Span> span = + std::unique_ptr<DiscardableSharedMemoryHeap::Span> span = heap.Grow(std::move(memory), block_size, next_discardable_shared_memory_id++, base::Bind(NullTask)); // Check if allocator dump is created when span exists. - scoped_ptr<base::trace_event::ProcessMemoryDump> pmd( + std::unique_ptr<base::trace_event::ProcessMemoryDump> pmd( new base::trace_event::ProcessMemoryDump(nullptr)); EXPECT_TRUE(heap.CreateMemoryAllocatorDump(span.get(), "discardable/test1", pmd.get()));
diff --git a/content/common/font_config_ipc_linux.cc b/content/common/font_config_ipc_linux.cc index 294bcf8..08fed23 100644 --- a/content/common/font_config_ipc_linux.cc +++ b/content/common/font_config_ipc_linux.cc
@@ -14,11 +14,11 @@ #include <unistd.h> #include <functional> +#include <memory> #include "base/files/file_util.h" #include "base/files/memory_mapped_file.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/pickle.h" #include "base/posix/unix_domain_socket_linux.h" #include "base/threading/thread_restrictions.h" @@ -117,7 +117,7 @@ } SkMemoryStream* FontConfigIPC::mapFileDescriptorToStream(int fd) { - scoped_ptr<base::MemoryMappedFile> mapped_font_file( + std::unique_ptr<base::MemoryMappedFile> mapped_font_file( new base::MemoryMappedFile); base::ThreadRestrictions::ScopedAllowIO allow_mmap; mapped_font_file->Initialize(base::File(fd));
diff --git a/content/common/font_list.h b/content/common/font_list.h index dd14ce71..7729213 100644 --- a/content/common/font_list.h +++ b/content/common/font_list.h
@@ -5,7 +5,7 @@ #ifndef CONTENT_COMMON_FONT_LIST_H_ #define CONTENT_COMMON_FONT_LIST_H_ -#include "base/memory/scoped_ptr.h" +#include <memory> namespace base { class ListValue; @@ -31,7 +31,7 @@ // // Most callers will want to use the GetFontListAsync function in // content/browser/font_list_async.h which does an asynchronous call. -scoped_ptr<base::ListValue> GetFontList_SlowBlocking(); +std::unique_ptr<base::ListValue> GetFontList_SlowBlocking(); } // namespace content
diff --git a/content/common/font_list_android.cc b/content/common/font_list_android.cc index 71ff8b6..73df728 100644 --- a/content/common/font_list_android.cc +++ b/content/common/font_list_android.cc
@@ -8,8 +8,8 @@ namespace content { -scoped_ptr<base::ListValue> GetFontList_SlowBlocking() { - return scoped_ptr<base::ListValue>(new base::ListValue); +std::unique_ptr<base::ListValue> GetFontList_SlowBlocking() { + return std::unique_ptr<base::ListValue>(new base::ListValue); } } // namespace content
diff --git a/content/common/font_list_mac.mm b/content/common/font_list_mac.mm index f4a7cedd..8c7d889 100644 --- a/content/common/font_list_mac.mm +++ b/content/common/font_list_mac.mm
@@ -12,9 +12,9 @@ namespace content { -scoped_ptr<base::ListValue> GetFontList_SlowBlocking() { +std::unique_ptr<base::ListValue> GetFontList_SlowBlocking() { base::mac::ScopedNSAutoreleasePool autorelease_pool; - scoped_ptr<base::ListValue> font_list(new base::ListValue); + std::unique_ptr<base::ListValue> font_list(new base::ListValue); NSFontManager* fontManager = [[[NSFontManager alloc] init] autorelease]; NSArray* fonts = [fontManager availableFontFamilies]; for (NSString* family_name in fonts) {
diff --git a/content/common/font_list_ozone.cc b/content/common/font_list_ozone.cc index 71ff8b6..73df728 100644 --- a/content/common/font_list_ozone.cc +++ b/content/common/font_list_ozone.cc
@@ -8,8 +8,8 @@ namespace content { -scoped_ptr<base::ListValue> GetFontList_SlowBlocking() { - return scoped_ptr<base::ListValue>(new base::ListValue); +std::unique_ptr<base::ListValue> GetFontList_SlowBlocking() { + return std::unique_ptr<base::ListValue>(new base::ListValue); } } // namespace content
diff --git a/content/common/font_list_pango.cc b/content/common/font_list_pango.cc index 15f21dc..d64c9033 100644 --- a/content/common/font_list_pango.cc +++ b/content/common/font_list_pango.cc
@@ -14,8 +14,8 @@ namespace content { -scoped_ptr<base::ListValue> GetFontList_SlowBlocking() { - scoped_ptr<base::ListValue> font_list(new base::ListValue); +std::unique_ptr<base::ListValue> GetFontList_SlowBlocking() { + std::unique_ptr<base::ListValue> font_list(new base::ListValue); PangoFontMap* font_map = ::pango_cairo_font_map_get_default(); PangoFontFamily** families = NULL;
diff --git a/content/common/font_list_win.cc b/content/common/font_list_win.cc index 62717ec3..8d00e0a 100644 --- a/content/common/font_list_win.cc +++ b/content/common/font_list_win.cc
@@ -30,7 +30,7 @@ return 1; } -scoped_ptr<base::ListValue> GetFontList_SlowBlocking() { +std::unique_ptr<base::ListValue> GetFontList_SlowBlocking() { std::set<base::string16> font_names; LOGFONTW logfont; @@ -42,7 +42,7 @@ (LPARAM)&font_names, 0); ::ReleaseDC(NULL, hdc); - scoped_ptr<base::ListValue> font_list(new base::ListValue); + std::unique_ptr<base::ListValue> font_list(new base::ListValue); std::set<base::string16>::iterator iter; for (iter = font_names.begin(); iter != font_names.end(); ++iter) { base::ListValue* font_item = new base::ListValue();
diff --git a/content/common/gpu/client/context_provider_command_buffer.cc b/content/common/gpu/client/context_provider_command_buffer.cc index 7ef9e732..557af910 100644 --- a/content/common/gpu/client/context_provider_command_buffer.cc +++ b/content/common/gpu/client/context_provider_command_buffer.cc
@@ -38,7 +38,7 @@ scoped_refptr<ContextProviderCommandBuffer> ContextProviderCommandBuffer::Create( - scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, + std::unique_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, CommandBufferContextType type) { if (!context3d) return NULL; @@ -47,7 +47,7 @@ } ContextProviderCommandBuffer::ContextProviderCommandBuffer( - scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, + std::unique_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, CommandBufferContextType type) : context3d_(std::move(context3d)), context_type_(type),
diff --git a/content/common/gpu/client/context_provider_command_buffer.h b/content/common/gpu/client/context_provider_command_buffer.h index 65b0e50..134035a 100644 --- a/content/common/gpu/client/context_provider_command_buffer.h +++ b/content/common/gpu/client/context_provider_command_buffer.h
@@ -7,8 +7,9 @@ #include <stdint.h> +#include <memory> + #include "base/compiler_specific.h" -#include "base/memory/scoped_ptr.h" #include "base/synchronization/lock.h" #include "base/threading/thread_checker.h" #include "cc/blink/context_provider_web_context.h" @@ -27,7 +28,7 @@ : NON_EXPORTED_BASE(public cc_blink::ContextProviderWebContext) { public: static scoped_refptr<ContextProviderCommandBuffer> Create( - scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, + std::unique_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, CommandBufferContextType type); gpu::CommandBufferProxyImpl* GetCommandBufferProxy(); @@ -51,7 +52,7 @@ protected: ContextProviderCommandBuffer( - scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, + std::unique_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, CommandBufferContextType type); ~ContextProviderCommandBuffer() override; @@ -63,8 +64,8 @@ base::ThreadChecker main_thread_checker_; base::ThreadChecker context_thread_checker_; - scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d_; - scoped_ptr<GrContextForGLES2Interface> gr_context_; + std::unique_ptr<WebGraphicsContext3DCommandBufferImpl> context3d_; + std::unique_ptr<GrContextForGLES2Interface> gr_context_; cc::ContextProvider::Capabilities capabilities_; CommandBufferContextType context_type_; @@ -75,7 +76,7 @@ base::Lock context_lock_; class LostContextCallbackProxy; - scoped_ptr<LostContextCallbackProxy> lost_context_callback_proxy_; + std::unique_ptr<LostContextCallbackProxy> lost_context_callback_proxy_; }; } // namespace content
diff --git a/content/common/gpu/client/gpu_in_process_context_tests.cc b/content/common/gpu/client/gpu_in_process_context_tests.cc index c8f0d3f2..933466d 100644 --- a/content/common/gpu/client/gpu_in_process_context_tests.cc +++ b/content/common/gpu/client/gpu_in_process_context_tests.cc
@@ -50,7 +50,7 @@ gpu::ContextSupport* context_support_; private: - scoped_ptr<gpu::GLInProcessContext> context_; + std::unique_ptr<gpu::GLInProcessContext> context_; }; } // namespace
diff --git a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc index 708a3da..d6ded78e 100644 --- a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc +++ b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc
@@ -206,7 +206,7 @@ TRACE_EVENT0("gpu", "WebGfxCtx3DCmdBfrImpl::CreateContext"); scoped_refptr<gpu::gles2::ShareGroup> gles2_share_group; - scoped_ptr<base::AutoLock> share_group_lock; + std::unique_ptr<base::AutoLock> share_group_lock; bool add_to_share_group = false; if (!command_buffer_) { WebGraphicsContext3DCommandBufferImpl* share_context = NULL;
diff --git a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h index 1bbd7202e..20152705 100644 --- a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h +++ b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h
@@ -8,12 +8,12 @@ #include <stddef.h> #include <stdint.h> +#include <memory> #include <string> #include <vector> #include "base/callback.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/synchronization/lock.h" #include "content/common/content_export.h" @@ -204,11 +204,11 @@ gfx::GpuPreference gpu_preference_; - scoped_ptr<gpu::CommandBufferProxyImpl> command_buffer_; - scoped_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_; - scoped_ptr<gpu::TransferBuffer> transfer_buffer_; - scoped_ptr<gpu::gles2::GLES2Implementation> real_gl_; - scoped_ptr<gpu::gles2::GLES2Interface> trace_gl_; + std::unique_ptr<gpu::CommandBufferProxyImpl> command_buffer_; + std::unique_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_; + std::unique_ptr<gpu::TransferBuffer> transfer_buffer_; + std::unique_ptr<gpu::gles2::GLES2Implementation> real_gl_; + std::unique_ptr<gpu::gles2::GLES2Interface> trace_gl_; SharedMemoryLimits mem_limits_; scoped_refptr<ShareGroup> share_group_;
diff --git a/content/common/gpu/media/android_copying_backing_strategy.h b/content/common/gpu/media/android_copying_backing_strategy.h index 8980404..83b6c4a 100644 --- a/content/common/gpu/media/android_copying_backing_strategy.h +++ b/content/common/gpu/media/android_copying_backing_strategy.h
@@ -50,7 +50,7 @@ private: // Used for copy the texture from surface texture to picture buffers. - scoped_ptr<gpu::CopyTextureCHROMIUMResourceManager> copier_; + std::unique_ptr<gpu::CopyTextureCHROMIUMResourceManager> copier_; AVDAStateProvider* state_provider_;
diff --git a/content/common/gpu/media/android_video_decode_accelerator.cc b/content/common/gpu/media/android_video_decode_accelerator.cc index 09f59d3..e6e9f51 100644 --- a/content/common/gpu/media/android_video_decode_accelerator.cc +++ b/content/common/gpu/media/android_video_decode_accelerator.cc
@@ -531,7 +531,7 @@ return true; } - scoped_ptr<SharedMemoryRegion> shm; + std::unique_ptr<SharedMemoryRegion> shm; if (pending_input_buf_index_ == -1) { // When |pending_input_buf_index_| is not -1, the buffer is already dequeued @@ -939,13 +939,13 @@ bool AndroidVideoDecodeAccelerator::ConfigureMediaCodecSynchronously() { state_ = WAITING_FOR_CODEC; - scoped_ptr<media::VideoCodecBridge> media_codec = + std::unique_ptr<media::VideoCodecBridge> media_codec = ConfigureMediaCodecOnAnyThread(codec_config_); OnCodecConfigured(std::move(media_codec)); return !!media_codec_; } -scoped_ptr<media::VideoCodecBridge> +std::unique_ptr<media::VideoCodecBridge> AndroidVideoDecodeAccelerator::ConfigureMediaCodecOnAnyThread( scoped_refptr<CodecConfig> codec_config) { TRACE_EVENT0("media", "AVDA::ConfigureMediaCodec"); @@ -957,7 +957,7 @@ // |needs_protected_surface_| implies encrypted stream. DCHECK(!codec_config->needs_protected_surface_ || media_crypto); - return scoped_ptr<media::VideoCodecBridge>( + return std::unique_ptr<media::VideoCodecBridge>( media::VideoCodecBridge::CreateDecoder( codec_config->codec_, codec_config->needs_protected_surface_, codec_config->initial_expected_coded_size_, @@ -965,7 +965,7 @@ } void AndroidVideoDecodeAccelerator::OnCodecConfigured( - scoped_ptr<media::VideoCodecBridge> media_codec) { + std::unique_ptr<media::VideoCodecBridge> media_codec) { DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_EQ(state_, WAITING_FOR_CODEC);
diff --git a/content/common/gpu/media/android_video_decode_accelerator.h b/content/common/gpu/media/android_video_decode_accelerator.h index 1e0543d3..6728270 100644 --- a/content/common/gpu/media/android_video_decode_accelerator.h +++ b/content/common/gpu/media/android_video_decode_accelerator.h
@@ -212,12 +212,12 @@ // Instantiate a media codec using |codec_config|. // This may be called on any thread. - static scoped_ptr<media::VideoCodecBridge> ConfigureMediaCodecOnAnyThread( - scoped_refptr<CodecConfig> codec_config); + static std::unique_ptr<media::VideoCodecBridge> + ConfigureMediaCodecOnAnyThread(scoped_refptr<CodecConfig> codec_config); // Called on the main thread to update |media_codec_| and complete codec // configuration. |media_codec| will be null if configuration failed. - void OnCodecConfigured(scoped_ptr<media::VideoCodecBridge> media_codec); + void OnCodecConfigured(std::unique_ptr<media::VideoCodecBridge> media_codec); // Sends the decoded frame specified by |codec_buffer_index| to the client. void SendDecodedFrameToClient(int32_t codec_buffer_index, @@ -320,7 +320,7 @@ std::queue<int32_t> free_picture_ids_; // The low-level decoder which Android SDK provides. - scoped_ptr<media::VideoCodecBridge> media_codec_; + std::unique_ptr<media::VideoCodecBridge> media_codec_; // Set to true after requesting picture buffers to the client. bool picturebuffers_requested_; @@ -343,7 +343,7 @@ std::list<int32_t> bitstreams_notified_in_advance_; // Backing strategy that we'll use to connect PictureBuffers to frames. - scoped_ptr<BackingStrategy> strategy_; + std::unique_ptr<BackingStrategy> strategy_; // Helper class that manages asynchronous OnFrameAvailable callbacks. class OnFrameAvailableHandler;
diff --git a/content/common/gpu/media/android_video_decode_accelerator_unittest.cc b/content/common/gpu/media/android_video_decode_accelerator_unittest.cc index d21ad9e..2a10eea 100644 --- a/content/common/gpu/media/android_video_decode_accelerator_unittest.cc +++ b/content/common/gpu/media/android_video_decode_accelerator_unittest.cc
@@ -6,10 +6,11 @@ #include <stdint.h> +#include <memory> + #include "base/android/jni_android.h" #include "base/bind.h" #include "base/logging.h" -#include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" #include "content/common/gpu/media/android_copying_backing_strategy.h" #include "content/common/gpu/media/android_video_decode_accelerator.h" @@ -68,9 +69,9 @@ // AndroidVideoDecodeAccelerator::ConfigureMediaCodec() starts a timer task. message_loop_.reset(new base::MessageLoop()); - scoped_ptr<gpu::gles2::MockGLES2Decoder> decoder( + std::unique_ptr<gpu::gles2::MockGLES2Decoder> decoder( new gpu::gles2::MockGLES2Decoder()); - scoped_ptr<MockVideoDecodeAcceleratorClient> client( + std::unique_ptr<MockVideoDecodeAcceleratorClient> client( new MockVideoDecodeAcceleratorClient()); accelerator_.reset(new AndroidVideoDecodeAccelerator( base::Bind(&MockMakeContextCurrent), @@ -89,8 +90,8 @@ } private: - scoped_ptr<media::VideoDecodeAccelerator> accelerator_; - scoped_ptr<base::MessageLoop> message_loop_; + std::unique_ptr<media::VideoDecodeAccelerator> accelerator_; + std::unique_ptr<base::MessageLoop> message_loop_; }; TEST_F(AndroidVideoDecodeAcceleratorTest, ConfigureUnsupportedCodec) {
diff --git a/content/common/gpu/media/android_video_encode_accelerator.cc b/content/common/gpu/media/android_video_encode_accelerator.cc index ac2ff39..accaa501 100644 --- a/content/common/gpu/media/android_video_encode_accelerator.cc +++ b/content/common/gpu/media/android_video_encode_accelerator.cc
@@ -419,7 +419,7 @@ media::BitstreamBuffer bitstream_buffer = available_bitstream_buffers_.back(); available_bitstream_buffers_.pop_back(); - scoped_ptr<SharedMemoryRegion> shm( + std::unique_ptr<SharedMemoryRegion> shm( new SharedMemoryRegion(bitstream_buffer, false)); RETURN_ON_FAILURE(shm->Map(), "Failed to map SHM", kPlatformFailureError); RETURN_ON_FAILURE(size <= shm->size(),
diff --git a/content/common/gpu/media/android_video_encode_accelerator.h b/content/common/gpu/media/android_video_encode_accelerator.h index 0de3d18..a708872 100644 --- a/content/common/gpu/media/android_video_encode_accelerator.h +++ b/content/common/gpu/media/android_video_encode_accelerator.h
@@ -76,9 +76,9 @@ // VideoDecodeAccelerator::Client callbacks go here. Invalidated once any // error triggers. - scoped_ptr<base::WeakPtrFactory<Client> > client_ptr_factory_; + std::unique_ptr<base::WeakPtrFactory<Client>> client_ptr_factory_; - scoped_ptr<media::VideoCodecBridge> media_codec_; + std::unique_ptr<media::VideoCodecBridge> media_codec_; // Bitstream buffers waiting to be populated & returned to the client. std::vector<media::BitstreamBuffer> available_bitstream_buffers_;
diff --git a/content/common/gpu/media/avda_codec_image.cc b/content/common/gpu/media/avda_codec_image.cc index 5830433c..667ab31 100644 --- a/content/common/gpu/media/avda_codec_image.cc +++ b/content/common/gpu/media/avda_codec_image.cc
@@ -137,7 +137,8 @@ codec_buffer_index_ = kInvalidCodecBufferIndex; // Swap the rendered image to the front. - scoped_ptr<ui::ScopedMakeCurrent> scoped_make_current = MakeCurrentIfNeeded(); + std::unique_ptr<ui::ScopedMakeCurrent> scoped_make_current = + MakeCurrentIfNeeded(); // If we changed contexts, then we always want to restore it, since the caller // doesn't know that we're switching contexts. @@ -196,9 +197,9 @@ shared_state_->DidAttachSurfaceTexture(); } -scoped_ptr<ui::ScopedMakeCurrent> AVDACodecImage::MakeCurrentIfNeeded() { +std::unique_ptr<ui::ScopedMakeCurrent> AVDACodecImage::MakeCurrentIfNeeded() { DCHECK(shared_state_->context()); - scoped_ptr<ui::ScopedMakeCurrent> scoped_make_current; + std::unique_ptr<ui::ScopedMakeCurrent> scoped_make_current; if (!shared_state_->context()->IsCurrent(NULL)) { scoped_make_current.reset(new ui::ScopedMakeCurrent( shared_state_->context(), shared_state_->surface()));
diff --git a/content/common/gpu/media/avda_codec_image.h b/content/common/gpu/media/avda_codec_image.h index 46547e4..8adb5fb 100644 --- a/content/common/gpu/media/avda_codec_image.h +++ b/content/common/gpu/media/avda_codec_image.h
@@ -84,7 +84,7 @@ void AttachSurfaceTextureToContext(); // Make shared_state_->context() current if it isn't already. - scoped_ptr<ui::ScopedMakeCurrent> MakeCurrentIfNeeded(); + std::unique_ptr<ui::ScopedMakeCurrent> MakeCurrentIfNeeded(); // Return whether or not the current context is in the same share group as // |surface_texture_|'s client texture.
diff --git a/content/common/gpu/media/dxva_video_decode_accelerator_win.cc b/content/common/gpu/media/dxva_video_decode_accelerator_win.cc index e55c900..2e376f2 100644 --- a/content/common/gpu/media/dxva_video_decode_accelerator_win.cc +++ b/content/common/gpu/media/dxva_video_decode_accelerator_win.cc
@@ -4,6 +4,8 @@ #include "content/common/gpu/media/dxva_video_decode_accelerator_win.h" +#include <memory> + #if !defined(OS_WIN) #error This file should only be built on Windows. #endif // !defined(OS_WIN) @@ -26,7 +28,6 @@ #include "base/files/file_path.h" #include "base/logging.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/shared_memory.h" #include "base/message_loop/message_loop.h" #include "base/path_service.h" @@ -612,7 +613,7 @@ bool waiting_to_reuse_; media::PictureBuffer picture_buffer_; EGLSurface decoding_surface_; - scoped_ptr<gfx::GLFence> reuse_fence_; + std::unique_ptr<gfx::GLFence> reuse_fence_; HANDLE texture_share_handle_; base::win::ScopedComPtr<IDirect3DTexture9> decoding_texture_; @@ -1686,7 +1687,7 @@ // Check version of DLL, version 6.1.7140 is blacklisted due to high crash // rates in browsers loading that DLL. If that is the version installed we // fall back to software decoding. See crbug/403440. - scoped_ptr<FileVersionInfo> version_info( + std::unique_ptr<FileVersionInfo> version_info( FileVersionInfo::CreateFileVersionInfoForModule(decoder_dll)); RETURN_ON_FAILURE(version_info, "unable to get version of msmpeg2vdec.dll",
diff --git a/content/common/gpu/media/dxva_video_decode_accelerator_win.h b/content/common/gpu/media/dxva_video_decode_accelerator_win.h index 01c15e6..7f0c013 100644 --- a/content/common/gpu/media/dxva_video_decode_accelerator_win.h +++ b/content/common/gpu/media/dxva_video_decode_accelerator_win.h
@@ -78,7 +78,7 @@ // we want to honor after we see an IDR slice. bool pending_config_changed_; - scoped_ptr<media::H264Parser> parser_; + std::unique_ptr<media::H264Parser> parser_; DISALLOW_COPY_AND_ASSIGN(H264ConfigChangeDetector); }; @@ -470,7 +470,7 @@ // when these changes occur then, the decoder works fine. The // H264ConfigChangeDetector class provides functionality to check if the // stream configuration changed. - scoped_ptr<H264ConfigChangeDetector> config_change_detector_; + std::unique_ptr<H264ConfigChangeDetector> config_change_detector_; // Contains the initialization parameters for the video. Config config_;
diff --git a/content/common/gpu/media/fake_video_decode_accelerator.cc b/content/common/gpu/media/fake_video_decode_accelerator.cc index 01ac07d..f811162 100644 --- a/content/common/gpu/media/fake_video_decode_accelerator.cc +++ b/content/common/gpu/media/fake_video_decode_accelerator.cc
@@ -87,13 +87,13 @@ DCHECK(!(buffers.size()%2)); // Save buffers and mark all buffers as ready for use. - scoped_ptr<uint8_t[]> white_data( + std::unique_ptr<uint8_t[]> white_data( new uint8_t[frame_buffer_size_.width() * frame_buffer_size_.height() * 4]); memset(white_data.get(), UINT8_MAX, frame_buffer_size_.width() * frame_buffer_size_.height() * 4); - scoped_ptr<uint8_t[]> black_data( + std::unique_ptr<uint8_t[]> black_data( new uint8_t[frame_buffer_size_.width() * frame_buffer_size_.height() * 4]); memset(black_data.get(),
diff --git a/content/common/gpu/media/generic_v4l2_device.cc b/content/common/gpu/media/generic_v4l2_device.cc index 5a6885d9..ed9225f 100644 --- a/content/common/gpu/media/generic_v4l2_device.cc +++ b/content/common/gpu/media/generic_v4l2_device.cc
@@ -217,7 +217,8 @@ return EGL_NO_IMAGE_KHR; } - scoped_ptr<base::ScopedFD[]> dmabuf_fds(new base::ScopedFD[num_v4l2_planes]); + std::unique_ptr<base::ScopedFD[]> dmabuf_fds( + new base::ScopedFD[num_v4l2_planes]); // Export dmabuf fds so we can create an EGLImage from them. for (size_t i = 0; i < num_v4l2_planes; ++i) { struct v4l2_exportbuffer expbuf;
diff --git a/content/common/gpu/media/gpu_jpeg_decode_accelerator.cc b/content/common/gpu/media/gpu_jpeg_decode_accelerator.cc index 3e25607..6bf6ae4 100644 --- a/content/common/gpu/media/gpu_jpeg_decode_accelerator.cc +++ b/content/common/gpu/media/gpu_jpeg_decode_accelerator.cc
@@ -35,7 +35,7 @@ namespace { -void DecodeFinished(scoped_ptr<base::SharedMemory> shm) { +void DecodeFinished(std::unique_ptr<base::SharedMemory> shm) { // Do nothing. Because VideoFrame is backed by |shm|, the purpose of this // function is to just keep reference of |shm| to make sure it lives util // decode finishes. @@ -101,7 +101,8 @@ accelerator_->Decode(bitstream_buffer, video_frame); } - void set_accelerator(scoped_ptr<media::JpegDecodeAccelerator> accelerator) { + void set_accelerator( + std::unique_ptr<media::JpegDecodeAccelerator> accelerator) { DCHECK(CalledOnValidThread()); accelerator_ = std::move(accelerator); } @@ -109,7 +110,7 @@ private: base::WeakPtr<content::GpuJpegDecodeAccelerator> owner_; int32_t route_id_; - scoped_ptr<media::JpegDecodeAccelerator> accelerator_; + std::unique_ptr<media::JpegDecodeAccelerator> accelerator_; }; // Create, destroy, and RemoveClient run on child thread. All other methods run @@ -207,7 +208,7 @@ // For handles in |params|, from now on, |params.output_video_frame_handle| // is taken cared by scoper. |params.input_buffer.handle()| need to be // closed manually for early exits. - scoped_ptr<base::SharedMemory> output_shm( + std::unique_ptr<base::SharedMemory> output_shm( new base::SharedMemory(params.output_video_frame_handle, false)); if (!output_shm->Map(params.output_buffer_size)) { LOG(ERROR) << "Could not map output shared memory for input buffer id " @@ -257,7 +258,7 @@ STLDeleteValues(&client_map_); } else { // Make sure |Client| are deleted on child thread. - scoped_ptr<ClientMap> client_map(new ClientMap); + std::unique_ptr<ClientMap> client_map(new ClientMap); client_map->swap(client_map_); child_task_runner_->PostTask( @@ -270,7 +271,8 @@ using ClientMap = base::hash_map<int32_t, Client*>; // Must be static because this method runs after destructor. - static void DeleteClientMapOnChildThread(scoped_ptr<ClientMap> client_map) { + static void DeleteClientMapOnChildThread( + std::unique_ptr<ClientMap> client_map) { STLDeleteValues(client_map.get()); } @@ -320,10 +322,10 @@ &GpuJpegDecodeAccelerator::CreateVaapiJDA, }; - scoped_ptr<Client> client(new Client(this, route_id)); - scoped_ptr<media::JpegDecodeAccelerator> accelerator; + std::unique_ptr<Client> client(new Client(this, route_id)); + std::unique_ptr<media::JpegDecodeAccelerator> accelerator; for (const auto& create_jda_function : create_jda_fps) { - scoped_ptr<media::JpegDecodeAccelerator> tmp_accelerator = + std::unique_ptr<media::JpegDecodeAccelerator> tmp_accelerator = (*create_jda_function)(io_task_runner_); if (tmp_accelerator && tmp_accelerator->Initialize(client.get())) { accelerator = std::move(tmp_accelerator); @@ -381,10 +383,10 @@ } // static -scoped_ptr<media::JpegDecodeAccelerator> +std::unique_ptr<media::JpegDecodeAccelerator> GpuJpegDecodeAccelerator::CreateV4L2JDA( const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) { - scoped_ptr<media::JpegDecodeAccelerator> decoder; + std::unique_ptr<media::JpegDecodeAccelerator> decoder; #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) scoped_refptr<V4L2Device> device = V4L2Device::Create( V4L2Device::kJpegDecoder); @@ -395,10 +397,10 @@ } // static -scoped_ptr<media::JpegDecodeAccelerator> +std::unique_ptr<media::JpegDecodeAccelerator> GpuJpegDecodeAccelerator::CreateVaapiJDA( const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) { - scoped_ptr<media::JpegDecodeAccelerator> decoder; + std::unique_ptr<media::JpegDecodeAccelerator> decoder; #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) decoder.reset(new VaapiJpegDecodeAccelerator(io_task_runner)); #endif @@ -412,7 +414,7 @@ &GpuJpegDecodeAccelerator::CreateVaapiJDA, }; for (const auto& create_jda_function : create_jda_fps) { - scoped_ptr<media::JpegDecodeAccelerator> accelerator = + std::unique_ptr<media::JpegDecodeAccelerator> accelerator = (*create_jda_function)(base::ThreadTaskRunnerHandle::Get()); if (accelerator && accelerator->IsSupported()) return true;
diff --git a/content/common/gpu/media/gpu_jpeg_decode_accelerator.h b/content/common/gpu/media/gpu_jpeg_decode_accelerator.h index 680dac5..486fdf4a 100644 --- a/content/common/gpu/media/gpu_jpeg_decode_accelerator.h +++ b/content/common/gpu/media/gpu_jpeg_decode_accelerator.h
@@ -50,17 +50,17 @@ static bool IsSupported(); private: - using CreateJDAFp = scoped_ptr<media::JpegDecodeAccelerator> (*)( - const scoped_refptr<base::SingleThreadTaskRunner>&); + using CreateJDAFp = std::unique_ptr<media::JpegDecodeAccelerator> (*)( + const scoped_refptr<base::SingleThreadTaskRunner>&); class Client; class MessageFilter; void ClientRemoved(); - static scoped_ptr<media::JpegDecodeAccelerator> CreateV4L2JDA( + static std::unique_ptr<media::JpegDecodeAccelerator> CreateV4L2JDA( const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); - static scoped_ptr<media::JpegDecodeAccelerator> CreateVaapiJDA( + static std::unique_ptr<media::JpegDecodeAccelerator> CreateVaapiJDA( const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); // The lifetime of objects of this class is managed by a gpu::GpuChannel. The
diff --git a/content/common/gpu/media/gpu_video_decode_accelerator.cc b/content/common/gpu/media/gpu_video_decode_accelerator.cc index 4b2f6f6a..160d0c31 100644 --- a/content/common/gpu/media/gpu_video_decode_accelerator.cc +++ b/content/common/gpu/media/gpu_video_decode_accelerator.cc
@@ -344,7 +344,7 @@ return false; #endif - scoped_ptr<GpuVideoDecodeAcceleratorFactoryImpl> vda_factory = + std::unique_ptr<GpuVideoDecodeAcceleratorFactoryImpl> vda_factory = GpuVideoDecodeAcceleratorFactoryImpl::CreateWithGLES2Decoder( get_gl_context_cb_, make_context_current_cb_, bind_image_cb_, get_gles2_decoder_cb_);
diff --git a/content/common/gpu/media/gpu_video_decode_accelerator.h b/content/common/gpu/media/gpu_video_decode_accelerator.h index e090b59a..561ca34 100644 --- a/content/common/gpu/media/gpu_video_decode_accelerator.h +++ b/content/common/gpu/media/gpu_video_decode_accelerator.h
@@ -111,7 +111,7 @@ gpu::GpuCommandBufferStub* const stub_; // The underlying VideoDecodeAccelerator. - scoped_ptr<media::VideoDecodeAccelerator> video_decode_accelerator_; + std::unique_ptr<media::VideoDecodeAccelerator> video_decode_accelerator_; // Callback to return current GLContext, if available. GetGLContextCallback get_gl_context_cb_;
diff --git a/content/common/gpu/media/gpu_video_decode_accelerator_factory_impl.cc b/content/common/gpu/media/gpu_video_decode_accelerator_factory_impl.cc index 0483148..f6ec448 100644 --- a/content/common/gpu/media/gpu_video_decode_accelerator_factory_impl.cc +++ b/content/common/gpu/media/gpu_video_decode_accelerator_factory_impl.cc
@@ -4,6 +4,7 @@ #include "content/common/gpu/media/gpu_video_decode_accelerator_factory_impl.h" +#include "base/memory/ptr_util.h" #include "content/common/gpu/media/gpu_video_decode_accelerator.h" #include "gpu/command_buffer/service/gpu_preferences.h" #include "media/gpu/ipc/common/gpu_video_accelerator_util.h" @@ -38,24 +39,24 @@ } // static -scoped_ptr<GpuVideoDecodeAcceleratorFactoryImpl> +std::unique_ptr<GpuVideoDecodeAcceleratorFactoryImpl> GpuVideoDecodeAcceleratorFactoryImpl::Create( const GetGLContextCallback& get_gl_context_cb, const MakeGLContextCurrentCallback& make_context_current_cb, const BindGLImageCallback& bind_image_cb) { - return make_scoped_ptr(new GpuVideoDecodeAcceleratorFactoryImpl( + return base::WrapUnique(new GpuVideoDecodeAcceleratorFactoryImpl( get_gl_context_cb, make_context_current_cb, bind_image_cb, base::Bind(&GetEmptyGLES2Decoder))); } // static -scoped_ptr<GpuVideoDecodeAcceleratorFactoryImpl> +std::unique_ptr<GpuVideoDecodeAcceleratorFactoryImpl> GpuVideoDecodeAcceleratorFactoryImpl::CreateWithGLES2Decoder( const GetGLContextCallback& get_gl_context_cb, const MakeGLContextCurrentCallback& make_context_current_cb, const BindGLImageCallback& bind_image_cb, const GetGLES2DecoderCallback& get_gles2_decoder_cb) { - return make_scoped_ptr(new GpuVideoDecodeAcceleratorFactoryImpl( + return base::WrapUnique(new GpuVideoDecodeAcceleratorFactoryImpl( get_gl_context_cb, make_context_current_cb, bind_image_cb, get_gles2_decoder_cb)); } @@ -104,7 +105,7 @@ capabilities); } -scoped_ptr<media::VideoDecodeAccelerator> +std::unique_ptr<media::VideoDecodeAccelerator> GpuVideoDecodeAcceleratorFactoryImpl::CreateVDA( media::VideoDecodeAccelerator::Client* client, const media::VideoDecodeAccelerator::Config& config, @@ -118,7 +119,7 @@ // platform. This list is ordered by priority, from most to least preferred, // if applicable. This list must be in the same order as the querying order // in GetDecoderCapabilities() above. - using CreateVDAFp = scoped_ptr<media::VideoDecodeAccelerator> ( + using CreateVDAFp = std::unique_ptr<media::VideoDecodeAccelerator> ( GpuVideoDecodeAcceleratorFactoryImpl::*)(const gpu::GpuPreferences&) const; const CreateVDAFp create_vda_fps[] = { @@ -140,7 +141,7 @@ #endif }; - scoped_ptr<media::VideoDecodeAccelerator> vda; + std::unique_ptr<media::VideoDecodeAccelerator> vda; for (const auto& create_vda_function : create_vda_fps) { vda = (this->*create_vda_function)(gpu_preferences); @@ -152,10 +153,10 @@ } #if defined(OS_WIN) -scoped_ptr<media::VideoDecodeAccelerator> +std::unique_ptr<media::VideoDecodeAccelerator> GpuVideoDecodeAcceleratorFactoryImpl::CreateDXVAVDA( const gpu::GpuPreferences& gpu_preferences) const { - scoped_ptr<media::VideoDecodeAccelerator> decoder; + std::unique_ptr<media::VideoDecodeAccelerator> decoder; if (base::win::GetVersion() >= base::win::VERSION_WIN7) { DVLOG(0) << "Initializing DXVA HW decoder for windows."; decoder.reset(new DXVAVideoDecodeAccelerator( @@ -167,10 +168,10 @@ #endif #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) -scoped_ptr<media::VideoDecodeAccelerator> +std::unique_ptr<media::VideoDecodeAccelerator> GpuVideoDecodeAcceleratorFactoryImpl::CreateV4L2VDA( const gpu::GpuPreferences& gpu_preferences) const { - scoped_ptr<media::VideoDecodeAccelerator> decoder; + std::unique_ptr<media::VideoDecodeAccelerator> decoder; scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); if (device.get()) { decoder.reset(new V4L2VideoDecodeAccelerator( @@ -180,10 +181,10 @@ return decoder; } -scoped_ptr<media::VideoDecodeAccelerator> +std::unique_ptr<media::VideoDecodeAccelerator> GpuVideoDecodeAcceleratorFactoryImpl::CreateV4L2SVDA( const gpu::GpuPreferences& gpu_preferences) const { - scoped_ptr<media::VideoDecodeAccelerator> decoder; + std::unique_ptr<media::VideoDecodeAccelerator> decoder; scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); if (device.get()) { decoder.reset(new V4L2SliceVideoDecodeAccelerator( @@ -195,10 +196,10 @@ #endif #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) -scoped_ptr<media::VideoDecodeAccelerator> +std::unique_ptr<media::VideoDecodeAccelerator> GpuVideoDecodeAcceleratorFactoryImpl::CreateVaapiVDA( const gpu::GpuPreferences& gpu_preferences) const { - scoped_ptr<media::VideoDecodeAccelerator> decoder; + std::unique_ptr<media::VideoDecodeAccelerator> decoder; decoder.reset(new VaapiVideoDecodeAccelerator(make_context_current_cb_, bind_image_cb_)); return decoder; @@ -206,10 +207,10 @@ #endif #if defined(OS_MACOSX) -scoped_ptr<media::VideoDecodeAccelerator> +std::unique_ptr<media::VideoDecodeAccelerator> GpuVideoDecodeAcceleratorFactoryImpl::CreateVTVDA( const gpu::GpuPreferences& gpu_preferences) const { - scoped_ptr<media::VideoDecodeAccelerator> decoder; + std::unique_ptr<media::VideoDecodeAccelerator> decoder; decoder.reset( new VTVideoDecodeAccelerator(make_context_current_cb_, bind_image_cb_)); return decoder; @@ -217,10 +218,10 @@ #endif #if defined(OS_ANDROID) -scoped_ptr<media::VideoDecodeAccelerator> +std::unique_ptr<media::VideoDecodeAccelerator> GpuVideoDecodeAcceleratorFactoryImpl::CreateAndroidVDA( const gpu::GpuPreferences& gpu_preferences) const { - scoped_ptr<media::VideoDecodeAccelerator> decoder; + std::unique_ptr<media::VideoDecodeAccelerator> decoder; decoder.reset(new AndroidVideoDecodeAccelerator(make_context_current_cb_, get_gles2_decoder_cb_)); return decoder;
diff --git a/content/common/gpu/media/gpu_video_decode_accelerator_factory_impl.h b/content/common/gpu/media/gpu_video_decode_accelerator_factory_impl.h index 2d4c10b..ba093263b 100644 --- a/content/common/gpu/media/gpu_video_decode_accelerator_factory_impl.h +++ b/content/common/gpu/media/gpu_video_decode_accelerator_factory_impl.h
@@ -58,12 +58,12 @@ using GetGLES2DecoderCallback = base::Callback<base::WeakPtr<gpu::gles2::GLES2Decoder>(void)>; - static scoped_ptr<GpuVideoDecodeAcceleratorFactoryImpl> Create( + static std::unique_ptr<GpuVideoDecodeAcceleratorFactoryImpl> Create( const GetGLContextCallback& get_gl_context_cb, const MakeGLContextCurrentCallback& make_context_current_cb, const BindGLImageCallback& bind_image_cb); - static scoped_ptr<GpuVideoDecodeAcceleratorFactoryImpl> + static std::unique_ptr<GpuVideoDecodeAcceleratorFactoryImpl> CreateWithGLES2Decoder( const GetGLContextCallback& get_gl_context_cb, const MakeGLContextCurrentCallback& make_context_current_cb, @@ -73,7 +73,7 @@ static gpu::VideoDecodeAcceleratorCapabilities GetDecoderCapabilities( const gpu::GpuPreferences& gpu_preferences); - scoped_ptr<media::VideoDecodeAccelerator> CreateVDA( + std::unique_ptr<media::VideoDecodeAccelerator> CreateVDA( media::VideoDecodeAccelerator::Client* client, const media::VideoDecodeAccelerator::Config& config, const gpu::GpuPreferences& gpu_preferences); @@ -86,25 +86,25 @@ const GetGLES2DecoderCallback& get_gles2_decoder_cb); #if defined(OS_WIN) - scoped_ptr<media::VideoDecodeAccelerator> CreateDXVAVDA( + std::unique_ptr<media::VideoDecodeAccelerator> CreateDXVAVDA( const gpu::GpuPreferences& gpu_preferences) const; #endif #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) - scoped_ptr<media::VideoDecodeAccelerator> CreateV4L2VDA( + std::unique_ptr<media::VideoDecodeAccelerator> CreateV4L2VDA( const gpu::GpuPreferences& gpu_preferences) const; - scoped_ptr<media::VideoDecodeAccelerator> CreateV4L2SVDA( + std::unique_ptr<media::VideoDecodeAccelerator> CreateV4L2SVDA( const gpu::GpuPreferences& gpu_preferences) const; #endif #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) - scoped_ptr<media::VideoDecodeAccelerator> CreateVaapiVDA( + std::unique_ptr<media::VideoDecodeAccelerator> CreateVaapiVDA( const gpu::GpuPreferences& gpu_preferences) const; #endif #if defined(OS_MACOSX) - scoped_ptr<media::VideoDecodeAccelerator> CreateVTVDA( + std::unique_ptr<media::VideoDecodeAccelerator> CreateVTVDA( const gpu::GpuPreferences& gpu_preferences) const; #endif #if defined(OS_ANDROID) - scoped_ptr<media::VideoDecodeAccelerator> CreateAndroidVDA( + std::unique_ptr<media::VideoDecodeAccelerator> CreateAndroidVDA( const gpu::GpuPreferences& gpu_preferences) const; #endif
diff --git a/content/common/gpu/media/gpu_video_encode_accelerator.cc b/content/common/gpu/media/gpu_video_encode_accelerator.cc index 7b1457e8..eab2f941 100644 --- a/content/common/gpu/media/gpu_video_encode_accelerator.cc +++ b/content/common/gpu/media/gpu_video_encode_accelerator.cc
@@ -7,6 +7,7 @@ #include "base/callback.h" #include "base/command_line.h" #include "base/logging.h" +#include "base/memory/ptr_util.h" #include "base/memory/shared_memory.h" #include "base/numerics/safe_math.h" #include "base/sys_info.h" @@ -177,8 +178,8 @@ CreateVEAFps(gpu_preferences); for (size_t i = 0; i < create_vea_fps.size(); ++i) { - scoped_ptr<media::VideoEncodeAccelerator> - encoder = (*create_vea_fps[i])(); + std::unique_ptr<media::VideoEncodeAccelerator> encoder = + (*create_vea_fps[i])(); if (!encoder) continue; media::VideoEncodeAccelerator::SupportedProfiles vea_profiles = @@ -214,9 +215,9 @@ #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) // static -scoped_ptr<media::VideoEncodeAccelerator> +std::unique_ptr<media::VideoEncodeAccelerator> GpuVideoEncodeAccelerator::CreateV4L2VEA() { - scoped_ptr<media::VideoEncodeAccelerator> encoder; + std::unique_ptr<media::VideoEncodeAccelerator> encoder; scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kEncoder); if (device) encoder.reset(new V4L2VideoEncodeAccelerator(device)); @@ -226,27 +227,27 @@ #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) // static -scoped_ptr<media::VideoEncodeAccelerator> +std::unique_ptr<media::VideoEncodeAccelerator> GpuVideoEncodeAccelerator::CreateVaapiVEA() { - return make_scoped_ptr<media::VideoEncodeAccelerator>( + return base::WrapUnique<media::VideoEncodeAccelerator>( new VaapiVideoEncodeAccelerator()); } #endif #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC) // static -scoped_ptr<media::VideoEncodeAccelerator> +std::unique_ptr<media::VideoEncodeAccelerator> GpuVideoEncodeAccelerator::CreateAndroidVEA() { - return make_scoped_ptr<media::VideoEncodeAccelerator>( + return base::WrapUnique<media::VideoEncodeAccelerator>( new AndroidVideoEncodeAccelerator()); } #endif #if defined(OS_MACOSX) // static -scoped_ptr<media::VideoEncodeAccelerator> +std::unique_ptr<media::VideoEncodeAccelerator> GpuVideoEncodeAccelerator::CreateVTVEA() { - return make_scoped_ptr<media::VideoEncodeAccelerator>( + return base::WrapUnique<media::VideoEncodeAccelerator>( new VTVideoEncodeAccelerator()); } #endif @@ -260,7 +261,7 @@ // Wrap into a SharedMemory in the beginning, so that |params.buffer_handle| // is cleaned properly in case of an early return. - scoped_ptr<base::SharedMemory> shm( + std::unique_ptr<base::SharedMemory> shm( new base::SharedMemory(params.buffer_handle, true)); if (!encoder_) @@ -375,7 +376,7 @@ void GpuVideoEncodeAccelerator::EncodeFrameFinished( int32_t frame_id, - scoped_ptr<base::SharedMemory> shm) { + std::unique_ptr<base::SharedMemory> shm) { Send(new AcceleratedVideoEncoderHostMsg_NotifyInputDone(host_route_id_, frame_id)); // Just let |shm| fall out of scope.
diff --git a/content/common/gpu/media/gpu_video_encode_accelerator.h b/content/common/gpu/media/gpu_video_encode_accelerator.h index 2c2db293..738f764 100644 --- a/content/common/gpu/media/gpu_video_encode_accelerator.h +++ b/content/common/gpu/media/gpu_video_encode_accelerator.h
@@ -8,10 +8,10 @@ #include <stddef.h> #include <stdint.h> +#include <memory> #include <vector> #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "gpu/config/gpu_info.h" #include "gpu/ipc/service/gpu_command_buffer_stub.h" @@ -73,23 +73,23 @@ const gpu::GpuPreferences& gpu_preferences); private: - typedef scoped_ptr<media::VideoEncodeAccelerator>(*CreateVEAFp)(); + typedef std::unique_ptr<media::VideoEncodeAccelerator> (*CreateVEAFp)(); // Return a set of VEA Create function pointers applicable to the current // platform. static std::vector<CreateVEAFp> CreateVEAFps( const gpu::GpuPreferences& gpu_preferences); #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) - static scoped_ptr<media::VideoEncodeAccelerator> CreateV4L2VEA(); + static std::unique_ptr<media::VideoEncodeAccelerator> CreateV4L2VEA(); #endif #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) - static scoped_ptr<media::VideoEncodeAccelerator> CreateVaapiVEA(); + static std::unique_ptr<media::VideoEncodeAccelerator> CreateVaapiVEA(); #endif #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC) - static scoped_ptr<media::VideoEncodeAccelerator> CreateAndroidVEA(); + static std::unique_ptr<media::VideoEncodeAccelerator> CreateAndroidVEA(); #endif #if defined(OS_MACOSX) - static scoped_ptr<media::VideoEncodeAccelerator> CreateVTVEA(); + static std::unique_ptr<media::VideoEncodeAccelerator> CreateVTVEA(); #endif // IPC handlers, proxying media::VideoEncodeAccelerator for the renderer @@ -104,7 +104,7 @@ void OnDestroy(); void EncodeFrameFinished(int32_t frame_id, - scoped_ptr<base::SharedMemory> shm); + std::unique_ptr<base::SharedMemory> shm); void Send(IPC::Message* message); // Route ID to communicate with the host. @@ -116,7 +116,7 @@ gpu::GpuCommandBufferStub* const stub_; // Owned pointer to the underlying VideoEncodeAccelerator. - scoped_ptr<media::VideoEncodeAccelerator> encoder_; + std::unique_ptr<media::VideoEncodeAccelerator> encoder_; base::Callback<bool(void)> make_context_current_; // Video encoding parameters.
diff --git a/content/common/gpu/media/h264_decoder.h b/content/common/gpu/media/h264_decoder.h index 9d8b56f5..51c4f7d 100644 --- a/content/common/gpu/media/h264_decoder.h +++ b/content/common/gpu/media/h264_decoder.h
@@ -8,11 +8,11 @@ #include <stddef.h> #include <stdint.h> +#include <memory> #include <vector> #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "content/common/content_export.h" #include "content/common/gpu/media/accelerated_video_decoder.h" #include "content/common/gpu/media/h264_dpb.h" @@ -261,8 +261,8 @@ int curr_pps_id_; // Current NALU and slice header being processed. - scoped_ptr<media::H264NALU> curr_nalu_; - scoped_ptr<media::H264SliceHeader> curr_slice_hdr_; + std::unique_ptr<media::H264NALU> curr_nalu_; + std::unique_ptr<media::H264SliceHeader> curr_slice_hdr_; // Output picture size. gfx::Size pic_size_;
diff --git a/content/common/gpu/media/jpeg_decode_accelerator_unittest.cc b/content/common/gpu/media/jpeg_decode_accelerator_unittest.cc index 17bd648..53bc5d1 100644 --- a/content/common/gpu/media/jpeg_decode_accelerator_unittest.cc +++ b/content/common/gpu/media/jpeg_decode_accelerator_unittest.cc
@@ -109,7 +109,7 @@ // JpegClient doesn't own |test_image_files_|. const std::vector<TestImageFile*>& test_image_files_; - scoped_ptr<JpegDecodeAccelerator> decoder_; + std::unique_ptr<JpegDecodeAccelerator> decoder_; ClientState state_; // Used to notify another thread about the state. JpegClient does not own @@ -117,11 +117,11 @@ ClientStateNotification<ClientState>* note_; // Mapped memory of input file. - scoped_ptr<base::SharedMemory> in_shm_; + std::unique_ptr<base::SharedMemory> in_shm_; // Mapped memory of output buffer from hardware decoder. - scoped_ptr<base::SharedMemory> hw_out_shm_; + std::unique_ptr<base::SharedMemory> hw_out_shm_; // Mapped memory of output buffer from software decoder. - scoped_ptr<base::SharedMemory> sw_out_shm_; + std::unique_ptr<base::SharedMemory> sw_out_shm_; DISALLOW_COPY_AND_ASSIGN(JpegClient); }; @@ -323,15 +323,15 @@ void ReadTestJpegImage(base::FilePath& filename, TestImageFile* image_data); // Parsed data of |test_1280x720_jpeg_file_|. - scoped_ptr<TestImageFile> image_data_1280x720_black_; + std::unique_ptr<TestImageFile> image_data_1280x720_black_; // Parsed data of |test_640x368_jpeg_file_|. - scoped_ptr<TestImageFile> image_data_640x368_black_; + std::unique_ptr<TestImageFile> image_data_640x368_black_; // Parsed data of |test_640x360_jpeg_file_|. - scoped_ptr<TestImageFile> image_data_640x360_black_; + std::unique_ptr<TestImageFile> image_data_640x360_black_; // Parsed data of "peach_pi-1280x720.jpg". - scoped_ptr<TestImageFile> image_data_1280x720_default_; + std::unique_ptr<TestImageFile> image_data_1280x720_default_; // Parsed data of failure image. - scoped_ptr<TestImageFile> image_data_invalid_; + std::unique_ptr<TestImageFile> image_data_invalid_; // Parsed data from command line. ScopedVector<TestImageFile> image_data_user_;
diff --git a/content/common/gpu/media/media_channel.cc b/content/common/gpu/media/media_channel.cc index 7baeba0..e23e296 100644 --- a/content/common/gpu/media/media_channel.cc +++ b/content/common/gpu/media/media_channel.cc
@@ -14,7 +14,7 @@ namespace { void SendCreateJpegDecoderResult( - scoped_ptr<IPC::Message> reply_message, + std::unique_ptr<IPC::Message> reply_message, scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, base::WeakPtr<gpu::GpuChannel> channel, scoped_refptr<gpu::GpuChannelMessageFilter> filter, @@ -82,7 +82,7 @@ void MediaChannel::OnCreateJpegDecoder(int32_t route_id, IPC::Message* reply_msg) { - scoped_ptr<IPC::Message> msg(reply_msg); + std::unique_ptr<IPC::Message> msg(reply_msg); if (!jpeg_decoder_) { jpeg_decoder_.reset( new GpuJpegDecodeAccelerator(channel_, channel_->io_task_runner()));
diff --git a/content/common/gpu/media/media_channel.h b/content/common/gpu/media/media_channel.h index 7cfe0378..7f0bca8 100644 --- a/content/common/gpu/media/media_channel.h +++ b/content/common/gpu/media/media_channel.h
@@ -48,7 +48,7 @@ IPC::Message* reply_message); gpu::GpuChannel* const channel_; - scoped_ptr<GpuJpegDecodeAccelerator> jpeg_decoder_; + std::unique_ptr<GpuJpegDecodeAccelerator> jpeg_decoder_; DISALLOW_COPY_AND_ASSIGN(MediaChannel); };
diff --git a/content/common/gpu/media/media_service.cc b/content/common/gpu/media/media_service.cc index 89ec8b1f..b274589b 100644 --- a/content/common/gpu/media/media_service.cc +++ b/content/common/gpu/media/media_service.cc
@@ -24,7 +24,7 @@ void MediaService::AddChannel(int32_t client_id) { gpu::GpuChannel* gpu_channel = channel_manager_->LookupChannel(client_id); DCHECK(gpu_channel); - scoped_ptr<MediaChannel> media_channel(new MediaChannel(gpu_channel)); + std::unique_ptr<MediaChannel> media_channel(new MediaChannel(gpu_channel)); gpu_channel->SetUnhandledMessageListener(media_channel.get()); media_channels_.set(client_id, std::move(media_channel)); }
diff --git a/content/common/gpu/media/media_service.h b/content/common/gpu/media/media_service.h index 15dca822..eaa01e3f 100644 --- a/content/common/gpu/media/media_service.h +++ b/content/common/gpu/media/media_service.h
@@ -33,7 +33,8 @@ private: gpu::GpuChannelManager* const channel_manager_; - base::ScopedPtrHashMap<int32_t, scoped_ptr<MediaChannel>> media_channels_; + base::ScopedPtrHashMap<int32_t, std::unique_ptr<MediaChannel>> + media_channels_; DISALLOW_COPY_AND_ASSIGN(MediaService); };
diff --git a/content/common/gpu/media/rendering_helper.cc b/content/common/gpu/media/rendering_helper.cc index 2a19428b..13291bf 100644 --- a/content/common/gpu/media/rendering_helper.cc +++ b/content/common/gpu/media/rendering_helper.cc
@@ -148,7 +148,7 @@ ui::PlatformWindow* platform_window() const { return platform_window_.get(); } private: - scoped_ptr<ui::PlatformWindow> platform_window_; + std::unique_ptr<ui::PlatformWindow> platform_window_; gfx::AcceleratedWidget accelerated_widget_; DISALLOW_COPY_AND_ASSIGN(StubOzoneDelegate); @@ -517,7 +517,8 @@ // several frames here to warm up the rendering. void RenderingHelper::WarmUpRendering(int warm_up_iterations) { unsigned int texture_id; - scoped_ptr<GLubyte[]> emptyData(new GLubyte[screen_size_.GetArea() * 2]()); + std::unique_ptr<GLubyte[]> emptyData( + new GLubyte[screen_size_.GetArea() * 2]()); glGenTextures(1, &texture_id); glBindTexture(GL_TEXTURE_2D, texture_id); glTexImage2D(GL_TEXTURE_2D,
diff --git a/content/common/gpu/media/rendering_helper.h b/content/common/gpu/media/rendering_helper.h index 250d382..6a43b39 100644 --- a/content/common/gpu/media/rendering_helper.h +++ b/content/common/gpu/media/rendering_helper.h
@@ -193,10 +193,10 @@ #if defined(USE_OZONE) class StubOzoneDelegate; - scoped_ptr<StubOzoneDelegate> platform_window_delegate_; + std::unique_ptr<StubOzoneDelegate> platform_window_delegate_; #if defined(OS_CHROMEOS) - scoped_ptr<ui::DisplayConfigurator> display_configurator_; + std::unique_ptr<ui::DisplayConfigurator> display_configurator_; #endif #endif
diff --git a/content/common/gpu/media/v4l2_device.h b/content/common/gpu/media/v4l2_device.h index d66413c..ecba402 100644 --- a/content/common/gpu/media/v4l2_device.h +++ b/content/common/gpu/media/v4l2_device.h
@@ -49,7 +49,8 @@ }; // Creates and initializes an appropriate V4L2Device of |type| for the - // current platform and returns a scoped_ptr<V4L2Device> on success, or NULL. + // current platform and returns a std::unique_ptr<V4L2Device> on success, or + // NULL. static scoped_refptr<V4L2Device> Create(Type type); // Parameters and return value are the same as for the standard ioctl() system
diff --git a/content/common/gpu/media/v4l2_image_processor.cc b/content/common/gpu/media/v4l2_image_processor.cc index 340a1484..7dd7d1d 100644 --- a/content/common/gpu/media/v4l2_image_processor.cc +++ b/content/common/gpu/media/v4l2_image_processor.cc
@@ -174,7 +174,7 @@ const FrameReadyCB& cb) { DVLOG(3) << __func__ << ": ts=" << frame->timestamp().InMilliseconds(); - scoped_ptr<JobRecord> job_record(new JobRecord()); + std::unique_ptr<JobRecord> job_record(new JobRecord()); job_record->frame = frame; job_record->ready_cb = cb; @@ -185,7 +185,7 @@ base::Passed(&job_record))); } -void V4L2ImageProcessor::ProcessTask(scoped_ptr<JobRecord> job_record) { +void V4L2ImageProcessor::ProcessTask(std::unique_ptr<JobRecord> job_record) { DCHECK_EQ(device_thread_.message_loop(), base::MessageLoop::current()); input_queue_.push(make_linked_ptr(job_record.release()));
diff --git a/content/common/gpu/media/v4l2_image_processor.h b/content/common/gpu/media/v4l2_image_processor.h index 6c36697..4ff80e7 100644 --- a/content/common/gpu/media/v4l2_image_processor.h +++ b/content/common/gpu/media/v4l2_image_processor.h
@@ -110,7 +110,7 @@ void NotifyError(); void DestroyTask(); - void ProcessTask(scoped_ptr<JobRecord> job_record); + void ProcessTask(std::unique_ptr<JobRecord> job_record); void ServiceDeviceTask(); // Attempt to start/stop device_poll_thread_.
diff --git a/content/common/gpu/media/v4l2_jpeg_decode_accelerator.cc b/content/common/gpu/media/v4l2_jpeg_decode_accelerator.cc index 0121ead..c563afc 100644 --- a/content/common/gpu/media/v4l2_jpeg_decode_accelerator.cc +++ b/content/common/gpu/media/v4l2_jpeg_decode_accelerator.cc
@@ -247,7 +247,7 @@ return; } - scoped_ptr<JobRecord> job_record( + std::unique_ptr<JobRecord> job_record( new JobRecord(bitstream_buffer, video_frame)); decoder_task_runner_->PostTask( @@ -267,7 +267,8 @@ return false; } -void V4L2JpegDecodeAccelerator::DecodeTask(scoped_ptr<JobRecord> job_record) { +void V4L2JpegDecodeAccelerator::DecodeTask( + std::unique_ptr<JobRecord> job_record) { DCHECK(decoder_task_runner_->BelongsToCurrentThread()); if (!job_record->shm.Map()) { PLOG(ERROR) << __func__ << ": could not map bitstream_buffer";
diff --git a/content/common/gpu/media/v4l2_jpeg_decode_accelerator.h b/content/common/gpu/media/v4l2_jpeg_decode_accelerator.h index bef33b22..a7e0f65 100644 --- a/content/common/gpu/media/v4l2_jpeg_decode_accelerator.h +++ b/content/common/gpu/media/v4l2_jpeg_decode_accelerator.h
@@ -97,7 +97,7 @@ void PostNotifyError(int32_t bitstream_buffer_id, Error error); // Run on |decoder_thread_| to enqueue the coming frame. - void DecodeTask(scoped_ptr<JobRecord> job_record); + void DecodeTask(std::unique_ptr<JobRecord> job_record); // Run on |decoder_thread_| to dequeue last frame and enqueue next frame. // This task is triggered by DevicePollTask. |event_pending| means that device
diff --git a/content/common/gpu/media/v4l2_slice_video_decode_accelerator.cc b/content/common/gpu/media/v4l2_slice_video_decode_accelerator.cc index 8008723..50e6c59 100644 --- a/content/common/gpu/media/v4l2_slice_video_decode_accelerator.cc +++ b/content/common/gpu/media/v4l2_slice_video_decode_accelerator.cc
@@ -176,7 +176,7 @@ ~BitstreamBufferRef(); const base::WeakPtr<VideoDecodeAccelerator::Client> client; const scoped_refptr<base::SingleThreadTaskRunner> client_task_runner; - const scoped_ptr<SharedMemoryRegion> shm; + const std::unique_ptr<SharedMemoryRegion> shm; off_t bytes_used; const int32_t input_id; }; @@ -1210,7 +1210,7 @@ << " size=" << bitstream_buffer.size(); DCHECK(decoder_thread_task_runner_->BelongsToCurrentThread()); - scoped_ptr<BitstreamBufferRef> bitstream_record(new BitstreamBufferRef( + std::unique_ptr<BitstreamBufferRef> bitstream_record(new BitstreamBufferRef( decode_client_, decode_task_runner_, new SharedMemoryRegion(bitstream_buffer, true), bitstream_buffer.id())); if (!bitstream_record->shm->Map()) { @@ -1537,7 +1537,7 @@ return; } - scoped_ptr<EGLSyncKHRRef> egl_sync_ref( + std::unique_ptr<EGLSyncKHRRef> egl_sync_ref( new EGLSyncKHRRef(egl_display_, egl_sync)); decoder_thread_task_runner_->PostTask( FROM_HERE, @@ -1548,7 +1548,7 @@ void V4L2SliceVideoDecodeAccelerator::ReusePictureBufferTask( int32_t picture_buffer_id, - scoped_ptr<EGLSyncKHRRef> egl_sync_ref) { + std::unique_ptr<EGLSyncKHRRef> egl_sync_ref) { DVLOGF(3) << "picture_buffer_id=" << picture_buffer_id; DCHECK(decoder_thread_task_runner_->BelongsToCurrentThread()); @@ -2095,7 +2095,7 @@ // TODO(posciak): Don't add start code back here, but have it passed from // the parser. size_t data_copy_size = size + 3; - scoped_ptr<uint8_t[]> data_copy(new uint8_t[data_copy_size]); + std::unique_ptr<uint8_t[]> data_copy(new uint8_t[data_copy_size]); memset(data_copy.get(), 0, data_copy_size); data_copy[2] = 0x01; memcpy(data_copy.get() + 3, data, size);
diff --git a/content/common/gpu/media/v4l2_slice_video_decode_accelerator.h b/content/common/gpu/media/v4l2_slice_video_decode_accelerator.h index cc11da3..d4b0e2e 100644 --- a/content/common/gpu/media/v4l2_slice_video_decode_accelerator.h +++ b/content/common/gpu/media/v4l2_slice_video_decode_accelerator.h
@@ -8,13 +8,14 @@ #include <linux/videodev2.h> #include <stddef.h> #include <stdint.h> + +#include <memory> #include <queue> #include <vector> #include "base/macros.h" #include "base/memory/linked_ptr.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/synchronization/waitable_event.h" #include "base/threading/thread.h" @@ -259,7 +260,7 @@ // Auto-destruction reference for EGLSync (for message-passing). struct EGLSyncKHRRef; void ReusePictureBufferTask(int32_t picture_buffer_id, - scoped_ptr<EGLSyncKHRRef> egl_sync_ref); + std::unique_ptr<EGLSyncKHRRef> egl_sync_ref); // Called to actually send |dec_surface| to the client, after it is decoded // preserving the order in which it was scheduled via SurfaceReady(). @@ -294,7 +295,7 @@ // To expose client callbacks from VideoDecodeAccelerator. // NOTE: all calls to these objects *MUST* be executed on // child_task_runner_. - scoped_ptr<base::WeakPtrFactory<VideoDecodeAccelerator::Client>> + std::unique_ptr<base::WeakPtrFactory<VideoDecodeAccelerator::Client>> client_ptr_factory_; base::WeakPtr<VideoDecodeAccelerator::Client> client_; // Callbacks to |decode_client_| must be executed on |decode_task_runner_|. @@ -337,7 +338,7 @@ // Input queue of stream buffers coming from the client. std::queue<linked_ptr<BitstreamBufferRef>> decoder_input_queue_; // BitstreamBuffer currently being processed. - scoped_ptr<BitstreamBufferRef> decoder_current_bitstream_buffer_; + std::unique_ptr<BitstreamBufferRef> decoder_current_bitstream_buffer_; // Queue storing decode surfaces ready to be output as soon as they are // decoded. The surfaces must be output in order they are queued. @@ -355,11 +356,11 @@ // Hardware accelerators. // TODO(posciak): Try to have a superclass here if possible. - scoped_ptr<V4L2H264Accelerator> h264_accelerator_; - scoped_ptr<V4L2VP8Accelerator> vp8_accelerator_; + std::unique_ptr<V4L2H264Accelerator> h264_accelerator_; + std::unique_ptr<V4L2VP8Accelerator> vp8_accelerator_; // Codec-specific software decoder in use. - scoped_ptr<AcceleratedVideoDecoder> decoder_; + std::unique_ptr<AcceleratedVideoDecoder> decoder_; // Surfaces queued to device to keep references to them while decoded. using V4L2DecodeSurfaceByOutputId =
diff --git a/content/common/gpu/media/v4l2_video_decode_accelerator.cc b/content/common/gpu/media/v4l2_video_decode_accelerator.cc index 719dbf7..51104159 100644 --- a/content/common/gpu/media/v4l2_video_decode_accelerator.cc +++ b/content/common/gpu/media/v4l2_video_decode_accelerator.cc
@@ -66,12 +66,12 @@ BitstreamBufferRef( base::WeakPtr<Client>& client, scoped_refptr<base::SingleThreadTaskRunner>& client_task_runner, - scoped_ptr<SharedMemoryRegion> shm, + std::unique_ptr<SharedMemoryRegion> shm, int32_t input_id); ~BitstreamBufferRef(); const base::WeakPtr<Client> client; const scoped_refptr<base::SingleThreadTaskRunner> client_task_runner; - const scoped_ptr<SharedMemoryRegion> shm; + const std::unique_ptr<SharedMemoryRegion> shm; size_t bytes_used; const int32_t input_id; }; @@ -93,7 +93,7 @@ V4L2VideoDecodeAccelerator::BitstreamBufferRef::BitstreamBufferRef( base::WeakPtr<Client>& client, scoped_refptr<base::SingleThreadTaskRunner>& client_task_runner, - scoped_ptr<SharedMemoryRegion> shm, + std::unique_ptr<SharedMemoryRegion> shm, int32_t input_id) : client(client), client_task_runner(client_task_runner), @@ -419,8 +419,8 @@ } #endif - scoped_ptr<EGLSyncKHRRef> egl_sync_ref(new EGLSyncKHRRef( - egl_display_, egl_sync)); + std::unique_ptr<EGLSyncKHRRef> egl_sync_ref( + new EGLSyncKHRRef(egl_display_, egl_sync)); decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( &V4L2VideoDecodeAccelerator::ReusePictureBufferTask, base::Unretained(this), picture_buffer_id, base::Passed(&egl_sync_ref))); @@ -490,9 +490,9 @@ TRACE_EVENT1("Video Decoder", "V4L2VDA::DecodeTask", "input_id", bitstream_buffer.id()); - scoped_ptr<BitstreamBufferRef> bitstream_record(new BitstreamBufferRef( + std::unique_ptr<BitstreamBufferRef> bitstream_record(new BitstreamBufferRef( decode_client_, decode_task_runner_, - scoped_ptr<SharedMemoryRegion>( + std::unique_ptr<SharedMemoryRegion>( new SharedMemoryRegion(bitstream_buffer, true)), bitstream_buffer.id())); if (!bitstream_record->shm->Map()) { @@ -1086,7 +1086,7 @@ while (output_buffer_queued_count_ > 0) { DCHECK(output_streamon_); struct v4l2_buffer dqbuf; - scoped_ptr<struct v4l2_plane[]> planes( + std::unique_ptr<struct v4l2_plane[]> planes( new v4l2_plane[output_planes_count_]); memset(&dqbuf, 0, sizeof(dqbuf)); memset(planes.get(), 0, sizeof(struct v4l2_plane) * output_planes_count_); @@ -1190,7 +1190,7 @@ output_record.egl_sync = EGL_NO_SYNC_KHR; } struct v4l2_buffer qbuf; - scoped_ptr<struct v4l2_plane[]> qbuf_planes( + std::unique_ptr<struct v4l2_plane[]> qbuf_planes( new v4l2_plane[output_planes_count_]); memset(&qbuf, 0, sizeof(qbuf)); memset( @@ -1209,7 +1209,7 @@ void V4L2VideoDecodeAccelerator::ReusePictureBufferTask( int32_t picture_buffer_id, - scoped_ptr<EGLSyncKHRRef> egl_sync_ref) { + std::unique_ptr<EGLSyncKHRRef> egl_sync_ref) { DVLOG(3) << "ReusePictureBufferTask(): picture_buffer_id=" << picture_buffer_id; DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current());
diff --git a/content/common/gpu/media/v4l2_video_decode_accelerator.h b/content/common/gpu/media/v4l2_video_decode_accelerator.h index cb74956..a16af17 100644 --- a/content/common/gpu/media/v4l2_video_decode_accelerator.h +++ b/content/common/gpu/media/v4l2_video_decode_accelerator.h
@@ -12,6 +12,7 @@ #include <stddef.h> #include <stdint.h> +#include <memory> #include <queue> #include <vector> @@ -19,7 +20,6 @@ #include "base/macros.h" #include "base/memory/linked_ptr.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/synchronization/waitable_event.h" #include "base/threading/thread.h" #include "content/common/content_export.h" @@ -217,7 +217,7 @@ // object on the main (GPU process) thread; we will record this object so we // can wait on it before reusing the buffer. void ReusePictureBufferTask(int32_t picture_buffer_id, - scoped_ptr<EGLSyncKHRRef> egl_sync_ref); + std::unique_ptr<EGLSyncKHRRef> egl_sync_ref); // Flush() task. Child thread should not submit any more buffers until it // receives the NotifyFlushDone callback. This task will schedule an empty @@ -332,7 +332,7 @@ // To expose client callbacks from VideoDecodeAccelerator. // NOTE: all calls to these objects *MUST* be executed on // child_task_runner_. - scoped_ptr<base::WeakPtrFactory<Client> > client_ptr_factory_; + std::unique_ptr<base::WeakPtrFactory<Client>> client_ptr_factory_; base::WeakPtr<Client> client_; // Callbacks to |decode_client_| must be executed on |decode_task_runner_|. base::WeakPtr<Client> decode_client_; @@ -350,7 +350,7 @@ // Decoder state machine state. State decoder_state_; // BitstreamBuffer we're presently reading. - scoped_ptr<BitstreamBufferRef> decoder_current_bitstream_buffer_; + std::unique_ptr<BitstreamBufferRef> decoder_current_bitstream_buffer_; // The V4L2Device this class is operating upon. scoped_refptr<V4L2Device> device_; // FlushTask() and ResetTask() should not affect buffers that have been @@ -373,7 +373,7 @@ std::queue<linked_ptr<BitstreamBufferRef> > decoder_input_queue_; // For H264 decode, hardware requires that we send it frame-sized chunks. // We'll need to parse the stream. - scoped_ptr<media::H264Parser> decoder_h264_parser_; + std::unique_ptr<media::H264Parser> decoder_h264_parser_; // Set if the decoder has a pending incomplete frame in an input buffer. bool decoder_partial_frame_pending_;
diff --git a/content/common/gpu/media/v4l2_video_encode_accelerator.cc b/content/common/gpu/media/v4l2_video_encode_accelerator.cc index d724d8de..badb9da 100644 --- a/content/common/gpu/media/v4l2_video_encode_accelerator.cc +++ b/content/common/gpu/media/v4l2_video_encode_accelerator.cc
@@ -51,10 +51,10 @@ namespace content { struct V4L2VideoEncodeAccelerator::BitstreamBufferRef { - BitstreamBufferRef(int32_t id, scoped_ptr<SharedMemoryRegion> shm) + BitstreamBufferRef(int32_t id, std::unique_ptr<SharedMemoryRegion> shm) : id(id), shm(std::move(shm)) {} const int32_t id; - const scoped_ptr<SharedMemoryRegion> shm; + const std::unique_ptr<SharedMemoryRegion> shm; }; V4L2VideoEncodeAccelerator::InputRecord::InputRecord() : at_device(false) { @@ -221,13 +221,14 @@ return; } - scoped_ptr<SharedMemoryRegion> shm(new SharedMemoryRegion(buffer, false)); + std::unique_ptr<SharedMemoryRegion> shm( + new SharedMemoryRegion(buffer, false)); if (!shm->Map()) { NOTIFY_ERROR(kPlatformFailureError); return; } - scoped_ptr<BitstreamBufferRef> buffer_ref( + std::unique_ptr<BitstreamBufferRef> buffer_ref( new BitstreamBufferRef(buffer.id(), std::move(shm))); encoder_thread_.message_loop()->PostTask( FROM_HERE, @@ -380,7 +381,7 @@ } void V4L2VideoEncodeAccelerator::UseOutputBitstreamBufferTask( - scoped_ptr<BitstreamBufferRef> buffer_ref) { + std::unique_ptr<BitstreamBufferRef> buffer_ref) { DVLOG(3) << "UseOutputBitstreamBufferTask(): id=" << buffer_ref->id; DCHECK_EQ(encoder_thread_.message_loop(), base::MessageLoop::current());
diff --git a/content/common/gpu/media/v4l2_video_encode_accelerator.h b/content/common/gpu/media/v4l2_video_encode_accelerator.h index a3821af3..dcad1a9 100644 --- a/content/common/gpu/media/v4l2_video_encode_accelerator.h +++ b/content/common/gpu/media/v4l2_video_encode_accelerator.h
@@ -117,7 +117,8 @@ // Add a BitstreamBuffer to the queue of buffers ready to be used for encoder // output. - void UseOutputBitstreamBufferTask(scoped_ptr<BitstreamBufferRef> buffer_ref); + void UseOutputBitstreamBufferTask( + std::unique_ptr<BitstreamBufferRef> buffer_ref); // Device destruction task. void DestroyTask(); @@ -215,7 +216,7 @@ // We need to provide the stream header with every keyframe, to allow // midstream decoding restarts. Store it here. - scoped_ptr<uint8_t[]> stream_header_; + std::unique_ptr<uint8_t[]> stream_header_; size_t stream_header_size_; // Video frames ready to be encoded. @@ -248,7 +249,7 @@ std::vector<linked_ptr<BitstreamBufferRef> > encoder_output_queue_; // Image processor, if one is in use. - scoped_ptr<V4L2ImageProcessor> image_processor_; + std::unique_ptr<V4L2ImageProcessor> image_processor_; // This thread services tasks posted from the VEA API entry points by the // child thread and device service callbacks posted from the device thread. @@ -262,7 +263,7 @@ // NOTE: all calls to these objects *MUST* be executed on // child_task_runner_. base::WeakPtr<Client> client_; - scoped_ptr<base::WeakPtrFactory<Client> > client_ptr_factory_; + std::unique_ptr<base::WeakPtrFactory<Client>> client_ptr_factory_; // WeakPtr<> pointing to |this| for use in posting tasks from the // image_processor_ back to the child thread.
diff --git a/content/common/gpu/media/vaapi_jpeg_decode_accelerator.cc b/content/common/gpu/media/vaapi_jpeg_decode_accelerator.cc index a0cbc6e..64931f6f 100644 --- a/content/common/gpu/media/vaapi_jpeg_decode_accelerator.cc +++ b/content/common/gpu/media/vaapi_jpeg_decode_accelerator.cc
@@ -78,7 +78,7 @@ VaapiJpegDecodeAccelerator::DecodeRequest::DecodeRequest( int32_t bitstream_buffer_id, - scoped_ptr<SharedMemoryRegion> shm, + std::unique_ptr<SharedMemoryRegion> shm, const scoped_refptr<media::VideoFrame>& video_frame) : bitstream_buffer_id(bitstream_buffer_id), shm(std::move(shm)), @@ -219,7 +219,7 @@ } void VaapiJpegDecodeAccelerator::DecodeTask( - const scoped_ptr<DecodeRequest>& request) { + const std::unique_ptr<DecodeRequest>& request) { DVLOG(3) << __func__; DCHECK(decoder_task_runner_->BelongsToCurrentThread()); TRACE_EVENT0("jpeg", "DecodeTask"); @@ -292,7 +292,7 @@ << " size: " << bitstream_buffer.size(); // SharedMemoryRegion will take over the |bitstream_buffer.handle()|. - scoped_ptr<SharedMemoryRegion> shm( + std::unique_ptr<SharedMemoryRegion> shm( new SharedMemoryRegion(bitstream_buffer, true)); if (bitstream_buffer.id() < 0) { @@ -307,7 +307,7 @@ return; } - scoped_ptr<DecodeRequest> request( + std::unique_ptr<DecodeRequest> request( new DecodeRequest(bitstream_buffer.id(), std::move(shm), video_frame)); decoder_task_runner_->PostTask(
diff --git a/content/common/gpu/media/vaapi_jpeg_decode_accelerator.h b/content/common/gpu/media/vaapi_jpeg_decode_accelerator.h index 232b04d..6493c42 100644 --- a/content/common/gpu/media/vaapi_jpeg_decode_accelerator.h +++ b/content/common/gpu/media/vaapi_jpeg_decode_accelerator.h
@@ -49,12 +49,12 @@ // consumption, provided by the client. struct DecodeRequest { DecodeRequest(int32_t bitstream_buffer_id, - scoped_ptr<SharedMemoryRegion> shm, + std::unique_ptr<SharedMemoryRegion> shm, const scoped_refptr<media::VideoFrame>& video_frame); ~DecodeRequest(); int32_t bitstream_buffer_id; - scoped_ptr<SharedMemoryRegion> shm; + std::unique_ptr<SharedMemoryRegion> shm; scoped_refptr<media::VideoFrame> video_frame; }; @@ -65,7 +65,7 @@ void VideoFrameReady(int32_t bitstream_buffer_id); // Processes one decode |request|. - void DecodeTask(const scoped_ptr<DecodeRequest>& request); + void DecodeTask(const std::unique_ptr<DecodeRequest>& request); // Puts contents of |va_surface| into given |video_frame|, releases the // surface and passes the |input_buffer_id| of the resulting picture to @@ -95,7 +95,7 @@ // Comes after vaapi_wrapper_ to ensure its destructor is executed before // |vaapi_wrapper_| is destroyed. - scoped_ptr<VaapiJpegDecoder> decoder_; + std::unique_ptr<VaapiJpegDecoder> decoder_; base::Thread decoder_thread_; // Use this to post tasks to |decoder_thread_| instead of // |decoder_thread_.task_runner()| because the latter will be NULL once
diff --git a/content/common/gpu/media/vaapi_video_decode_accelerator.cc b/content/common/gpu/media/vaapi_video_decode_accelerator.cc index d8caeec9..4d59c37 100644 --- a/content/common/gpu/media/vaapi_video_decode_accelerator.cc +++ b/content/common/gpu/media/vaapi_video_decode_accelerator.cc
@@ -450,7 +450,7 @@ DVLOG(4) << "Mapping new input buffer id: " << bitstream_buffer.id() << " size: " << (int)bitstream_buffer.size(); - scoped_ptr<SharedMemoryRegion> shm( + std::unique_ptr<SharedMemoryRegion> shm( new SharedMemoryRegion(bitstream_buffer, true)); RETURN_AND_NOTIFY_ON_FAILURE(shm->Map(), "Failed to map input buffer", UNREADABLE_INPUT, );
diff --git a/content/common/gpu/media/vaapi_video_decode_accelerator.h b/content/common/gpu/media/vaapi_video_decode_accelerator.h index f9cfb903..5f95629 100644 --- a/content/common/gpu/media/vaapi_video_decode_accelerator.h +++ b/content/common/gpu/media/vaapi_video_decode_accelerator.h
@@ -210,7 +210,7 @@ ~InputBuffer(); int32_t id; - scoped_ptr<SharedMemoryRegion> shm; + std::unique_ptr<SharedMemoryRegion> shm; }; // Queue for incoming input buffers. @@ -273,15 +273,15 @@ // To expose client callbacks from VideoDecodeAccelerator. // NOTE: all calls to these objects *MUST* be executed on message_loop_. - scoped_ptr<base::WeakPtrFactory<Client> > client_ptr_factory_; + std::unique_ptr<base::WeakPtrFactory<Client>> client_ptr_factory_; base::WeakPtr<Client> client_; // Accelerators come after vaapi_wrapper_ to ensure they are destroyed first. - scoped_ptr<VaapiH264Accelerator> h264_accelerator_; - scoped_ptr<VaapiVP8Accelerator> vp8_accelerator_; - scoped_ptr<VaapiVP9Accelerator> vp9_accelerator_; + std::unique_ptr<VaapiH264Accelerator> h264_accelerator_; + std::unique_ptr<VaapiVP8Accelerator> vp8_accelerator_; + std::unique_ptr<VaapiVP9Accelerator> vp9_accelerator_; // After *_accelerator_ to ensure correct destruction order. - scoped_ptr<AcceleratedVideoDecoder> decoder_; + std::unique_ptr<AcceleratedVideoDecoder> decoder_; base::Thread decoder_thread_; // Use this to post tasks to |decoder_thread_| instead of
diff --git a/content/common/gpu/media/vaapi_video_encode_accelerator.cc b/content/common/gpu/media/vaapi_video_encode_accelerator.cc index 520d411e..86e6676 100644 --- a/content/common/gpu/media/vaapi_video_encode_accelerator.cc +++ b/content/common/gpu/media/vaapi_video_encode_accelerator.cc
@@ -101,10 +101,10 @@ }; struct VaapiVideoEncodeAccelerator::BitstreamBufferRef { - BitstreamBufferRef(int32_t id, scoped_ptr<SharedMemoryRegion> shm) + BitstreamBufferRef(int32_t id, std::unique_ptr<SharedMemoryRegion> shm) : id(id), shm(std::move(shm)) {} const int32_t id; - const scoped_ptr<SharedMemoryRegion> shm; + const std::unique_ptr<SharedMemoryRegion> shm; }; media::VideoEncodeAccelerator::SupportedProfiles @@ -674,13 +674,14 @@ return; } - scoped_ptr<SharedMemoryRegion> shm(new SharedMemoryRegion(buffer, false)); + std::unique_ptr<SharedMemoryRegion> shm( + new SharedMemoryRegion(buffer, false)); if (!shm->Map()) { NOTIFY_ERROR(kPlatformFailureError, "Failed mapping shared memory."); return; } - scoped_ptr<BitstreamBufferRef> buffer_ref( + std::unique_ptr<BitstreamBufferRef> buffer_ref( new BitstreamBufferRef(buffer.id(), std::move(shm))); encoder_thread_task_runner_->PostTask( @@ -690,7 +691,7 @@ } void VaapiVideoEncodeAccelerator::UseOutputBitstreamBufferTask( - scoped_ptr<BitstreamBufferRef> buffer_ref) { + std::unique_ptr<BitstreamBufferRef> buffer_ref) { DCHECK(encoder_thread_task_runner_->BelongsToCurrentThread()); DCHECK_NE(state_, kUninitialized);
diff --git a/content/common/gpu/media/vaapi_video_encode_accelerator.h b/content/common/gpu/media/vaapi_video_encode_accelerator.h index 9e6f39f..8cb709640 100644 --- a/content/common/gpu/media/vaapi_video_encode_accelerator.h +++ b/content/common/gpu/media/vaapi_video_encode_accelerator.h
@@ -94,7 +94,8 @@ void InitializeTask(); void EncodeTask(const scoped_refptr<media::VideoFrame>& frame, bool force_keyframe); - void UseOutputBitstreamBufferTask(scoped_ptr<BitstreamBufferRef> buffer_ref); + void UseOutputBitstreamBufferTask( + std::unique_ptr<BitstreamBufferRef> buffer_ref); void RequestEncodingParametersChangeTask(uint32_t bitrate, uint32_t framerate); void DestroyTask(); @@ -204,7 +205,7 @@ bool encoding_parameters_changed_; // Job currently being prepared for encode. - scoped_ptr<EncodeJob> current_encode_job_; + std::unique_ptr<EncodeJob> current_encode_job_; // Current SPS, PPS and their packed versions. Packed versions are their NALUs // in AnnexB format *without* emulation prevention three-byte sequences @@ -247,7 +248,7 @@ // To expose client callbacks from VideoEncodeAccelerator. // NOTE: all calls to these objects *MUST* be executed on // child_task_runner_. - scoped_ptr<base::WeakPtrFactory<Client> > client_ptr_factory_; + std::unique_ptr<base::WeakPtrFactory<Client>> client_ptr_factory_; base::WeakPtr<Client> client_; // WeakPtr to post from the encoder thread back to the ChildThread, as it may
diff --git a/content/common/gpu/media/video_decode_accelerator_unittest.cc b/content/common/gpu/media/video_decode_accelerator_unittest.cc index 87f4d0aa..b62a908 100644 --- a/content/common/gpu/media/video_decode_accelerator_unittest.cc +++ b/content/common/gpu/media/video_decode_accelerator_unittest.cc
@@ -263,7 +263,7 @@ private: base::Thread rendering_thread_; #if defined(USE_OZONE) - scoped_ptr<ui::OzoneGpuTestHelper> gpu_helper_; + std::unique_ptr<ui::OzoneGpuTestHelper> gpu_helper_; #endif DISALLOW_COPY_AND_ASSIGN(VideoDecodeAcceleratorTestEnvironment); @@ -392,11 +392,11 @@ size_t encoded_data_next_pos_to_decode_; int next_bitstream_buffer_id_; ClientStateNotification<ClientState>* note_; - scoped_ptr<VideoDecodeAccelerator> decoder_; + std::unique_ptr<VideoDecodeAccelerator> decoder_; base::WeakPtr<VideoDecodeAccelerator> weak_vda_; - scoped_ptr<base::WeakPtrFactory<VideoDecodeAccelerator>> + std::unique_ptr<base::WeakPtrFactory<VideoDecodeAccelerator>> weak_vda_ptr_factory_; - scoped_ptr<GpuVideoDecodeAcceleratorFactoryImpl> vda_factory_; + std::unique_ptr<GpuVideoDecodeAcceleratorFactoryImpl> vda_factory_; int remaining_play_throughs_; int reset_after_frame_num_; int delete_decoder_state_;
diff --git a/content/common/gpu/media/video_encode_accelerator_unittest.cc b/content/common/gpu/media/video_encode_accelerator_unittest.cc index 09f1c63..df5ad4f8 100644 --- a/content/common/gpu/media/video_encode_accelerator_unittest.cc +++ b/content/common/gpu/media/video_encode_accelerator_unittest.cc
@@ -400,7 +400,7 @@ class VideoEncodeAcceleratorTestEnvironment : public ::testing::Environment { public: VideoEncodeAcceleratorTestEnvironment( - scoped_ptr<base::FilePath::StringType> data, + std::unique_ptr<base::FilePath::StringType> data, const base::FilePath& log_path, bool run_at_fps, bool needs_encode_latency, @@ -455,9 +455,9 @@ ScopedVector<TestStream> test_streams_; private: - scoped_ptr<base::FilePath::StringType> test_stream_data_; + std::unique_ptr<base::FilePath::StringType> test_stream_data_; base::FilePath log_path_; - scoped_ptr<base::File> log_file_; + std::unique_ptr<base::File> log_file_; bool run_at_fps_; bool needs_encode_latency_; bool verify_all_output_; @@ -490,8 +490,9 @@ virtual ~StreamValidator() {} // Provide a StreamValidator instance for the given |profile|. - static scoped_ptr<StreamValidator> Create(media::VideoCodecProfile profile, - const FrameFoundCallback& frame_cb); + static std::unique_ptr<StreamValidator> Create( + media::VideoCodecProfile profile, + const FrameFoundCallback& frame_cb); // Process and verify contents of a bitstream buffer. virtual void ProcessStreamBuffer(const uint8_t* stream, size_t size) = 0; @@ -599,10 +600,10 @@ } // static -scoped_ptr<StreamValidator> StreamValidator::Create( +std::unique_ptr<StreamValidator> StreamValidator::Create( media::VideoCodecProfile profile, const FrameFoundCallback& frame_cb) { - scoped_ptr<StreamValidator> validator; + std::unique_ptr<StreamValidator> validator; if (IsH264(profile)) { validator.reset(new H264Validator(frame_cb)); @@ -637,7 +638,7 @@ enum State { UNINITIALIZED, INITIALIZED, DECODING, ERROR }; const media::VideoCodecProfile profile_; - scoped_ptr<media::FFmpegVideoDecoder> decoder_; + std::unique_ptr<media::FFmpegVideoDecoder> decoder_; media::VideoDecoder::DecodeCB decode_cb_; // Decode callback of an EOS buffer. media::VideoDecoder::DecodeCB eos_decode_cb_; @@ -814,10 +815,10 @@ // Return the number of encoded frames per second. double frames_per_second(); - scoped_ptr<media::VideoEncodeAccelerator> CreateFakeVEA(); - scoped_ptr<media::VideoEncodeAccelerator> CreateV4L2VEA(); - scoped_ptr<media::VideoEncodeAccelerator> CreateVaapiVEA(); - scoped_ptr<media::VideoEncodeAccelerator> CreateVTVEA(); + std::unique_ptr<media::VideoEncodeAccelerator> CreateFakeVEA(); + std::unique_ptr<media::VideoEncodeAccelerator> CreateV4L2VEA(); + std::unique_ptr<media::VideoEncodeAccelerator> CreateVaapiVEA(); + std::unique_ptr<media::VideoEncodeAccelerator> CreateVTVEA(); void SetState(ClientState new_state); @@ -881,7 +882,7 @@ void DecodeFailed(); ClientState state_; - scoped_ptr<VideoEncodeAccelerator> encoder_; + std::unique_ptr<VideoEncodeAccelerator> encoder_; TestStream* test_stream_; @@ -958,10 +959,10 @@ bool verify_output_; // Used to perform codec-specific sanity checks on the stream. - scoped_ptr<StreamValidator> stream_validator_; + std::unique_ptr<StreamValidator> stream_validator_; // Used to validate the encoded frame quality. - scoped_ptr<VideoFrameQualityValidator> quality_validator_; + std::unique_ptr<VideoFrameQualityValidator> quality_validator_; // The time when the first frame is submitted for encode. base::TimeTicks first_frame_start_time_; @@ -985,7 +986,7 @@ unsigned int requested_subsequent_framerate_; // The timer used to feed the encoder with the input frames. - scoped_ptr<base::RepeatingTimer> input_timer_; + std::unique_ptr<base::RepeatingTimer> input_timer_; }; VEAClient::VEAClient(TestStream* test_stream, @@ -1050,8 +1051,8 @@ VEAClient::~VEAClient() { LOG_ASSERT(!has_encoder()); } -scoped_ptr<media::VideoEncodeAccelerator> VEAClient::CreateFakeVEA() { - scoped_ptr<media::VideoEncodeAccelerator> encoder; +std::unique_ptr<media::VideoEncodeAccelerator> VEAClient::CreateFakeVEA() { + std::unique_ptr<media::VideoEncodeAccelerator> encoder; if (g_fake_encoder) { encoder.reset(new media::FakeVideoEncodeAccelerator( scoped_refptr<base::SingleThreadTaskRunner>( @@ -1060,8 +1061,8 @@ return encoder; } -scoped_ptr<media::VideoEncodeAccelerator> VEAClient::CreateV4L2VEA() { - scoped_ptr<media::VideoEncodeAccelerator> encoder; +std::unique_ptr<media::VideoEncodeAccelerator> VEAClient::CreateV4L2VEA() { + std::unique_ptr<media::VideoEncodeAccelerator> encoder; #if defined(OS_CHROMEOS) && (defined(ARCH_CPU_ARMEL) || \ (defined(USE_OZONE) && defined(USE_V4L2_CODEC))) scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kEncoder); @@ -1071,16 +1072,16 @@ return encoder; } -scoped_ptr<media::VideoEncodeAccelerator> VEAClient::CreateVaapiVEA() { - scoped_ptr<media::VideoEncodeAccelerator> encoder; +std::unique_ptr<media::VideoEncodeAccelerator> VEAClient::CreateVaapiVEA() { + std::unique_ptr<media::VideoEncodeAccelerator> encoder; #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) encoder.reset(new VaapiVideoEncodeAccelerator()); #endif return encoder; } -scoped_ptr<media::VideoEncodeAccelerator> VEAClient::CreateVTVEA() { - scoped_ptr<media::VideoEncodeAccelerator> encoder; +std::unique_ptr<media::VideoEncodeAccelerator> VEAClient::CreateVTVEA() { + std::unique_ptr<media::VideoEncodeAccelerator> encoder; #if defined(OS_MACOSX) encoder.reset(new VTVideoEncodeAccelerator()); #endif @@ -1091,12 +1092,8 @@ DCHECK(thread_checker_.CalledOnValidThread()); LOG_ASSERT(!has_encoder()); - scoped_ptr<media::VideoEncodeAccelerator> encoders[] = { - CreateFakeVEA(), - CreateV4L2VEA(), - CreateVaapiVEA(), - CreateVTVEA() - }; + std::unique_ptr<media::VideoEncodeAccelerator> encoders[] = { + CreateFakeVEA(), CreateV4L2VEA(), CreateVaapiVEA(), CreateVTVEA()}; DVLOG(1) << "Profile: " << test_stream_->requested_profile << ", initial bitrate: " << requested_bitrate_; @@ -1748,7 +1745,7 @@ base::ShadowingAtExitManager at_exit_manager; base::MessageLoop main_loop; - scoped_ptr<base::FilePath::StringType> test_stream_data( + std::unique_ptr<base::FilePath::StringType> test_stream_data( new base::FilePath::StringType( media::GetTestDataFilePath(content::g_default_in_filename).value() + content::g_default_in_parameters));
diff --git a/content/common/gpu/media/vp8_decoder.h b/content/common/gpu/media/vp8_decoder.h index 79d115c6..50b3d1c 100644 --- a/content/common/gpu/media/vp8_decoder.h +++ b/content/common/gpu/media/vp8_decoder.h
@@ -8,9 +8,10 @@ #include <stddef.h> #include <stdint.h> +#include <memory> + #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "content/common/gpu/media/accelerated_video_decoder.h" #include "content/common/gpu/media/vp8_picture.h" #include "media/filters/vp8_parser.h" @@ -88,7 +89,7 @@ media::Vp8Parser parser_; - scoped_ptr<media::Vp8FrameHeader> curr_frame_hdr_; + std::unique_ptr<media::Vp8FrameHeader> curr_frame_hdr_; scoped_refptr<VP8Picture> curr_pic_; scoped_refptr<VP8Picture> last_frame_; scoped_refptr<VP8Picture> golden_frame_;
diff --git a/content/common/gpu/media/vp9_decoder.cc b/content/common/gpu/media/vp9_decoder.cc index c1adc84b..1cb0dff 100644 --- a/content/common/gpu/media/vp9_decoder.cc +++ b/content/common/gpu/media/vp9_decoder.cc
@@ -49,7 +49,7 @@ while (1) { // Read a new frame header if one is not awaiting decoding already. if (!curr_frame_hdr_) { - scoped_ptr<media::Vp9FrameHeader> hdr(new media::Vp9FrameHeader()); + std::unique_ptr<media::Vp9FrameHeader> hdr(new media::Vp9FrameHeader()); media::Vp9Parser::Result res = parser_.ParseNextFrame(hdr.get()); switch (res) { case media::Vp9Parser::kOk:
diff --git a/content/common/gpu/media/vp9_decoder.h b/content/common/gpu/media/vp9_decoder.h index 55625e73..c513a94 100644 --- a/content/common/gpu/media/vp9_decoder.h +++ b/content/common/gpu/media/vp9_decoder.h
@@ -8,11 +8,11 @@ #include <stddef.h> #include <stdint.h> +#include <memory> #include <vector> #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "content/common/gpu/media/accelerated_video_decoder.h" #include "content/common/gpu/media/vp9_picture.h" #include "media/filters/vp9_parser.h" @@ -113,7 +113,7 @@ State state_; // Current frame header to be used in decoding the next picture. - scoped_ptr<media::Vp9FrameHeader> curr_frame_hdr_; + std::unique_ptr<media::Vp9FrameHeader> curr_frame_hdr_; // Reference frames currently in use. std::vector<scoped_refptr<VP9Picture>> ref_frames_;
diff --git a/content/common/gpu/media/vp9_picture.h b/content/common/gpu/media/vp9_picture.h index b6b1443..5d63ade 100644 --- a/content/common/gpu/media/vp9_picture.h +++ b/content/common/gpu/media/vp9_picture.h
@@ -5,9 +5,10 @@ #ifndef CONTENT_COMMON_GPU_MEDIA_VP9_PICTURE_H_ #define CONTENT_COMMON_GPU_MEDIA_VP9_PICTURE_H_ +#include <memory> + #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "media/filters/vp9_parser.h" namespace content { @@ -22,7 +23,7 @@ virtual V4L2VP9Picture* AsV4L2VP9Picture(); virtual VaapiVP9Picture* AsVaapiVP9Picture(); - scoped_ptr<media::Vp9FrameHeader> frame_hdr; + std::unique_ptr<media::Vp9FrameHeader> frame_hdr; protected: friend class base::RefCounted<VP9Picture>;
diff --git a/content/common/gpu/media/vt_video_decode_accelerator_mac.cc b/content/common/gpu/media/vt_video_decode_accelerator_mac.cc index 1571e834..4774f920 100644 --- a/content/common/gpu/media/vt_video_decode_accelerator_mac.cc +++ b/content/common/gpu/media/vt_video_decode_accelerator_mac.cc
@@ -2,23 +2,25 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <algorithm> +#include "content/common/gpu/media/vt_video_decode_accelerator_mac.h" #include <CoreVideo/CoreVideo.h> #include <OpenGL/CGLIOSurface.h> #include <OpenGL/gl.h> #include <stddef.h> +#include <algorithm> + #include "base/bind.h" #include "base/logging.h" #include "base/mac/mac_logging.h" #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/metrics/histogram_macros.h" #include "base/sys_byteorder.h" #include "base/sys_info.h" #include "base/thread_task_runner_handle.h" #include "base/version.h" -#include "content/common/gpu/media/vt_video_decode_accelerator_mac.h" #include "media/base/limits.h" #include "ui/gl/gl_context.h" #include "ui/gl/gl_image_io_surface.h" @@ -851,8 +853,8 @@ DCHECK_LE(1u, picture.texture_ids().size()); picture_info_map_.insert(std::make_pair( picture.id(), - make_scoped_ptr(new PictureInfo(picture.internal_texture_ids()[0], - picture.texture_ids()[0])))); + base::WrapUnique(new PictureInfo(picture.internal_texture_ids()[0], + picture.texture_ids()[0])))); } // Pictures are not marked as uncleared until after this method returns, and
diff --git a/content/common/gpu/media/vt_video_decode_accelerator_mac.h b/content/common/gpu/media/vt_video_decode_accelerator_mac.h index 22fc8b1..3badb07 100644 --- a/content/common/gpu/media/vt_video_decode_accelerator_mac.h +++ b/content/common/gpu/media/vt_video_decode_accelerator_mac.h
@@ -235,7 +235,7 @@ std::set<int32_t> assigned_picture_ids_; // Texture IDs and image buffers of assigned pictures. - std::map<int32_t, scoped_ptr<PictureInfo>> picture_info_map_; + std::map<int32_t, std::unique_ptr<PictureInfo>> picture_info_map_; // Pictures ready to be rendered to. std::vector<int32_t> available_picture_ids_;
diff --git a/content/common/gpu/media/vt_video_encode_accelerator_mac.cc b/content/common/gpu/media/vt_video_encode_accelerator_mac.cc index 71c80ef..f22db09 100644 --- a/content/common/gpu/media/vt_video_encode_accelerator_mac.cc +++ b/content/common/gpu/media/vt_video_encode_accelerator_mac.cc
@@ -50,11 +50,11 @@ struct VTVideoEncodeAccelerator::BitstreamBufferRef { BitstreamBufferRef(int32_t id, - scoped_ptr<base::SharedMemory> shm, + std::unique_ptr<base::SharedMemory> shm, size_t size) : id(id), shm(std::move(shm)), size(size) {} const int32_t id; - const scoped_ptr<base::SharedMemory> shm; + const std::unique_ptr<base::SharedMemory> shm; const size_t size; private: @@ -187,7 +187,7 @@ return; } - scoped_ptr<base::SharedMemory> shm( + std::unique_ptr<base::SharedMemory> shm( new base::SharedMemory(buffer.handle(), false)); if (!shm->Map(buffer.size())) { DLOG(ERROR) << "Failed mapping shared memory."; @@ -195,7 +195,7 @@ return; } - scoped_ptr<BitstreamBufferRef> buffer_ref( + std::unique_ptr<BitstreamBufferRef> buffer_ref( new BitstreamBufferRef(buffer.id(), std::move(shm), buffer.size())); encoder_thread_task_runner_->PostTask( @@ -260,8 +260,8 @@ frame->timestamp().InMicroseconds(), USEC_PER_SEC); // Wrap information we'll need after the frame is encoded in a heap object. // We'll get the pointer back from the VideoToolbox completion callback. - scoped_ptr<InProgressFrameEncode> request(new InProgressFrameEncode( - frame->timestamp(), ref_time)); + std::unique_ptr<InProgressFrameEncode> request( + new InProgressFrameEncode(frame->timestamp(), ref_time)); // We can pass the ownership of |request| to the encode callback if // successful. Otherwise let it fall out of scope. @@ -278,12 +278,12 @@ } void VTVideoEncodeAccelerator::UseOutputBitstreamBufferTask( - scoped_ptr<BitstreamBufferRef> buffer_ref) { + std::unique_ptr<BitstreamBufferRef> buffer_ref) { DCHECK(encoder_thread_task_runner_->BelongsToCurrentThread()); // If there is already EncodeOutput waiting, copy its output first. if (!encoder_output_queue_.empty()) { - scoped_ptr<VTVideoEncodeAccelerator::EncodeOutput> encode_output = + std::unique_ptr<VTVideoEncodeAccelerator::EncodeOutput> encode_output = std::move(encoder_output_queue_.front()); encoder_output_queue_.pop_front(); ReturnBitstreamBuffer(std::move(encode_output), std::move(buffer_ref)); @@ -356,13 +356,13 @@ // Release InProgressFrameEncode, since we don't have support to return // timestamps at this point. - scoped_ptr<InProgressFrameEncode> request( + std::unique_ptr<InProgressFrameEncode> request( reinterpret_cast<InProgressFrameEncode*>(request_opaque)); request.reset(); // EncodeOutput holds onto CMSampleBufferRef when posting task between // threads. - scoped_ptr<EncodeOutput> encode_output(new EncodeOutput(info, sbuf)); + std::unique_ptr<EncodeOutput> encode_output(new EncodeOutput(info, sbuf)); // This method is NOT called on |encoder_thread_|, so we still need to // post a task back to it to do work. @@ -374,7 +374,7 @@ void VTVideoEncodeAccelerator::CompressionCallbackTask( OSStatus status, - scoped_ptr<EncodeOutput> encode_output) { + std::unique_ptr<EncodeOutput> encode_output) { DCHECK(encoder_thread_task_runner_->BelongsToCurrentThread()); if (status != noErr) { @@ -390,15 +390,15 @@ return; } - scoped_ptr<VTVideoEncodeAccelerator::BitstreamBufferRef> buffer_ref = + std::unique_ptr<VTVideoEncodeAccelerator::BitstreamBufferRef> buffer_ref = std::move(bitstream_buffer_queue_.front()); bitstream_buffer_queue_.pop_front(); ReturnBitstreamBuffer(std::move(encode_output), std::move(buffer_ref)); } void VTVideoEncodeAccelerator::ReturnBitstreamBuffer( - scoped_ptr<EncodeOutput> encode_output, - scoped_ptr<VTVideoEncodeAccelerator::BitstreamBufferRef> buffer_ref) { + std::unique_ptr<EncodeOutput> encode_output, + std::unique_ptr<VTVideoEncodeAccelerator::BitstreamBufferRef> buffer_ref) { DVLOG(3) << __FUNCTION__; DCHECK(encoder_thread_task_runner_->BelongsToCurrentThread());
diff --git a/content/common/gpu/media/vt_video_encode_accelerator_mac.h b/content/common/gpu/media/vt_video_encode_accelerator_mac.h index aa4b37ed..adb2584 100644 --- a/content/common/gpu/media/vt_video_encode_accelerator_mac.h +++ b/content/common/gpu/media/vt_video_encode_accelerator_mac.h
@@ -54,7 +54,8 @@ // Encoding tasks to be run on |encoder_thread_|. void EncodeTask(const scoped_refptr<media::VideoFrame>& frame, bool force_keyframe); - void UseOutputBitstreamBufferTask(scoped_ptr<BitstreamBufferRef> buffer_ref); + void UseOutputBitstreamBufferTask( + std::unique_ptr<BitstreamBufferRef> buffer_ref); void RequestEncodingParametersChangeTask(uint32_t bitrate, uint32_t framerate); void DestroyTask(); @@ -69,12 +70,12 @@ VTEncodeInfoFlags info, CMSampleBufferRef sbuf); void CompressionCallbackTask(OSStatus status, - scoped_ptr<EncodeOutput> encode_output); + std::unique_ptr<EncodeOutput> encode_output); // Copy CMSampleBuffer into a BitstreamBuffer and return it to the |client_|. void ReturnBitstreamBuffer( - scoped_ptr<EncodeOutput> encode_output, - scoped_ptr<VTVideoEncodeAccelerator::BitstreamBufferRef> buffer_ref); + std::unique_ptr<EncodeOutput> encode_output, + std::unique_ptr<VTVideoEncodeAccelerator::BitstreamBufferRef> buffer_ref); // Reset the encoder's compression session by destroying the existing one // using DestroyCompressionSession() and creating a new one. The new session @@ -106,10 +107,10 @@ int32_t target_bitrate_; // Bitstream buffers ready to be used to return encoded output as a FIFO. - std::deque<scoped_ptr<BitstreamBufferRef>> bitstream_buffer_queue_; + std::deque<std::unique_ptr<BitstreamBufferRef>> bitstream_buffer_queue_; // EncodeOutput needs to be copied into a BitstreamBufferRef as a FIFO. - std::deque<scoped_ptr<EncodeOutput>> encoder_output_queue_; + std::deque<std::unique_ptr<EncodeOutput>> encoder_output_queue_; // Our original calling task runner for the child thread. const scoped_refptr<base::SingleThreadTaskRunner> client_task_runner_; @@ -118,7 +119,7 @@ // NOTE: all calls to this object *MUST* be executed on // |client_task_runner_|. base::WeakPtr<Client> client_; - scoped_ptr<base::WeakPtrFactory<Client> > client_ptr_factory_; + std::unique_ptr<base::WeakPtrFactory<Client>> client_ptr_factory_; // Thread checker to enforce that this object is used on a specific thread. // It is pinned on |client_task_runner_| thread.
diff --git a/content/common/host_discardable_shared_memory_manager.cc b/content/common/host_discardable_shared_memory_manager.cc index d8d141cd..2168e0a 100644 --- a/content/common/host_discardable_shared_memory_manager.cc +++ b/content/common/host_discardable_shared_memory_manager.cc
@@ -14,6 +14,7 @@ #include "base/lazy_instance.h" #include "base/macros.h" #include "base/memory/discardable_memory.h" +#include "base/memory/ptr_util.h" #include "base/numerics/safe_math.h" #include "base/process/memory.h" #include "base/strings/string_number_conversions.h" @@ -40,8 +41,9 @@ class DiscardableMemoryImpl : public base::DiscardableMemory { public: - DiscardableMemoryImpl(scoped_ptr<base::DiscardableSharedMemory> shared_memory, - const base::Closure& deleted_callback) + DiscardableMemoryImpl( + std::unique_ptr<base::DiscardableSharedMemory> shared_memory, + const base::Closure& deleted_callback) : shared_memory_(std::move(shared_memory)), deleted_callback_(deleted_callback), is_locked_(true) {} @@ -88,7 +90,7 @@ } private: - scoped_ptr<base::DiscardableSharedMemory> shared_memory_; + std::unique_ptr<base::DiscardableSharedMemory> shared_memory_; const base::Closure deleted_callback_; bool is_locked_; @@ -154,7 +156,7 @@ } // namespace HostDiscardableSharedMemoryManager::MemorySegment::MemorySegment( - scoped_ptr<base::DiscardableSharedMemory> memory) + std::unique_ptr<base::DiscardableSharedMemory> memory) : memory_(std::move(memory)) {} HostDiscardableSharedMemoryManager::MemorySegment::~MemorySegment() { @@ -188,7 +190,7 @@ return g_discardable_shared_memory_manager.Pointer(); } -scoped_ptr<base::DiscardableMemory> +std::unique_ptr<base::DiscardableMemory> HostDiscardableSharedMemoryManager::AllocateLockedDiscardableMemory( size_t size) { // TODO(reveman): Temporary diagnostics for http://crbug.com/577786. @@ -204,13 +206,13 @@ AllocateLockedDiscardableSharedMemory(current_process_handle, ChildProcessHost::kInvalidUniqueID, size, new_id, &handle); - scoped_ptr<base::DiscardableSharedMemory> memory( + std::unique_ptr<base::DiscardableSharedMemory> memory( new base::DiscardableSharedMemory(handle)); if (!memory->Map(size)) base::TerminateBecauseOutOfMemory(size); // Close file descriptor to avoid running out. memory->Close(); - return make_scoped_ptr(new DiscardableMemoryImpl( + return base::WrapUnique(new DiscardableMemoryImpl( std::move(memory), base::Bind( &HostDiscardableSharedMemoryManager::DeletedDiscardableSharedMemory, @@ -364,7 +366,7 @@ if (bytes_allocated_ > limit) ReduceMemoryUsageUntilWithinLimit(limit); - scoped_ptr<base::DiscardableSharedMemory> memory( + std::unique_ptr<base::DiscardableSharedMemory> memory( new base::DiscardableSharedMemory); if (!memory->CreateAndMap(size)) { *shared_memory_handle = base::SharedMemory::NULLHandle();
diff --git a/content/common/host_discardable_shared_memory_manager.h b/content/common/host_discardable_shared_memory_manager.h index 834afe75..bca3384 100644 --- a/content/common/host_discardable_shared_memory_manager.h +++ b/content/common/host_discardable_shared_memory_manager.h
@@ -8,6 +8,7 @@ #include <stddef.h> #include <stdint.h> +#include <memory> #include <vector> #include "base/callback.h" @@ -18,7 +19,6 @@ #include "base/memory/discardable_shared_memory.h" #include "base/memory/memory_pressure_listener.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/shared_memory.h" #include "base/memory/weak_ptr.h" #include "base/process/process_handle.h" @@ -44,7 +44,7 @@ static HostDiscardableSharedMemoryManager* current(); // Overridden from base::DiscardableMemoryAllocator: - scoped_ptr<base::DiscardableMemory> AllocateLockedDiscardableMemory( + std::unique_ptr<base::DiscardableMemory> AllocateLockedDiscardableMemory( size_t size) override; // Overridden from base::trace_event::MemoryDumpProvider: @@ -83,7 +83,7 @@ private: class MemorySegment : public base::RefCountedThreadSafe<MemorySegment> { public: - MemorySegment(scoped_ptr<base::DiscardableSharedMemory> memory); + MemorySegment(std::unique_ptr<base::DiscardableSharedMemory> memory); base::DiscardableSharedMemory* memory() const { return memory_.get(); } @@ -92,7 +92,7 @@ ~MemorySegment(); - scoped_ptr<base::DiscardableSharedMemory> memory_; + std::unique_ptr<base::DiscardableSharedMemory> memory_; DISALLOW_COPY_AND_ASSIGN(MemorySegment); }; @@ -133,7 +133,7 @@ MemorySegmentVector segments_; size_t memory_limit_; size_t bytes_allocated_; - scoped_ptr<base::MemoryPressureListener> memory_pressure_listener_; + std::unique_ptr<base::MemoryPressureListener> memory_pressure_listener_; scoped_refptr<base::SingleThreadTaskRunner> enforce_memory_policy_task_runner_; base::Closure enforce_memory_policy_callback_;
diff --git a/content/common/host_discardable_shared_memory_manager_unittest.cc b/content/common/host_discardable_shared_memory_manager_unittest.cc index 963ce0d..fcd39ba 100644 --- a/content/common/host_discardable_shared_memory_manager_unittest.cc +++ b/content/common/host_discardable_shared_memory_manager_unittest.cc
@@ -66,7 +66,7 @@ // HostDiscardableSharedMemoryManager requires a message loop. base::MessageLoop message_loop_; - scoped_ptr<TestHostDiscardableSharedMemoryManager> manager_; + std::unique_ptr<TestHostDiscardableSharedMemoryManager> manager_; }; TEST_F(HostDiscardableSharedMemoryManagerTest, AllocateForChild) { @@ -249,7 +249,7 @@ // HostDiscardableSharedMemoryManager requires a message loop. base::MessageLoop message_loop_; - scoped_ptr<HostDiscardableSharedMemoryManager> manager_; + std::unique_ptr<HostDiscardableSharedMemoryManager> manager_; }; class SetMemoryLimitRunner : public base::DelegateSimpleThread::Delegate {
diff --git a/content/common/host_shared_bitmap_manager.cc b/content/common/host_shared_bitmap_manager.cc index e666f9b..2533cf16 100644 --- a/content/common/host_shared_bitmap_manager.cc +++ b/content/common/host_shared_bitmap_manager.cc
@@ -5,10 +5,12 @@ #include "content/common/host_shared_bitmap_manager.h" #include <stdint.h> + #include <utility> #include "base/lazy_instance.h" #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/memory/ref_counted.h" #include "base/strings/string_number_conversions.h" #include "base/trace_event/process_memory_dump.h" @@ -25,8 +27,8 @@ : process_handle(process_handle), buffer_size(buffer_size) {} base::ProcessHandle process_handle; - scoped_ptr<base::SharedMemory> memory; - scoped_ptr<uint8_t[]> pixels; + std::unique_ptr<base::SharedMemory> memory; + std::unique_ptr<uint8_t[]> pixels; size_t buffer_size; private: @@ -115,50 +117,50 @@ return g_shared_memory_manager.Pointer(); } -scoped_ptr<cc::SharedBitmap> HostSharedBitmapManager::AllocateSharedBitmap( +std::unique_ptr<cc::SharedBitmap> HostSharedBitmapManager::AllocateSharedBitmap( const gfx::Size& size) { base::AutoLock lock(lock_); size_t bitmap_size; if (!cc::SharedBitmap::SizeInBytes(size, &bitmap_size)) - return scoped_ptr<cc::SharedBitmap>(); + return std::unique_ptr<cc::SharedBitmap>(); scoped_refptr<BitmapData> data( new BitmapData(base::GetCurrentProcessHandle(), bitmap_size)); // Bitmaps allocated in host don't need to be shared to other processes, so // allocate them with new instead. - data->pixels = scoped_ptr<uint8_t[]>(new uint8_t[bitmap_size]); + data->pixels = std::unique_ptr<uint8_t[]>(new uint8_t[bitmap_size]); cc::SharedBitmapId id = cc::SharedBitmap::GenerateId(); handle_map_[id] = data; - return make_scoped_ptr( + return base::WrapUnique( new HostSharedBitmap(data->pixels.get(), data, id, this)); } -scoped_ptr<cc::SharedBitmap> HostSharedBitmapManager::GetSharedBitmapFromId( - const gfx::Size& size, - const cc::SharedBitmapId& id) { +std::unique_ptr<cc::SharedBitmap> +HostSharedBitmapManager::GetSharedBitmapFromId(const gfx::Size& size, + const cc::SharedBitmapId& id) { base::AutoLock lock(lock_); BitmapMap::iterator it = handle_map_.find(id); if (it == handle_map_.end()) - return scoped_ptr<cc::SharedBitmap>(); + return std::unique_ptr<cc::SharedBitmap>(); BitmapData* data = it->second.get(); size_t bitmap_size; if (!cc::SharedBitmap::SizeInBytes(size, &bitmap_size) || bitmap_size > data->buffer_size) - return scoped_ptr<cc::SharedBitmap>(); + return std::unique_ptr<cc::SharedBitmap>(); if (data->pixels) { - return make_scoped_ptr( + return base::WrapUnique( new HostSharedBitmap(data->pixels.get(), data, id, nullptr)); } if (!data->memory->memory()) { - return scoped_ptr<cc::SharedBitmap>(); + return std::unique_ptr<cc::SharedBitmap>(); } - return make_scoped_ptr(new HostSharedBitmap( + return base::WrapUnique(new HostSharedBitmap( static_cast<uint8_t*>(data->memory->memory()), data, id, nullptr)); } @@ -202,8 +204,7 @@ new BitmapData(process_handle, buffer_size)); handle_map_[id] = data; - data->memory = - make_scoped_ptr(new base::SharedMemory(handle, false)); + data->memory = base::WrapUnique(new base::SharedMemory(handle, false)); data->memory->Map(data->buffer_size); data->memory->Close(); return true; @@ -219,7 +220,7 @@ *shared_memory_handle = base::SharedMemory::NULLHandle(); return; } - scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory); + std::unique_ptr<base::SharedMemory> shared_memory(new base::SharedMemory); if (!shared_memory->CreateAndMapAnonymous(buffer_size)) { LOG(ERROR) << "Cannot create shared memory buffer"; *shared_memory_handle = base::SharedMemory::NULLHandle();
diff --git a/content/common/host_shared_bitmap_manager.h b/content/common/host_shared_bitmap_manager.h index 6bfb42e..c96e1c6 100644 --- a/content/common/host_shared_bitmap_manager.h +++ b/content/common/host_shared_bitmap_manager.h
@@ -8,13 +8,13 @@ #include <stddef.h> #include <map> +#include <memory> #include <set> #include "base/containers/hash_tables.h" #include "base/hash.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/shared_memory.h" #include "base/synchronization/lock.h" #include "base/trace_event/memory_dump_provider.h" @@ -71,9 +71,9 @@ static HostSharedBitmapManager* current(); // cc::SharedBitmapManager implementation. - scoped_ptr<cc::SharedBitmap> AllocateSharedBitmap( + std::unique_ptr<cc::SharedBitmap> AllocateSharedBitmap( const gfx::Size& size) override; - scoped_ptr<cc::SharedBitmap> GetSharedBitmapFromId( + std::unique_ptr<cc::SharedBitmap> GetSharedBitmapFromId( const gfx::Size& size, const cc::SharedBitmapId&) override;
diff --git a/content/common/host_shared_bitmap_manager_unittest.cc b/content/common/host_shared_bitmap_manager_unittest.cc index 63bfbed1..16cb139 100644 --- a/content/common/host_shared_bitmap_manager_unittest.cc +++ b/content/common/host_shared_bitmap_manager_unittest.cc
@@ -14,14 +14,14 @@ class HostSharedBitmapManagerTest : public testing::Test { protected: void SetUp() override { manager_.reset(new HostSharedBitmapManager()); } - scoped_ptr<HostSharedBitmapManager> manager_; + std::unique_ptr<HostSharedBitmapManager> manager_; }; TEST_F(HostSharedBitmapManagerTest, TestCreate) { gfx::Size bitmap_size(1, 1); size_t size_in_bytes; EXPECT_TRUE(cc::SharedBitmap::SizeInBytes(bitmap_size, &size_in_bytes)); - scoped_ptr<base::SharedMemory> bitmap(new base::SharedMemory()); + std::unique_ptr<base::SharedMemory> bitmap(new base::SharedMemory()); bitmap->CreateAndMapAnonymous(size_in_bytes); memset(bitmap->memory(), 0xff, size_in_bytes); cc::SharedBitmapId id = cc::SharedBitmap::GenerateId(); @@ -32,35 +32,35 @@ client.ChildAllocatedSharedBitmap(size_in_bytes, handle, base::GetCurrentProcessHandle(), id); - scoped_ptr<cc::SharedBitmap> large_bitmap; + std::unique_ptr<cc::SharedBitmap> large_bitmap; large_bitmap = manager_->GetSharedBitmapFromId(gfx::Size(1024, 1024), id); EXPECT_TRUE(large_bitmap.get() == NULL); - scoped_ptr<cc::SharedBitmap> very_large_bitmap; + std::unique_ptr<cc::SharedBitmap> very_large_bitmap; very_large_bitmap = manager_->GetSharedBitmapFromId(gfx::Size(1, (1 << 30) | 1), id); EXPECT_TRUE(very_large_bitmap.get() == NULL); - scoped_ptr<cc::SharedBitmap> negative_size_bitmap; + std::unique_ptr<cc::SharedBitmap> negative_size_bitmap; negative_size_bitmap = manager_->GetSharedBitmapFromId(gfx::Size(-1, 1024), id); EXPECT_TRUE(negative_size_bitmap.get() == NULL); cc::SharedBitmapId id2 = cc::SharedBitmap::GenerateId(); - scoped_ptr<cc::SharedBitmap> invalid_bitmap; + std::unique_ptr<cc::SharedBitmap> invalid_bitmap; invalid_bitmap = manager_->GetSharedBitmapFromId(bitmap_size, id2); EXPECT_TRUE(invalid_bitmap.get() == NULL); - scoped_ptr<cc::SharedBitmap> shared_bitmap; + std::unique_ptr<cc::SharedBitmap> shared_bitmap; shared_bitmap = manager_->GetSharedBitmapFromId(bitmap_size, id); ASSERT_TRUE(shared_bitmap.get() != NULL); EXPECT_EQ(memcmp(shared_bitmap->pixels(), bitmap->memory(), 4), 0); - scoped_ptr<cc::SharedBitmap> large_bitmap2; + std::unique_ptr<cc::SharedBitmap> large_bitmap2; large_bitmap2 = manager_->GetSharedBitmapFromId(gfx::Size(1024, 1024), id); EXPECT_TRUE(large_bitmap2.get() == NULL); - scoped_ptr<cc::SharedBitmap> shared_bitmap2; + std::unique_ptr<cc::SharedBitmap> shared_bitmap2; shared_bitmap2 = manager_->GetSharedBitmapFromId(bitmap_size, id); EXPECT_TRUE(shared_bitmap2->pixels() == shared_bitmap->pixels()); shared_bitmap2.reset(); @@ -88,11 +88,12 @@ size_in_bytes, id, &handle); EXPECT_TRUE(base::SharedMemory::IsHandleValid(handle)); - scoped_ptr<base::SharedMemory> bitmap(new base::SharedMemory(handle, false)); + std::unique_ptr<base::SharedMemory> bitmap( + new base::SharedMemory(handle, false)); EXPECT_TRUE(bitmap->Map(size_in_bytes)); memset(bitmap->memory(), 0xff, size_in_bytes); - scoped_ptr<cc::SharedBitmap> shared_bitmap; + std::unique_ptr<cc::SharedBitmap> shared_bitmap; shared_bitmap = manager_->GetSharedBitmapFromId(bitmap_size, id); EXPECT_TRUE(shared_bitmap); EXPECT_TRUE( @@ -105,19 +106,19 @@ gfx::Size bitmap_size(1, 1); size_t size_in_bytes; EXPECT_TRUE(cc::SharedBitmap::SizeInBytes(bitmap_size, &size_in_bytes)); - scoped_ptr<base::SharedMemory> bitmap(new base::SharedMemory()); + std::unique_ptr<base::SharedMemory> bitmap(new base::SharedMemory()); bitmap->CreateAndMapAnonymous(size_in_bytes); memset(bitmap->memory(), 0xff, size_in_bytes); cc::SharedBitmapId id = cc::SharedBitmap::GenerateId(); base::SharedMemoryHandle handle; - scoped_ptr<HostSharedBitmapManagerClient> client( + std::unique_ptr<HostSharedBitmapManagerClient> client( new HostSharedBitmapManagerClient(manager_.get())); bitmap->ShareToProcess(base::GetCurrentProcessHandle(), &handle); client->ChildAllocatedSharedBitmap(size_in_bytes, handle, base::GetCurrentProcessHandle(), id); - scoped_ptr<cc::SharedBitmap> shared_bitmap; + std::unique_ptr<cc::SharedBitmap> shared_bitmap; shared_bitmap = manager_->GetSharedBitmapFromId(bitmap_size, id); ASSERT_TRUE(shared_bitmap.get() != NULL); @@ -125,7 +126,7 @@ client.reset(); EXPECT_EQ(0u, manager_->AllocatedBitmapCount()); - scoped_ptr<cc::SharedBitmap> shared_bitmap2; + std::unique_ptr<cc::SharedBitmap> shared_bitmap2; shared_bitmap2 = manager_->GetSharedBitmapFromId(bitmap_size, id); EXPECT_TRUE(shared_bitmap2.get() == NULL); EXPECT_EQ(memcmp(shared_bitmap->pixels(), bitmap->memory(), size_in_bytes), @@ -138,7 +139,7 @@ gfx::Size bitmap_size(1, 1); size_t size_in_bytes; EXPECT_TRUE(cc::SharedBitmap::SizeInBytes(bitmap_size, &size_in_bytes)); - scoped_ptr<base::SharedMemory> bitmap(new base::SharedMemory()); + std::unique_ptr<base::SharedMemory> bitmap(new base::SharedMemory()); bitmap->CreateAndMapAnonymous(size_in_bytes); memset(bitmap->memory(), 0xff, size_in_bytes); cc::SharedBitmapId id = cc::SharedBitmap::GenerateId(); @@ -149,14 +150,14 @@ client.ChildAllocatedSharedBitmap(size_in_bytes, handle, base::GetCurrentProcessHandle(), id); - scoped_ptr<base::SharedMemory> bitmap2(new base::SharedMemory()); + std::unique_ptr<base::SharedMemory> bitmap2(new base::SharedMemory()); bitmap2->CreateAndMapAnonymous(size_in_bytes); memset(bitmap2->memory(), 0x00, size_in_bytes); client.ChildAllocatedSharedBitmap(size_in_bytes, bitmap2->handle(), base::GetCurrentProcessHandle(), id); - scoped_ptr<cc::SharedBitmap> shared_bitmap; + std::unique_ptr<cc::SharedBitmap> shared_bitmap; shared_bitmap = manager_->GetSharedBitmapFromId(bitmap_size, id); ASSERT_TRUE(shared_bitmap.get() != NULL); EXPECT_EQ(memcmp(shared_bitmap->pixels(), bitmap->memory(), size_in_bytes),
diff --git a/content/common/input/input_event.h b/content/common/input/input_event.h index ec04a12d..58485e13 100644 --- a/content/common/input/input_event.h +++ b/content/common/input/input_event.h
@@ -5,8 +5,9 @@ #ifndef CONTENT_COMMON_INPUT_INPUT_EVENT_H_ #define CONTENT_COMMON_INPUT_INPUT_EVENT_H_ +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "content/common/content_export.h" #include "content/common/input/scoped_web_input_event.h" #include "ui/events/latency_info.h"
diff --git a/content/common/input/input_event_ack.cc b/content/common/input/input_event_ack.cc index 27e5aa2..689eda6a 100644 --- a/content/common/input/input_event_ack.cc +++ b/content/common/input/input_event_ack.cc
@@ -12,7 +12,7 @@ blink::WebInputEvent::Type type, InputEventAckState state, const ui::LatencyInfo& latency, - scoped_ptr<content::DidOverscrollParams> overscroll, + std::unique_ptr<content::DidOverscrollParams> overscroll, uint32_t unique_touch_event_id) : type(type), state(state),
diff --git a/content/common/input/input_event_ack.h b/content/common/input/input_event_ack.h index abe9a9539..565b66f 100644 --- a/content/common/input/input_event_ack.h +++ b/content/common/input/input_event_ack.h
@@ -7,7 +7,8 @@ #include <stdint.h> -#include "base/memory/scoped_ptr.h" +#include <memory> + #include "content/common/content_export.h" #include "content/common/input/did_overscroll_params.h" #include "content/common/input/input_event_ack_state.h" @@ -21,7 +22,7 @@ InputEventAck(blink::WebInputEvent::Type type, InputEventAckState state, const ui::LatencyInfo& latency, - scoped_ptr<content::DidOverscrollParams> overscroll, + std::unique_ptr<content::DidOverscrollParams> overscroll, uint32_t unique_touch_event_id); InputEventAck(blink::WebInputEvent::Type type, InputEventAckState state, @@ -37,7 +38,7 @@ blink::WebInputEvent::Type type; InputEventAckState state; ui::LatencyInfo latency; - scoped_ptr<content::DidOverscrollParams> overscroll; + std::unique_ptr<content::DidOverscrollParams> overscroll; uint32_t unique_touch_event_id; };
diff --git a/content/common/input/input_param_traits.cc b/content/common/input/input_param_traits.cc index 076d54a..a9f7a0d5 100644 --- a/content/common/input/input_param_traits.cc +++ b/content/common/input/input_param_traits.cc
@@ -17,12 +17,12 @@ namespace IPC { namespace { template <typename GestureType> -scoped_ptr<content::SyntheticGestureParams> ReadGestureParams( +std::unique_ptr<content::SyntheticGestureParams> ReadGestureParams( const base::Pickle* m, base::PickleIterator* iter) { - scoped_ptr<GestureType> gesture_params(new GestureType); + std::unique_ptr<GestureType> gesture_params(new GestureType); if (!ReadParam(m, iter, gesture_params.get())) - return scoped_ptr<content::SyntheticGestureParams>(); + return std::unique_ptr<content::SyntheticGestureParams>(); return std::move(gesture_params); } @@ -91,7 +91,7 @@ content::SyntheticGestureParams::GestureType gesture_type; if (!ReadParam(m, iter, &gesture_type)) return false; - scoped_ptr<content::SyntheticGestureParams> gesture_params; + std::unique_ptr<content::SyntheticGestureParams> gesture_params; switch (gesture_type) { case content::SyntheticGestureParams::SMOOTH_SCROLL_GESTURE: gesture_params =
diff --git a/content/common/input/input_param_traits_unittest.cc b/content/common/input/input_param_traits_unittest.cc index 1935f9c..07a7ac3 100644 --- a/content/common/input/input_param_traits_unittest.cc +++ b/content/common/input/input_param_traits_unittest.cc
@@ -226,7 +226,7 @@ } TEST_F(InputParamTraitsTest, SyntheticSmoothScrollGestureParams) { - scoped_ptr<SyntheticSmoothScrollGestureParams> gesture_params( + std::unique_ptr<SyntheticSmoothScrollGestureParams> gesture_params( new SyntheticSmoothScrollGestureParams); gesture_params->gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; gesture_params->anchor.SetPoint(234, 345); @@ -243,7 +243,7 @@ } TEST_F(InputParamTraitsTest, SyntheticPinchGestureParams) { - scoped_ptr<SyntheticPinchGestureParams> gesture_params( + std::unique_ptr<SyntheticPinchGestureParams> gesture_params( new SyntheticPinchGestureParams); gesture_params->gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; gesture_params->scale_factor = 2.3f; @@ -258,7 +258,7 @@ } TEST_F(InputParamTraitsTest, SyntheticTapGestureParams) { - scoped_ptr<SyntheticTapGestureParams> gesture_params( + std::unique_ptr<SyntheticTapGestureParams> gesture_params( new SyntheticTapGestureParams); gesture_params->gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; gesture_params->position.SetPoint(798, 233); @@ -272,7 +272,7 @@ } TEST_F(InputParamTraitsTest, SyntheticPointerActionParamsMove) { - scoped_ptr<SyntheticPointerActionParams> gesture_params( + std::unique_ptr<SyntheticPointerActionParams> gesture_params( new SyntheticPointerActionParams( SyntheticPointerActionParams::PointerActionType::MOVE)); gesture_params->gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; @@ -286,7 +286,7 @@ } TEST_F(InputParamTraitsTest, SyntheticPointerActionParamsRelease) { - scoped_ptr<SyntheticPointerActionParams> gesture_params( + std::unique_ptr<SyntheticPointerActionParams> gesture_params( new SyntheticPointerActionParams( SyntheticPointerActionParams::PointerActionType::RELEASE)); gesture_params->gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; @@ -299,7 +299,7 @@ } TEST_F(InputParamTraitsTest, SyntheticPointerActionParamsProcess) { - scoped_ptr<SyntheticPointerActionParams> gesture_params( + std::unique_ptr<SyntheticPointerActionParams> gesture_params( new SyntheticPointerActionParams( SyntheticPointerActionParams::PointerActionType::PROCESS)); gesture_params->gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
diff --git a/content/common/input/scoped_web_input_event.h b/content/common/input/scoped_web_input_event.h index d12b1a7d..bc502eef6 100644 --- a/content/common/input/scoped_web_input_event.h +++ b/content/common/input/scoped_web_input_event.h
@@ -5,7 +5,8 @@ #ifndef CONTENT_COMMON_INPUT_SCOPED_WEB_INPUT_EVENT_H_ #define CONTENT_COMMON_INPUT_SCOPED_WEB_INPUT_EVENT_H_ -#include "base/memory/scoped_ptr.h" +#include <memory> + #include "content/common/content_export.h" namespace blink { @@ -19,8 +20,8 @@ WebInputEventDeleter(); void operator()(blink::WebInputEvent* web_event) const; }; -typedef scoped_ptr<blink::WebInputEvent, - WebInputEventDeleter> ScopedWebInputEvent; +typedef std::unique_ptr<blink::WebInputEvent, WebInputEventDeleter> + ScopedWebInputEvent; } // namespace content
diff --git a/content/common/input/synthetic_gesture_packet.h b/content/common/input/synthetic_gesture_packet.h index db2c80bb..4f9b281d 100644 --- a/content/common/input/synthetic_gesture_packet.h +++ b/content/common/input/synthetic_gesture_packet.h
@@ -5,10 +5,10 @@ #ifndef CONTENT_COMMON_INPUT_SYNTHETIC_GESTURE_PACKET_H_ #define CONTENT_COMMON_INPUT_SYNTHETIC_GESTURE_PACKET_H_ +#include <memory> #include <utility> #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "content/common/content_export.h" #include "content/common/input/synthetic_gesture_params.h" @@ -21,18 +21,19 @@ SyntheticGesturePacket(); ~SyntheticGesturePacket(); - void set_gesture_params(scoped_ptr<SyntheticGestureParams> gesture_params) { + void set_gesture_params( + std::unique_ptr<SyntheticGestureParams> gesture_params) { gesture_params_ = std::move(gesture_params); } const SyntheticGestureParams* gesture_params() const { return gesture_params_.get(); } - scoped_ptr<SyntheticGestureParams> pass_gesture_params() { + std::unique_ptr<SyntheticGestureParams> pass_gesture_params() { return std::move(gesture_params_); } private: - scoped_ptr<SyntheticGestureParams> gesture_params_; + std::unique_ptr<SyntheticGestureParams> gesture_params_; DISALLOW_COPY_AND_ASSIGN(SyntheticGesturePacket); };
diff --git a/content/common/input/synthetic_gesture_params.h b/content/common/input/synthetic_gesture_params.h index 5ece4db..5f308db 100644 --- a/content/common/input/synthetic_gesture_params.h +++ b/content/common/input/synthetic_gesture_params.h
@@ -5,7 +5,8 @@ #ifndef CONTENT_COMMON_INPUT_SYNTHETIC_GESTURE_PARAMS_H_ #define CONTENT_COMMON_INPUT_SYNTHETIC_GESTURE_PARAMS_H_ -#include "base/memory/scoped_ptr.h" +#include <memory> + #include "content/common/content_export.h" namespace content {
diff --git a/content/common/input/web_input_event_queue.h b/content/common/input/web_input_event_queue.h index fa85bd4f7..eab0599 100644 --- a/content/common/input/web_input_event_queue.h +++ b/content/common/input/web_input_event_queue.h
@@ -6,8 +6,7 @@ #define CONTENT_COMMON_INPUT_WEB_INPUT_EVENT_QUEUE_H_ #include <deque> - -#include "base/memory/scoped_ptr.h" +#include <memory> namespace content { @@ -40,17 +39,17 @@ // queued events. void Queue(const T& event) { if (!queue_.empty()) { - scoped_ptr<T>& last_event = queue_.back(); + std::unique_ptr<T>& last_event = queue_.back(); if (last_event->CanCoalesceWith(event)) { last_event->CoalesceWith(event); return; } } - queue_.emplace_back(scoped_ptr<T>(new T(event))); + queue_.emplace_back(std::unique_ptr<T>(new T(event))); } - scoped_ptr<T> Pop() { - scoped_ptr<T> result; + std::unique_ptr<T> Pop() { + std::unique_ptr<T> result; if (!queue_.empty()) { result.reset(queue_.front().release()); queue_.pop_front(); @@ -67,7 +66,7 @@ WebInputEventQueueState state() const WARN_UNUSED_RESULT { return state_; } private: - typedef std::deque<scoped_ptr<T>> EventQueue; + typedef std::deque<std::unique_ptr<T>> EventQueue; EventQueue queue_; WebInputEventQueueState state_;
diff --git a/content/common/mac/attributed_string_coder_unittest.mm b/content/common/mac/attributed_string_coder_unittest.mm index 021ea9b..314af39 100644 --- a/content/common/mac/attributed_string_coder_unittest.mm +++ b/content/common/mac/attributed_string_coder_unittest.mm
@@ -2,12 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#import "content/common/mac/attributed_string_coder.h" + #include <AppKit/AppKit.h> +#include <memory> + #include "base/mac/scoped_nsobject.h" -#include "base/memory/scoped_ptr.h" #include "base/strings/utf_string_conversions.h" -#import "content/common/mac/attributed_string_coder.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" @@ -26,7 +28,7 @@ } NSAttributedString* EncodeAndDecode(NSAttributedString* str) { - scoped_ptr<const AttributedStringCoder::EncodedString> encoded_str( + std::unique_ptr<const AttributedStringCoder::EncodedString> encoded_str( AttributedStringCoder::Encode(str)); return AttributedStringCoder::Decode(encoded_str.get()); }
diff --git a/content/common/mojo/current_thread_loader.cc b/content/common/mojo/current_thread_loader.cc index eb64b15..561f91b1 100644 --- a/content/common/mojo/current_thread_loader.cc +++ b/content/common/mojo/current_thread_loader.cc
@@ -4,6 +4,8 @@ #include "content/common/mojo/current_thread_loader.h" +#include "base/memory/ptr_util.h" + namespace content { CurrentThreadLoader::CurrentThreadLoader(const ApplicationFactory& factory) @@ -18,7 +20,7 @@ factory_ = ApplicationFactory(); } - connections_.push_back(make_scoped_ptr( + connections_.push_back(base::WrapUnique( new mojo::ShellConnection(shell_client_.get(), std::move(request)))); }
diff --git a/content/common/mojo/current_thread_loader.h b/content/common/mojo/current_thread_loader.h index e5e6e35..deb0e10 100644 --- a/content/common/mojo/current_thread_loader.h +++ b/content/common/mojo/current_thread_loader.h
@@ -19,7 +19,8 @@ // the current thread. class CurrentThreadLoader : public mojo::shell::Loader { public: - using ApplicationFactory = base::Callback<scoped_ptr<mojo::ShellClient>()>; + using ApplicationFactory = + base::Callback<std::unique_ptr<mojo::ShellClient>()>; explicit CurrentThreadLoader(const ApplicationFactory& factory); ~CurrentThreadLoader() override; @@ -34,9 +35,9 @@ ApplicationFactory factory_; // Our shared shell client, passed to each connection. - scoped_ptr<mojo::ShellClient> shell_client_; + std::unique_ptr<mojo::ShellClient> shell_client_; - std::vector<scoped_ptr<mojo::ShellConnection>> connections_; + std::vector<std::unique_ptr<mojo::ShellConnection>> connections_; DISALLOW_COPY_AND_ASSIGN(CurrentThreadLoader); };
diff --git a/content/common/mojo/mojo_shell_connection_impl.h b/content/common/mojo/mojo_shell_connection_impl.h index 3f1a188..cc9d6b3 100644 --- a/content/common/mojo/mojo_shell_connection_impl.h +++ b/content/common/mojo/mojo_shell_connection_impl.h
@@ -5,10 +5,10 @@ #ifndef CONTENT_COMMON_MOJO_SHELL_CONNECTION_IMPL_H_ #define CONTENT_COMMON_MOJO_SHELL_CONNECTION_IMPL_H_ +#include <memory> #include <vector> #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "content/public/common/mojo_shell_connection.h" #include "mojo/public/cpp/system/message_pipe.h" #include "mojo/shell/public/cpp/shell.h" @@ -62,7 +62,7 @@ void RemoveListener(Listener* listener) override; const bool external_; - scoped_ptr<mojo::ShellConnection> shell_connection_; + std::unique_ptr<mojo::ShellConnection> shell_connection_; std::vector<Listener*> listeners_; DISALLOW_COPY_AND_ASSIGN(MojoShellConnectionImpl);
diff --git a/content/common/mojo/static_loader.cc b/content/common/mojo/static_loader.cc index 107c913..bd81c5a0 100644 --- a/content/common/mojo/static_loader.cc +++ b/content/common/mojo/static_loader.cc
@@ -35,7 +35,7 @@ factory_(factory) {} void Run() override { - scoped_ptr<mojo::ApplicationRunner> runner( + std::unique_ptr<mojo::ApplicationRunner> runner( new mojo::ApplicationRunner(factory_.Run().release())); runner->Run(request_.PassMessagePipe().release().value(), false /* init_base */);
diff --git a/content/common/mojo/static_loader.h b/content/common/mojo/static_loader.h index 318366d8..ac2a9f5a 100644 --- a/content/common/mojo/static_loader.h +++ b/content/common/mojo/static_loader.h
@@ -28,7 +28,8 @@ // a time. Any Load requests received while the app is running will be dropped. class StaticLoader : public mojo::shell::Loader { public: - using ApplicationFactory = base::Callback<scoped_ptr<mojo::ShellClient>()>; + using ApplicationFactory = + base::Callback<std::unique_ptr<mojo::ShellClient>()>; // Constructs a static loader for |factory|. explicit StaticLoader(const ApplicationFactory& factory); @@ -54,7 +55,7 @@ base::Closure quit_callback_; // Thread for the application if currently running. - scoped_ptr<base::SimpleThread> thread_; + std::unique_ptr<base::SimpleThread> thread_; base::WeakPtrFactory<StaticLoader> weak_factory_;
diff --git a/content/common/origin_trials/trial_token.cc b/content/common/origin_trials/trial_token.cc index e44f6f0..fe94de9e 100644 --- a/content/common/origin_trials/trial_token.cc +++ b/content/common/origin_trials/trial_token.cc
@@ -10,6 +10,7 @@ #include "base/base64.h" #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_split.h" #include "base/strings/string_util.h" @@ -31,7 +32,7 @@ TrialToken::~TrialToken() {} -scoped_ptr<TrialToken> TrialToken::Parse(const std::string& token_text) { +std::unique_ptr<TrialToken> TrialToken::Parse(const std::string& token_text) { if (token_text.empty()) { return nullptr; } @@ -86,8 +87,8 @@ // Signed data is (origin + "|" + feature_name + "|" + expiry). std::string data = token_contents.substr(signature.length() + 1); - return make_scoped_ptr(new TrialToken(version, signature, data, origin, - feature_name, expiry_timestamp)); + return base::WrapUnique(new TrialToken(version, signature, data, origin, + feature_name, expiry_timestamp)); } bool TrialToken::IsAppropriate(const url::Origin& origin,
diff --git a/content/common/origin_trials/trial_token.h b/content/common/origin_trials/trial_token.h index 3109240..3143a7ef 100644 --- a/content/common/origin_trials/trial_token.h +++ b/content/common/origin_trials/trial_token.h
@@ -5,9 +5,9 @@ #ifndef CONTENT_COMMON_ORIGIN_TRIALS_TRIAL_TOKEN_H_ #define CONTENT_COMMON_ORIGIN_TRIALS_TRIAL_TOKEN_H_ +#include <memory> #include <string> -#include "base/memory/scoped_ptr.h" #include "base/strings/string_piece.h" #include "base/time/time.h" #include "content/common/content_export.h" @@ -35,7 +35,7 @@ // Returns a token object if the string represents a well-formed token, or // nullptr otherwise. (This does not mean that the token is valid, just that // it can be parsed.) - static scoped_ptr<TrialToken> Parse(const std::string& token_text); + static std::unique_ptr<TrialToken> Parse(const std::string& token_text); // Returns true if this feature is appropriate for use by the given origin, // for the given feature name. This does not check whether the signature is
diff --git a/content/common/origin_trials/trial_token_unittest.cc b/content/common/origin_trials/trial_token_unittest.cc index dd83508..f5a2527a 100644 --- a/content/common/origin_trials/trial_token_unittest.cc +++ b/content/common/origin_trials/trial_token_unittest.cc
@@ -4,8 +4,9 @@ #include "content/common/origin_trials/trial_token.h" +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/strings/string_piece.h" #include "base/strings/string_util.h" #include "base/test/simple_test_clock.h" @@ -155,20 +156,21 @@ }; TEST_F(TrialTokenTest, ParseEmptyString) { - scoped_ptr<TrialToken> empty_token = TrialToken::Parse(""); + std::unique_ptr<TrialToken> empty_token = TrialToken::Parse(""); EXPECT_FALSE(empty_token); } TEST_F(TrialTokenTest, ParseInvalidStrings) { for (size_t i = 0; i < kNumInvalidTokens; ++i) { - scoped_ptr<TrialToken> empty_token = TrialToken::Parse(kInvalidTokens[i]); + std::unique_ptr<TrialToken> empty_token = + TrialToken::Parse(kInvalidTokens[i]); EXPECT_FALSE(empty_token) << "Invalid trial token should not parse: " << kInvalidTokens[i]; } } TEST_F(TrialTokenTest, ParseValidToken) { - scoped_ptr<TrialToken> token = TrialToken::Parse(kSampleToken); + std::unique_ptr<TrialToken> token = TrialToken::Parse(kSampleToken); ASSERT_TRUE(token); EXPECT_EQ(kExpectedVersion, token->version()); EXPECT_EQ(kExpectedFeatureName, token->feature_name()); @@ -179,7 +181,7 @@ } TEST_F(TrialTokenTest, ValidateValidToken) { - scoped_ptr<TrialToken> token = TrialToken::Parse(kSampleToken); + std::unique_ptr<TrialToken> token = TrialToken::Parse(kSampleToken); ASSERT_TRUE(token); EXPECT_TRUE(ValidateOrigin(token.get(), expected_origin_)); EXPECT_FALSE(ValidateOrigin(token.get(), invalid_origin_)); @@ -197,7 +199,7 @@ } TEST_F(TrialTokenTest, TokenIsAppropriateForOriginAndFeature) { - scoped_ptr<TrialToken> token = TrialToken::Parse(kSampleToken); + std::unique_ptr<TrialToken> token = TrialToken::Parse(kSampleToken); ASSERT_TRUE(token); EXPECT_TRUE(token->IsAppropriate(expected_origin_, kExpectedFeatureName)); EXPECT_FALSE(token->IsAppropriate(expected_origin_, @@ -210,33 +212,33 @@ } TEST_F(TrialTokenTest, ValidateValidSignature) { - scoped_ptr<TrialToken> token = TrialToken::Parse(kSampleToken); + std::unique_ptr<TrialToken> token = TrialToken::Parse(kSampleToken); ASSERT_TRUE(token); EXPECT_TRUE(ValidateSignature(token.get(), correct_public_key())); } TEST_F(TrialTokenTest, ValidateInvalidSignature) { - scoped_ptr<TrialToken> token = TrialToken::Parse(kInvalidSignatureToken); + std::unique_ptr<TrialToken> token = TrialToken::Parse(kInvalidSignatureToken); ASSERT_TRUE(token); EXPECT_FALSE(ValidateSignature(token.get(), correct_public_key())); } TEST_F(TrialTokenTest, ValidateTokenWithCorrectKey) { - scoped_ptr<TrialToken> token = TrialToken::Parse(kSampleToken); + std::unique_ptr<TrialToken> token = TrialToken::Parse(kSampleToken); ASSERT_TRUE(token); EXPECT_TRUE(token->IsValid(base::Time::FromDoubleT(kValidTimestamp), correct_public_key())); } TEST_F(TrialTokenTest, ValidateSignatureWithIncorrectKey) { - scoped_ptr<TrialToken> token = TrialToken::Parse(kSampleToken); + std::unique_ptr<TrialToken> token = TrialToken::Parse(kSampleToken); ASSERT_TRUE(token); EXPECT_FALSE(token->IsValid(base::Time::FromDoubleT(kValidTimestamp), incorrect_public_key())); } TEST_F(TrialTokenTest, ValidateWhenNotExpired) { - scoped_ptr<TrialToken> token = TrialToken::Parse(kSampleToken); + std::unique_ptr<TrialToken> token = TrialToken::Parse(kSampleToken); ASSERT_TRUE(token); }
diff --git a/content/common/origin_trials/trial_token_validator.cc b/content/common/origin_trials/trial_token_validator.cc index b7d61fec..2dd4d8aa 100644 --- a/content/common/origin_trials/trial_token_validator.cc +++ b/content/common/origin_trials/trial_token_validator.cc
@@ -13,7 +13,7 @@ bool TrialTokenValidator::ValidateToken(const std::string& token, const url::Origin& origin, base::StringPiece featureName) { - scoped_ptr<TrialToken> trial_token = TrialToken::Parse(token); + std::unique_ptr<TrialToken> trial_token = TrialToken::Parse(token); // TODO(iclelland): Allow for multiple signing keys, and iterate over all // active keys here. https://crbug.com/543220
diff --git a/content/common/origin_trials/trial_token_validator_unittest.cc b/content/common/origin_trials/trial_token_validator_unittest.cc index 9a2d27c..e54a8d5 100644 --- a/content/common/origin_trials/trial_token_validator_unittest.cc +++ b/content/common/origin_trials/trial_token_validator_unittest.cc
@@ -4,8 +4,9 @@ #include "content/common/origin_trials/trial_token_validator.h" +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/strings/string_util.h" #include "base/test/simple_test_clock.h" #include "base/time/time.h"
diff --git a/content/common/sandbox_linux/bpf_cros_arm_gpu_policy_linux.cc b/content/common/sandbox_linux/bpf_cros_arm_gpu_policy_linux.cc index dc625517..ac6de8b5 100644 --- a/content/common/sandbox_linux/bpf_cros_arm_gpu_policy_linux.cc +++ b/content/common/sandbox_linux/bpf_cros_arm_gpu_policy_linux.cc
@@ -12,6 +12,7 @@ #include <sys/types.h> #include <unistd.h> +#include <memory> #include <string> #include <vector> @@ -19,7 +20,6 @@ #include "base/compiler_specific.h" #include "base/logging.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "build/build_config.h" #include "content/common/sandbox_linux/sandbox_bpf_base_policy_linux.h" #include "content/common/sandbox_linux/sandbox_seccomp_bpf_linux.h"
diff --git a/content/common/sandbox_linux/bpf_gpu_policy_linux.cc b/content/common/sandbox_linux/bpf_gpu_policy_linux.cc index d0aefb3..077a710 100644 --- a/content/common/sandbox_linux/bpf_gpu_policy_linux.cc +++ b/content/common/sandbox_linux/bpf_gpu_policy_linux.cc
@@ -12,6 +12,7 @@ #include <sys/types.h> #include <unistd.h> +#include <memory> #include <string> #include <vector> @@ -20,7 +21,7 @@ #include "base/compiler_specific.h" #include "base/logging.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" +#include "base/memory/ptr_util.h" #include "build/build_config.h" #include "content/common/sandbox_linux/sandbox_bpf_base_policy_linux.h" #include "content/common/sandbox_linux/sandbox_seccomp_bpf_linux.h" @@ -223,7 +224,7 @@ DCHECK(broker_sandboxer_allocator); UpdateProcessTypeToGpuBroker(); return SandboxSeccompBPF::StartSandboxWithExternalPolicy( - make_scoped_ptr(broker_sandboxer_allocator()), base::ScopedFD()); + base::WrapUnique(broker_sandboxer_allocator()), base::ScopedFD()); } } // namespace
diff --git a/content/common/sandbox_linux/sandbox_bpf_base_policy_linux.h b/content/common/sandbox_linux/sandbox_bpf_base_policy_linux.h index fab25bbd..a5cc04f 100644 --- a/content/common/sandbox_linux/sandbox_bpf_base_policy_linux.h +++ b/content/common/sandbox_linux/sandbox_bpf_base_policy_linux.h
@@ -5,8 +5,9 @@ #ifndef CONTENT_COMMON_SANDBOX_LINUX_SANDBOX_BPF_BASE_POLICY_LINUX_H_ #define CONTENT_COMMON_SANDBOX_LINUX_SANDBOX_BPF_BASE_POLICY_LINUX_H_ +#include <memory> + #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "sandbox/linux/bpf_dsl/bpf_dsl_forward.h" #include "sandbox/linux/bpf_dsl/policy.h" #include "sandbox/linux/seccomp-bpf-helpers/baseline_policy.h" @@ -41,7 +42,7 @@ private: // Compose the BaselinePolicy from sandbox/. - scoped_ptr<sandbox::BaselinePolicy> baseline_policy_; + std::unique_ptr<sandbox::BaselinePolicy> baseline_policy_; DISALLOW_COPY_AND_ASSIGN(SandboxBPFBasePolicy); };
diff --git a/content/common/sandbox_linux/sandbox_init_linux.cc b/content/common/sandbox_linux/sandbox_init_linux.cc index 11190344..f7358377 100644 --- a/content/common/sandbox_linux/sandbox_init_linux.cc +++ b/content/common/sandbox_linux/sandbox_init_linux.cc
@@ -4,24 +4,24 @@ #include "content/public/common/sandbox_init.h" +#include <memory> #include <utility> #include "base/files/scoped_file.h" -#include "base/memory/scoped_ptr.h" #include "build/build_config.h" #include "content/common/sandbox_linux/sandbox_seccomp_bpf_linux.h" #include "sandbox/linux/bpf_dsl/policy.h" namespace content { -bool InitializeSandbox(scoped_ptr<sandbox::bpf_dsl::Policy> policy, +bool InitializeSandbox(std::unique_ptr<sandbox::bpf_dsl::Policy> policy, base::ScopedFD proc_fd) { return SandboxSeccompBPF::StartSandboxWithExternalPolicy(std::move(policy), std::move(proc_fd)); } #if !defined(OS_NACL_NONSFI) -scoped_ptr<sandbox::bpf_dsl::Policy> GetBPFSandboxBaselinePolicy() { +std::unique_ptr<sandbox::bpf_dsl::Policy> GetBPFSandboxBaselinePolicy() { return SandboxSeccompBPF::GetBaselinePolicy(); } #endif // !defined(OS_NACL_NONSFI)
diff --git a/content/common/sandbox_linux/sandbox_linux.cc b/content/common/sandbox_linux/sandbox_linux.cc index 2c639c1f..c27f0b21 100644 --- a/content/common/sandbox_linux/sandbox_linux.cc +++ b/content/common/sandbox_linux/sandbox_linux.cc
@@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/common/sandbox_linux/sandbox_linux.h" + #include <dirent.h> #include <fcntl.h> #include <stdint.h> @@ -12,6 +14,7 @@ #include <unistd.h> #include <limits> +#include <memory> #include <string> #include <vector> @@ -22,14 +25,13 @@ #include "base/files/scoped_file.h" #include "base/logging.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.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/sys_info.h" #include "base/time/time.h" #include "build/build_config.h" -#include "content/common/sandbox_linux/sandbox_linux.h" #include "content/common/sandbox_linux/sandbox_seccomp_bpf_linux.h" #include "content/public/common/content_switches.h" #include "content/public/common/sandbox_linux.h" @@ -113,7 +115,7 @@ LOG(FATAL) << "Failed to instantiate the setuid sandbox client."; } #if defined(ANY_OF_AMTLU_SANITIZER) - sanitizer_args_ = make_scoped_ptr(new __sanitizer_sandbox_arguments); + sanitizer_args_ = base::WrapUnique(new __sanitizer_sandbox_arguments); *sanitizer_args_ = {0}; #endif }
diff --git a/content/common/sandbox_linux/sandbox_linux.h b/content/common/sandbox_linux/sandbox_linux.h index 7ce723b3..3836a8d 100644 --- a/content/common/sandbox_linux/sandbox_linux.h +++ b/content/common/sandbox_linux/sandbox_linux.h
@@ -5,12 +5,12 @@ #ifndef CONTENT_COMMON_SANDBOX_LINUX_SANDBOX_LINUX_H_ #define CONTENT_COMMON_SANDBOX_LINUX_SANDBOX_LINUX_H_ +#include <memory> #include <string> #include <vector> #include "base/logging.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "content/public/common/sandbox_linux.h" #if defined(ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER) || \ @@ -173,9 +173,9 @@ bool seccomp_bpf_with_tsync_supported_; // Accurate if pre_initialized_. bool yama_is_enforcing_; // Accurate if pre_initialized_. bool initialize_sandbox_ran_; // InitializeSandbox() was called. - scoped_ptr<sandbox::SetuidSandboxClient> setuid_sandbox_client_; + std::unique_ptr<sandbox::SetuidSandboxClient> setuid_sandbox_client_; #if defined(ANY_OF_AMTLU_SANITIZER) - scoped_ptr<__sanitizer_sandbox_arguments> sanitizer_args_; + std::unique_ptr<__sanitizer_sandbox_arguments> sanitizer_args_; #endif DISALLOW_COPY_AND_ASSIGN(LinuxSandbox);
diff --git a/content/common/sandbox_linux/sandbox_seccomp_bpf_linux.cc b/content/common/sandbox_linux/sandbox_seccomp_bpf_linux.cc index 7dec1db..7a3620c 100644 --- a/content/common/sandbox_linux/sandbox_seccomp_bpf_linux.cc +++ b/content/common/sandbox_linux/sandbox_seccomp_bpf_linux.cc
@@ -10,6 +10,8 @@ #include <sys/stat.h> #include <sys/types.h> +#include <memory> + #include "base/command_line.h" #include "base/logging.h" #include "base/macros.h" @@ -20,7 +22,6 @@ #if defined(USE_SECCOMP_BPF) #include "base/files/scoped_file.h" -#include "base/memory/scoped_ptr.h" #include "base/posix/eintr_wrapper.h" #include "content/common/sandbox_linux/bpf_cros_arm_gpu_policy_linux.h" #include "content/common/sandbox_linux/bpf_gpu_policy_linux.h" @@ -160,7 +161,7 @@ } } -scoped_ptr<SandboxBPFBasePolicy> GetGpuProcessSandbox() { +std::unique_ptr<SandboxBPFBasePolicy> GetGpuProcessSandbox() { const base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); bool allow_sysv_shm = false; @@ -170,13 +171,13 @@ } if (IsChromeOS() && IsArchitectureArm()) { - return scoped_ptr<SandboxBPFBasePolicy>( + return std::unique_ptr<SandboxBPFBasePolicy>( new CrosArmGpuProcessPolicy(allow_sysv_shm)); } else { bool allow_mincore = command_line.HasSwitch(switches::kUseGL) && command_line.GetSwitchValueASCII(switches::kUseGL) == gfx::kGLImplementationEGLName; - return scoped_ptr<SandboxBPFBasePolicy>( + return std::unique_ptr<SandboxBPFBasePolicy>( new GpuProcessPolicy(allow_mincore)); } } @@ -185,7 +186,7 @@ bool StartBPFSandbox(const base::CommandLine& command_line, const std::string& process_type, base::ScopedFD proc_fd) { - scoped_ptr<SandboxBPFBasePolicy> policy; + std::unique_ptr<SandboxBPFBasePolicy> policy; if (process_type == switches::kGpuProcess) { policy.reset(GetGpuProcessSandbox().release()); @@ -285,7 +286,7 @@ #endif // !defined(OS_NACL_NONSFI) bool SandboxSeccompBPF::StartSandboxWithExternalPolicy( - scoped_ptr<sandbox::bpf_dsl::Policy> policy, + std::unique_ptr<sandbox::bpf_dsl::Policy> policy, base::ScopedFD proc_fd) { #if defined(USE_SECCOMP_BPF) if (IsSeccompBPFDesired() && SupportsSandbox()) { @@ -298,11 +299,12 @@ } #if !defined(OS_NACL_NONSFI) -scoped_ptr<sandbox::bpf_dsl::Policy> SandboxSeccompBPF::GetBaselinePolicy() { +std::unique_ptr<sandbox::bpf_dsl::Policy> +SandboxSeccompBPF::GetBaselinePolicy() { #if defined(USE_SECCOMP_BPF) - return scoped_ptr<sandbox::bpf_dsl::Policy>(new BaselinePolicy); + return std::unique_ptr<sandbox::bpf_dsl::Policy>(new BaselinePolicy); #else - return scoped_ptr<sandbox::bpf_dsl::Policy>(); + return std::unique_ptr<sandbox::bpf_dsl::Policy>(); #endif // defined(USE_SECCOMP_BPF) } #endif // !defined(OS_NACL_NONSFI)
diff --git a/content/common/sandbox_linux/sandbox_seccomp_bpf_linux.h b/content/common/sandbox_linux/sandbox_seccomp_bpf_linux.h index 5549ef6..a462dc95 100644 --- a/content/common/sandbox_linux/sandbox_seccomp_bpf_linux.h +++ b/content/common/sandbox_linux/sandbox_seccomp_bpf_linux.h
@@ -5,11 +5,11 @@ #ifndef CONTENT_COMMON_SANDBOX_LINUX_SANDBOX_SECCOMP_BPF_LINUX_H_ #define CONTENT_COMMON_SANDBOX_LINUX_SANDBOX_SECCOMP_BPF_LINUX_H_ +#include <memory> #include <string> #include "base/files/scoped_file.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "sandbox/linux/bpf_dsl/policy.h" namespace content { @@ -39,10 +39,10 @@ // This is the API to enable a seccomp-bpf sandbox by using an // external policy. static bool StartSandboxWithExternalPolicy( - scoped_ptr<sandbox::bpf_dsl::Policy> policy, + std::unique_ptr<sandbox::bpf_dsl::Policy> policy, base::ScopedFD proc_fd); // The "baseline" policy can be a useful base to build a sandbox policy. - static scoped_ptr<sandbox::bpf_dsl::Policy> GetBaselinePolicy(); + static std::unique_ptr<sandbox::bpf_dsl::Policy> GetBaselinePolicy(); private: DISALLOW_IMPLICIT_CONSTRUCTORS(SandboxSeccompBPF);
diff --git a/content/common/sandbox_mac_diraccess_unittest.mm b/content/common/sandbox_mac_diraccess_unittest.mm index 205e1cb..322b231d 100644 --- a/content/common/sandbox_mac_diraccess_unittest.mm +++ b/content/common/sandbox_mac_diraccess_unittest.mm
@@ -10,10 +10,11 @@ #include <sandbox.h> } +#include <memory> + #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/process/kill.h" #include "base/strings/sys_string_conversions.h" #include "base/strings/utf_string_conversions.h" @@ -142,7 +143,7 @@ } }; -typedef scoped_ptr<base::FilePath, ScopedDirectoryDelete> ScopedDirectory; +typedef std::unique_ptr<base::FilePath, ScopedDirectoryDelete> ScopedDirectory; TEST_F(MacDirAccessSandboxTest, SandboxAccess) { using base::CreateDirectory;
diff --git a/content/common/sandbox_mac_fontloading_unittest.mm b/content/common/sandbox_mac_fontloading_unittest.mm index 4a0fb0d..a9210f3 100644 --- a/content/common/sandbox_mac_fontloading_unittest.mm +++ b/content/common/sandbox_mac_fontloading_unittest.mm
@@ -5,11 +5,12 @@ #import <Cocoa/Cocoa.h> #include <stddef.h> +#include <memory> + #include "base/files/file_util.h" #include "base/files/scoped_file.h" #include "base/logging.h" #include "base/mac/scoped_cftyperef.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/shared_memory.h" #include "content/common/mac/font_descriptor.h" #include "content/common/mac/font_loader.h" @@ -25,7 +26,7 @@ bool SandboxedTest() override; private: - scoped_ptr<base::SharedMemory> font_shmem_; + std::unique_ptr<base::SharedMemory> font_shmem_; size_t font_data_length_; }; REGISTER_SANDBOX_TEST_CASE(FontLoadingTestCase);
diff --git a/content/common/sandbox_mac_unittest_helper.mm b/content/common/sandbox_mac_unittest_helper.mm index cb029d1..5988ffe6 100644 --- a/content/common/sandbox_mac_unittest_helper.mm +++ b/content/common/sandbox_mac_unittest_helper.mm
@@ -9,10 +9,10 @@ } #include <map> +#include <memory> #include "base/files/file_path.h" #include "base/logging.h" -#include "base/memory/scoped_ptr.h" #include "base/process/kill.h" #include "content/common/sandbox_mac.h" #include "content/test/test_content_client.h" @@ -136,8 +136,8 @@ const char* test_data = getenv(kTestDataKey); // Find Test Function to run; - scoped_ptr<MacSandboxTestCase> - test_case(SandboxTestForName(sandbox_test_name)); + std::unique_ptr<MacSandboxTestCase> test_case( + SandboxTestForName(sandbox_test_name)); if (!test_case) { LOG(ERROR) << "Invalid sandbox test name (" << sandbox_test_name << ")"; return -1;
diff --git a/content/common/webplugininfo_unittest.cc b/content/common/webplugininfo_unittest.cc index dc1d30fb..5661af3 100644 --- a/content/common/webplugininfo_unittest.cc +++ b/content/common/webplugininfo_unittest.cc
@@ -6,11 +6,11 @@ #include <stddef.h> +#include <memory> #include <string> #include <vector> #include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "base/strings/utf_string_conversions.h" #include "base/version.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/content/content_common_mojo_bindings.gyp b/content/content_common_mojo_bindings.gyp index 8063d23..008743cd 100644 --- a/content/content_common_mojo_bindings.gyp +++ b/content/content_common_mojo_bindings.gyp
@@ -40,10 +40,6 @@ '../skia/skia.gyp:skia_mojo', '../third_party/WebKit/public/blink.gyp:mojo_bindings', '../ui/mojo/geometry/mojo_bindings.gyp:mojo_geometry_bindings', - '../url/url.gyp:url_interfaces_mojom', - ], - 'export_dependent_settings': [ - '../url/url.gyp:url_interfaces_mojom', ], 'includes': [ '../mojo/mojom_bindings_generator_explicit.gypi' ], }, @@ -54,8 +50,12 @@ 'enable_wexit_time_destructors': 1, }, 'dependencies': [ + '../url/url.gyp:url_mojom', 'content_common_mojo_bindings_mojom', ], + 'export_dependent_settings': [ + '../url/url.gyp:url_mojom', + ], }, ] }
diff --git a/content/content_renderer.gypi b/content/content_renderer.gypi index d31c8ba..3e2500b 100644 --- a/content/content_renderer.gypi +++ b/content/content_renderer.gypi
@@ -351,6 +351,8 @@ 'renderer/media/video_capture_impl_manager.h', 'renderer/media/video_capture_message_filter.cc', 'renderer/media/video_capture_message_filter.h', + 'renderer/media/web_media_element_source_utils.cc', + 'renderer/media/web_media_element_source_utils.h', 'renderer/media/webmediaplayer_ms.cc', 'renderer/media/webmediaplayer_ms.h', 'renderer/media/webmediaplayer_ms_compositor.cc',
diff --git a/content/public/android/java/src/org/chromium/content/browser/DownloadController.java b/content/public/android/java/src/org/chromium/content/browser/DownloadController.java index 5bc567b..6cccb2a 100644 --- a/content/public/android/java/src/org/chromium/content/browser/DownloadController.java +++ b/content/public/android/java/src/org/chromium/content/browser/DownloadController.java
@@ -149,7 +149,7 @@ @CalledByNative private void onDownloadInterrupted(String url, String mimeType, String filename, String path, long contentLength, int notificationId, String downloadGuid, boolean isResumable, - boolean isAutoResumable) { + boolean isAutoResumable, boolean isOffTheRecord) { if (sDownloadNotificationService == null) return; DownloadInfo downloadInfo = new DownloadInfo.Builder() .setUrl(url) @@ -161,6 +161,7 @@ .setNotificationId(notificationId) .setDownloadGuid(downloadGuid) .setIsResumable(isResumable) + .setIsOffTheRecord(isOffTheRecord) .build(); sDownloadNotificationService.onDownloadInterrupted(downloadInfo, isAutoResumable); } @@ -191,7 +192,8 @@ @CalledByNative private void onDownloadUpdated(String url, String mimeType, String filename, String path, long contentLength, int notificationId, String downloadGuid, int percentCompleted, - long timeRemainingInMs, boolean hasUserGesture, boolean isPaused, boolean isResumable) { + long timeRemainingInMs, boolean hasUserGesture, boolean isPaused, + boolean isOffTheRecord) { if (sDownloadNotificationService == null) return; DownloadInfo downloadInfo = new DownloadInfo.Builder() .setUrl(url) @@ -206,7 +208,8 @@ .setTimeRemainingInMillis(timeRemainingInMs) .setHasUserGesture(hasUserGesture) .setIsPaused(isPaused) - .setIsResumable(isResumable) + .setIsResumable(!isOffTheRecord) + .setIsOffTheRecord(isOffTheRecord) .build(); sDownloadNotificationService.onDownloadUpdated(downloadInfo); }
diff --git a/content/public/android/java/src/org/chromium/content/browser/DownloadInfo.java b/content/public/android/java/src/org/chromium/content/browser/DownloadInfo.java index f6297bec..7110fe8f 100644 --- a/content/public/android/java/src/org/chromium/content/browser/DownloadInfo.java +++ b/content/public/android/java/src/org/chromium/content/browser/DownloadInfo.java
@@ -27,6 +27,7 @@ private final long mTimeRemainingInMillis; private final boolean mIsResumable; private final boolean mIsPaused; + private final boolean mIsOffTheRecord; private DownloadInfo(Builder builder) { mUrl = builder.mUrl; @@ -48,6 +49,7 @@ mTimeRemainingInMillis = builder.mTimeRemainingInMillis; mIsResumable = builder.mIsResumable; mIsPaused = builder.mIsPaused; + mIsOffTheRecord = builder.mIsOffTheRecord; } public String getUrl() { @@ -129,6 +131,10 @@ return mIsPaused; } + public boolean isOffTheRecord() { + return mIsOffTheRecord; + } + /** * Helper class for building the DownloadInfo object. */ @@ -151,7 +157,8 @@ private int mPercentCompleted = -1; private long mTimeRemainingInMillis; private boolean mIsResumable = true; - private boolean mIsPaused = false; + private boolean mIsPaused; + private boolean mIsOffTheRecord; public Builder setUrl(String url) { mUrl = url; @@ -249,6 +256,11 @@ return this; } + public Builder setIsOffTheRecord(boolean isOffTheRecord) { + mIsOffTheRecord = isOffTheRecord; + return this; + } + public DownloadInfo build() { return new DownloadInfo(this); } @@ -278,7 +290,8 @@ .setPercentCompleted(downloadInfo.getPercentCompleted()) .setTimeRemainingInMillis(downloadInfo.getTimeRemainingInMillis()) .setIsResumable(downloadInfo.isResumable()) - .setIsPaused(downloadInfo.isPaused()); + .setIsPaused(downloadInfo.isPaused()) + .setIsOffTheRecord(downloadInfo.isOffTheRecord()); return builder; }
diff --git a/content/public/renderer/media_stream_renderer_factory.h b/content/public/renderer/media_stream_renderer_factory.h index 963767c..12d9120 100644 --- a/content/public/renderer/media_stream_renderer_factory.h +++ b/content/public/renderer/media_stream_renderer_factory.h
@@ -11,7 +11,6 @@ #include "base/memory/ref_counted.h" #include "content/public/renderer/media_stream_audio_renderer.h" #include "content/public/renderer/video_frame_provider.h" -#include "url/gurl.h" #include "url/origin.h" namespace base { @@ -19,6 +18,10 @@ class TaskRunner; } // namespace base +namespace blink { +class WebMediaStream; +} // namespace blink + namespace media { class GpuVideoAcceleratorFactories; } // namespace media @@ -34,7 +37,7 @@ virtual ~MediaStreamRendererFactory() {} virtual scoped_refptr<VideoFrameProvider> GetVideoFrameProvider( - const GURL& url, + const blink::WebMediaStream& web_stream, const base::Closure& error_cb, const VideoFrameProvider::RepaintCB& repaint_cb, const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner, @@ -42,7 +45,7 @@ media::GpuVideoAcceleratorFactories* gpu_factories) = 0; virtual scoped_refptr<MediaStreamAudioRenderer> GetAudioRenderer( - const GURL& url, + const blink::WebMediaStream& web_stream, int render_frame_id, const std::string& device_id, const url::Origin& security_origin) = 0;
diff --git a/content/renderer/media/android/webmediaplayer_android.cc b/content/renderer/media/android/webmediaplayer_android.cc index 9131680..d4a05a9 100644 --- a/content/renderer/media/android/webmediaplayer_android.cc +++ b/content/renderer/media/android/webmediaplayer_android.cc
@@ -57,6 +57,7 @@ #include "third_party/WebKit/public/platform/WebGraphicsContext3DProvider.h" #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h" #include "third_party/WebKit/public/platform/WebMediaPlayerEncryptedMediaClient.h" +#include "third_party/WebKit/public/platform/WebMediaPlayerSource.h" #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" #include "third_party/WebKit/public/platform/WebString.h" #include "third_party/WebKit/public/platform/WebURL.h" @@ -297,8 +298,11 @@ } void WebMediaPlayerAndroid::load(LoadType load_type, - const blink::WebURL& url, + const blink::WebMediaPlayerSource& source, CORSMode cors_mode) { + // Only URL or MSE blob URL is supported. + DCHECK(source.isURL()); + blink::WebURL url = source.getAsURL(); if (!defer_load_cb_.is_null()) { defer_load_cb_.Run(base::Bind(&WebMediaPlayerAndroid::DoLoad, weak_factory_.GetWeakPtr(), load_type, url,
diff --git a/content/renderer/media/android/webmediaplayer_android.h b/content/renderer/media/android/webmediaplayer_android.h index a103827..73d8e2c 100644 --- a/content/renderer/media/android/webmediaplayer_android.h +++ b/content/renderer/media/android/webmediaplayer_android.h
@@ -107,7 +107,7 @@ // Resource loading. void load(LoadType load_type, - const blink::WebURL& url, + const blink::WebMediaPlayerSource& source, CORSMode cors_mode) override; // Playback controls.
diff --git a/content/renderer/media/html_video_element_capturer_source_unittest.cc b/content/renderer/media/html_video_element_capturer_source_unittest.cc index b3bbc3b..51c911f 100644 --- a/content/renderer/media/html_video_element_capturer_source_unittest.cc +++ b/content/renderer/media/html_video_element_capturer_source_unittest.cc
@@ -30,7 +30,7 @@ MockWebMediaPlayer() = default; ~MockWebMediaPlayer() override = default; - void load(LoadType, const blink::WebURL&, CORSMode) override {} + void load(LoadType, const blink::WebMediaPlayerSource&, CORSMode) override {} void play() override {} void pause() override {} bool supportsSave() const override { return true; }
diff --git a/content/renderer/media/media_stream_renderer_factory_impl.cc b/content/renderer/media/media_stream_renderer_factory_impl.cc index f31dde1..2bd9799 100644 --- a/content/renderer/media/media_stream_renderer_factory_impl.cc +++ b/content/renderer/media/media_stream_renderer_factory_impl.cc
@@ -15,8 +15,6 @@ #include "content/renderer/render_thread_impl.h" #include "media/base/audio_hardware_config.h" #include "third_party/WebKit/public/platform/WebMediaStream.h" -#include "third_party/WebKit/public/platform/WebURL.h" -#include "third_party/WebKit/public/web/WebMediaStreamRegistry.h" #include "third_party/webrtc/api/mediastreaminterface.h" namespace content { @@ -60,14 +58,12 @@ scoped_refptr<VideoFrameProvider> MediaStreamRendererFactoryImpl::GetVideoFrameProvider( - const GURL& url, + const blink::WebMediaStream& web_stream, const base::Closure& error_cb, const VideoFrameProvider::RepaintCB& repaint_cb, const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner, const scoped_refptr<base::TaskRunner>& worker_task_runner, media::GpuVideoAcceleratorFactories* gpu_factories) { - blink::WebMediaStream web_stream = - blink::WebMediaStreamRegistry::lookupMediaStreamDescriptor(url); DCHECK(!web_stream.isNull()); DVLOG(1) << "MediaStreamRendererFactoryImpl::GetVideoFrameProvider stream:" @@ -87,13 +83,11 @@ scoped_refptr<MediaStreamAudioRenderer> MediaStreamRendererFactoryImpl::GetAudioRenderer( - const GURL& url, + const blink::WebMediaStream& web_stream, int render_frame_id, const std::string& device_id, const url::Origin& security_origin) { - blink::WebMediaStream web_stream = - blink::WebMediaStreamRegistry::lookupMediaStreamDescriptor(url); - + DCHECK(!web_stream.isNull()); blink::WebVector<blink::WebMediaStreamTrack> audio_tracks; web_stream.audioTracks(audio_tracks); if (audio_tracks.isEmpty())
diff --git a/content/renderer/media/media_stream_renderer_factory_impl.h b/content/renderer/media/media_stream_renderer_factory_impl.h index 75f15b18..33519ef 100644 --- a/content/renderer/media/media_stream_renderer_factory_impl.h +++ b/content/renderer/media/media_stream_renderer_factory_impl.h
@@ -16,7 +16,7 @@ ~MediaStreamRendererFactoryImpl() override; scoped_refptr<VideoFrameProvider> GetVideoFrameProvider( - const GURL& url, + const blink::WebMediaStream& web_stream, const base::Closure& error_cb, const VideoFrameProvider::RepaintCB& repaint_cb, const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner, @@ -24,7 +24,7 @@ media::GpuVideoAcceleratorFactories* gpu_factories) override; scoped_refptr<MediaStreamAudioRenderer> GetAudioRenderer( - const GURL& url, + const blink::WebMediaStream& web_stream, int render_frame_id, const std::string& device_id, const url::Origin& security_origin) override;
diff --git a/content/renderer/media/web_media_element_source_utils.cc b/content/renderer/media/web_media_element_source_utils.cc new file mode 100644 index 0000000..4a9a190e --- /dev/null +++ b/content/renderer/media/web_media_element_source_utils.cc
@@ -0,0 +1,26 @@ +// Copyright 2016 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 "content/renderer/media/web_media_element_source_utils.h" + +#include "third_party/WebKit/public/platform/WebMediaPlayerSource.h" +#include "third_party/WebKit/public/platform/WebMediaStream.h" +#include "third_party/WebKit/public/web/WebMediaStreamRegistry.h" + +namespace content { + +blink::WebMediaStream GetWebMediaStreamFromWebMediaPlayerSource( + const blink::WebMediaPlayerSource& source) { + if (source.isMediaStream()) + return source.getAsMediaStream(); + + if (source.isURL()) { + return blink::WebMediaStreamRegistry::lookupMediaStreamDescriptor( + source.getAsURL()); + } + + return blink::WebMediaStream(); +} + +} // namespace content
diff --git a/content/renderer/media/web_media_element_source_utils.h b/content/renderer/media/web_media_element_source_utils.h new file mode 100644 index 0000000..86ca8ce4 --- /dev/null +++ b/content/renderer/media/web_media_element_source_utils.h
@@ -0,0 +1,23 @@ +// Copyright 2016 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 CONTENT_RENDERER_MEDIA_WEB_MEDIA_ELEMENT_SOURCE_UTILS_H_ +#define CONTENT_RENDERER_MEDIA_WEB_MEDIA_ELEMENT_SOURCE_UTILS_H_ + +namespace blink { +class WebMediaPlayerSource; +class WebMediaStream; +} + +namespace content { + +// Obtains a WebMediaStream from a WebMediaPlayerSource. If the +// WebMediaPlayerSource does not contain a WebMediaStream, a null +// WebMediaStream is returned. +blink::WebMediaStream GetWebMediaStreamFromWebMediaPlayerSource( + const blink::WebMediaPlayerSource& source); + +} // namespace content + +#endif // CONTENT_RENDERER_MEDIA_WEB_MEDIA_ELEMENT_SOURCE_UTILS_H_
diff --git a/content/renderer/media/webmediaplayer_ms.cc b/content/renderer/media/webmediaplayer_ms.cc index f9b5a48..c7d09e7d9 100644 --- a/content/renderer/media/webmediaplayer_ms.cc +++ b/content/renderer/media/webmediaplayer_ms.cc
@@ -19,6 +19,7 @@ #include "content/public/renderer/media_stream_audio_renderer.h" #include "content/public/renderer/media_stream_renderer_factory.h" #include "content/public/renderer/video_frame_provider.h" +#include "content/renderer/media/web_media_element_source_utils.h" #include "content/renderer/media/webmediaplayer_ms_compositor.h" #include "content/renderer/render_frame_impl.h" #include "content/renderer/render_thread_impl.h" @@ -26,9 +27,9 @@ #include "media/base/video_frame.h" #include "media/blink/webmediaplayer_util.h" #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h" +#include "third_party/WebKit/public/platform/WebMediaPlayerSource.h" #include "third_party/WebKit/public/platform/WebRect.h" #include "third_party/WebKit/public/platform/WebSize.h" -#include "third_party/WebKit/public/platform/WebURL.h" namespace content { @@ -101,7 +102,7 @@ } void WebMediaPlayerMS::load(LoadType load_type, - const blink::WebURL& url, + const blink::WebMediaPlayerSource& source, CORSMode /*cors_mode*/) { DVLOG(1) << __FUNCTION__; DCHECK(thread_checker_.CalledOnValidThread()); @@ -109,30 +110,32 @@ // TODO(acolwell): Change this to DCHECK_EQ(load_type, LoadTypeMediaStream) // once Blink-side changes land. DCHECK_NE(load_type, LoadTypeMediaSource); + blink::WebMediaStream web_stream = + GetWebMediaStreamFromWebMediaPlayerSource(source); - compositor_.reset(new WebMediaPlayerMSCompositor(compositor_task_runner_, url, - AsWeakPtr())); + compositor_.reset(new WebMediaPlayerMSCompositor(compositor_task_runner_, + web_stream, AsWeakPtr())); SetNetworkState(WebMediaPlayer::NetworkStateLoading); SetReadyState(WebMediaPlayer::ReadyStateHaveNothing); - media_log_->AddEvent(media_log_->CreateLoadEvent(url.string().utf8())); + std::string stream_id = + web_stream.isNull() ? std::string() : web_stream.id().utf8(); + media_log_->AddEvent(media_log_->CreateLoadEvent(stream_id)); video_frame_provider_ = renderer_factory_->GetVideoFrameProvider( - url, - base::Bind(&WebMediaPlayerMS::OnSourceError, AsWeakPtr()), + web_stream, base::Bind(&WebMediaPlayerMS::OnSourceError, AsWeakPtr()), base::Bind(&WebMediaPlayerMS::OnFrameAvailable, AsWeakPtr()), - media_task_runner_, - worker_task_runner_, - gpu_factories_); + media_task_runner_, worker_task_runner_, gpu_factories_); RenderFrame* const frame = RenderFrame::FromWebFrame(frame_); if (frame) { // Report UMA and RAPPOR metrics. - media::ReportMetrics(load_type, GURL(url), frame_->getSecurityOrigin()); + GURL url = source.isURL() ? GURL(source.getAsURL()) : GURL(); + media::ReportMetrics(load_type, url, frame_->getSecurityOrigin()); audio_renderer_ = renderer_factory_->GetAudioRenderer( - url, frame->GetRoutingID(), initial_audio_output_device_id_, + web_stream, frame->GetRoutingID(), initial_audio_output_device_id_, initial_security_origin_); }
diff --git a/content/renderer/media/webmediaplayer_ms.h b/content/renderer/media/webmediaplayer_ms.h index 4678edd..5615be2 100644 --- a/content/renderer/media/webmediaplayer_ms.h +++ b/content/renderer/media/webmediaplayer_ms.h
@@ -85,7 +85,7 @@ ~WebMediaPlayerMS() override; void load(LoadType load_type, - const blink::WebURL& url, + const blink::WebMediaPlayerSource& source, CORSMode cors_mode) override; // Playback controls.
diff --git a/content/renderer/media/webmediaplayer_ms_compositor.cc b/content/renderer/media/webmediaplayer_ms_compositor.cc index bbc2586..55819d3 100644 --- a/content/renderer/media/webmediaplayer_ms_compositor.cc +++ b/content/renderer/media/webmediaplayer_ms_compositor.cc
@@ -5,6 +5,7 @@ #include "content/renderer/media/webmediaplayer_ms_compositor.h" #include <stdint.h> +#include <string> #include "base/command_line.h" #include "base/hash.h" @@ -22,8 +23,6 @@ #include "third_party/WebKit/public/platform/WebMediaStream.h" #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" -#include "third_party/WebKit/public/platform/WebURL.h" -#include "third_party/WebKit/public/web/WebMediaStreamRegistry.h" #include "third_party/libyuv/include/libyuv/convert.h" #include "third_party/libyuv/include/libyuv/video_common.h" @@ -116,7 +115,7 @@ WebMediaPlayerMSCompositor::WebMediaPlayerMSCompositor( const scoped_refptr<base::SingleThreadTaskRunner>& compositor_task_runner, - const blink::WebURL& url, + const blink::WebMediaStream& web_stream, const base::WeakPtr<WebMediaPlayerMS>& player) : compositor_task_runner_(compositor_task_runner), player_(player), @@ -129,8 +128,6 @@ weak_ptr_factory_(this) { main_message_loop_ = base::MessageLoop::current(); - const blink::WebMediaStream web_stream( - blink::WebMediaStreamRegistry::lookupMediaStreamDescriptor(url)); blink::WebVector<blink::WebMediaStreamTrack> video_tracks; if (!web_stream.isNull()) web_stream.videoTracks(video_tracks); @@ -148,7 +145,9 @@ } // Just for logging purpose. - const uint32_t hash_value = base::Hash(url.string().utf8()); + std::string stream_id = + web_stream.isNull() ? std::string() : web_stream.id().utf8(); + const uint32_t hash_value = base::Hash(stream_id); serial_ = (hash_value << 1) | (remote_video ? 1 : 0); }
diff --git a/content/renderer/media/webmediaplayer_ms_compositor.h b/content/renderer/media/webmediaplayer_ms_compositor.h index 5c2c4d1..927c39e8 100644 --- a/content/renderer/media/webmediaplayer_ms_compositor.h +++ b/content/renderer/media/webmediaplayer_ms_compositor.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 CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_MS_COMPOSITOR_H -#define CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_MS_COMPOSITOR_H +#ifndef CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_MS_COMPOSITOR_H_ +#define CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_MS_COMPOSITOR_H_ #include <stddef.h> @@ -23,7 +23,7 @@ } namespace blink { -class WebURL; +class WebMediaStream; } namespace gfx { @@ -56,7 +56,7 @@ // we enable algorithm or not. WebMediaPlayerMSCompositor( const scoped_refptr<base::SingleThreadTaskRunner>& compositor_task_runner, - const blink::WebURL& url, + const blink::WebMediaStream& web_stream, const base::WeakPtr<WebMediaPlayerMS>& player); ~WebMediaPlayerMSCompositor() override; @@ -154,6 +154,6 @@ DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerMSCompositor); }; -} +} // namespace content -#endif // CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_MS_COMPOSITOR_H +#endif // CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_MS_COMPOSITOR_H_
diff --git a/content/renderer/media/webmediaplayer_ms_unittest.cc b/content/renderer/media/webmediaplayer_ms_unittest.cc index d930ddc7..4eef03a 100644 --- a/content/renderer/media/webmediaplayer_ms_unittest.cc +++ b/content/renderer/media/webmediaplayer_ms_unittest.cc
@@ -12,6 +12,7 @@ #include "media/base/video_frame.h" #include "third_party/WebKit/public/platform/WebMediaPlayer.h" #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h" +#include "third_party/WebKit/public/platform/WebMediaPlayerSource.h" namespace content { @@ -273,7 +274,7 @@ message_loop_controller_(message_loop_controller) {} scoped_refptr<VideoFrameProvider> GetVideoFrameProvider( - const GURL& url, + const blink::WebMediaStream& web_stream, const base::Closure& error_cb, const VideoFrameProvider::RepaintCB& repaint_cb, const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner, @@ -285,7 +286,7 @@ } scoped_refptr<MediaStreamAudioRenderer> GetAudioRenderer( - const GURL& url, + const blink::WebMediaStream& web_stream, int render_frame_id, const std::string& device_id, const url::Origin& security_origin) override { @@ -299,7 +300,7 @@ }; scoped_refptr<VideoFrameProvider> MockRenderFactory::GetVideoFrameProvider( - const GURL& url, + const blink::WebMediaStream& web_stream, const base::Closure& error_cb, const VideoFrameProvider::RepaintCB& repaint_cb, const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner, @@ -435,7 +436,8 @@ *this, DoNetworkStateChanged(blink::WebMediaPlayer::NetworkStateLoading)); EXPECT_CALL( *this, DoReadyStateChanged(blink::WebMediaPlayer::ReadyStateHaveNothing)); - player_.load(blink::WebMediaPlayer::LoadTypeURL, blink::WebURL(), + player_.load(blink::WebMediaPlayer::LoadTypeURL, + blink::WebMediaPlayerSource(), blink::WebMediaPlayer::CORSModeUnspecified); compositor_ = player_.compositor_.get(); EXPECT_TRUE(!!compositor_);
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc index 2628d87..7336204 100644 --- a/content/renderer/render_frame_impl.cc +++ b/content/renderer/render_frame_impl.cc
@@ -104,6 +104,7 @@ #include "content/renderer/media/render_media_log.h" #include "content/renderer/media/renderer_webmediaplayer_delegate.h" #include "content/renderer/media/user_media_client_impl.h" +#include "content/renderer/media/web_media_element_source_utils.h" #include "content/renderer/media/webmediaplayer_ms.h" #include "content/renderer/mojo/service_registry_js_wrapper.h" #include "content/renderer/mojo_bindings_controller.h" @@ -153,6 +154,7 @@ #include "third_party/WebKit/public/platform/WebCachePolicy.h" #include "third_party/WebKit/public/platform/WebData.h" #include "third_party/WebKit/public/platform/WebMediaPlayer.h" +#include "third_party/WebKit/public/platform/WebMediaPlayerSource.h" #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h" #include "third_party/WebKit/public/platform/WebString.h" @@ -2411,7 +2413,7 @@ } blink::WebMediaPlayer* RenderFrameImpl::createMediaPlayer( - const blink::WebURL& url, + const blink::WebMediaPlayerSource& source, WebMediaPlayerClient* client, WebMediaPlayerEncryptedMediaClient* encrypted_client, WebContentDecryptionModule* initial_cdm, @@ -2423,13 +2425,17 @@ contains_media_player_ = true; } #endif // defined(VIDEO_HOLE) - - blink::WebMediaStream web_stream( - blink::WebMediaStreamRegistry::lookupMediaStreamDescriptor(url)); + blink::WebMediaStream web_stream = + GetWebMediaStreamFromWebMediaPlayerSource(source); if (!web_stream.isNull()) return CreateWebMediaPlayerForMediaStream(client, sink_id, frame_->getSecurityOrigin()); + // If |source| was not a MediaStream, it must be a URL. + // TODO(guidou): Fix this when support for other srcObject types is added. + DCHECK(source.isURL()); + blink::WebURL url = source.getAsURL(); + RenderThreadImpl* render_thread = RenderThreadImpl::current(); scoped_refptr<media::SwitchableAudioRendererSink> audio_renderer_sink =
diff --git a/content/renderer/render_frame_impl.h b/content/renderer/render_frame_impl.h index fbf359699..62540fd6 100644 --- a/content/renderer/render_frame_impl.h +++ b/content/renderer/render_frame_impl.h
@@ -421,7 +421,7 @@ blink::WebPlugin* createPlugin(blink::WebLocalFrame* frame, const blink::WebPluginParams& params) override; blink::WebMediaPlayer* createMediaPlayer( - const blink::WebURL& url, + const blink::WebMediaPlayerSource& source, blink::WebMediaPlayerClient* client, blink::WebMediaPlayerEncryptedMediaClient* encrypted_client, blink::WebContentDecryptionModule* initial_cdm,
diff --git a/content/shell/renderer/layout_test/test_media_stream_renderer_factory.cc b/content/shell/renderer/layout_test/test_media_stream_renderer_factory.cc index 758312e..641b38cb 100644 --- a/content/shell/renderer/layout_test/test_media_stream_renderer_factory.cc +++ b/content/shell/renderer/layout_test/test_media_stream_renderer_factory.cc
@@ -18,14 +18,12 @@ static const int kVideoCaptureHeight = 288; static const int kVideoCaptureFrameDurationMs = 33; -bool IsMockMediaStreamWithVideo(const WebURL& url) { +bool IsMockMediaStreamWithVideo(const WebMediaStream& web_stream) { #if ENABLE_WEBRTC - WebMediaStream descriptor( - WebMediaStreamRegistry::lookupMediaStreamDescriptor(url)); - if (descriptor.isNull()) + if (web_stream.isNull()) return false; WebVector<WebMediaStreamTrack> video_tracks; - descriptor.videoTracks(video_tracks); + web_stream.videoTracks(video_tracks); return video_tracks.size() > 0; #else return false; @@ -42,13 +40,13 @@ scoped_refptr<VideoFrameProvider> TestMediaStreamRendererFactory::GetVideoFrameProvider( - const GURL& url, + const blink::WebMediaStream& web_stream, const base::Closure& error_cb, const VideoFrameProvider::RepaintCB& repaint_cb, const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner, const scoped_refptr<base::TaskRunner>& worker_task_runner, media::GpuVideoAcceleratorFactories* gpu_factories) { - if (!IsMockMediaStreamWithVideo(url)) + if (!IsMockMediaStreamWithVideo(web_stream)) return NULL; return new TestVideoFrameProvider( @@ -60,7 +58,7 @@ scoped_refptr<MediaStreamAudioRenderer> TestMediaStreamRendererFactory::GetAudioRenderer( - const GURL& url, + const blink::WebMediaStream& web_stream, int render_frame_id, const std::string& device_id, const url::Origin& security_origin) {
diff --git a/content/shell/renderer/layout_test/test_media_stream_renderer_factory.h b/content/shell/renderer/layout_test/test_media_stream_renderer_factory.h index 9acc7b65..911106a 100644 --- a/content/shell/renderer/layout_test/test_media_stream_renderer_factory.h +++ b/content/shell/renderer/layout_test/test_media_stream_renderer_factory.h
@@ -7,7 +7,6 @@ #include "base/callback_forward.h" #include "content/public/renderer/media_stream_renderer_factory.h" -#include "third_party/WebKit/public/platform/WebURL.h" namespace content { @@ -20,7 +19,7 @@ // MediaStreamRendererFactory implementation. scoped_refptr<VideoFrameProvider> GetVideoFrameProvider( - const GURL& url, + const blink::WebMediaStream& web_stream, const base::Closure& error_cb, const VideoFrameProvider::RepaintCB& repaint_cb, const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner, @@ -28,7 +27,7 @@ media::GpuVideoAcceleratorFactories* gpu_factories) override; scoped_refptr<MediaStreamAudioRenderer> GetAudioRenderer( - const GURL& url, + const blink::WebMediaStream& web_stream, int render_frame_id, const std::string& device_id, const url::Origin& security_origin) override;
diff --git a/content/zygote/zygote_main_linux.cc b/content/zygote/zygote_main_linux.cc index da5a1e8..43b2578 100644 --- a/content/zygote/zygote_main_linux.cc +++ b/content/zygote/zygote_main_linux.cc
@@ -22,6 +22,7 @@ #include "base/bind.h" #include "base/command_line.h" #include "base/compiler_specific.h" +#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_vector.h" #include "base/native_library.h" #include "base/pickle.h"
diff --git a/ios/chrome/browser/passwords/credential_manager.h b/ios/chrome/browser/passwords/credential_manager.h index da6c4d6..68dcf72 100644 --- a/ios/chrome/browser/passwords/credential_manager.h +++ b/ios/chrome/browser/passwords/credential_manager.h
@@ -58,9 +58,11 @@ bool IsZeroClickAllowed() const override; GURL GetOrigin() const override; void SendCredential( - int id, + const password_manager::SendCredentialCallback& send_callback, const password_manager::CredentialInfo& credential) override; - void SendPasswordForm(int id, const autofill::PasswordForm* form) override; + void SendPasswordForm( + const password_manager::SendCredentialCallback& send_callback, + const autofill::PasswordForm* form) override; password_manager::PasswordManagerClient* client() const override; autofill::PasswordForm GetSynthesizedFormForOrigin() const override; @@ -84,6 +86,9 @@ ERROR_TYPE_SECURITY_ERROR_UNTRUSTED_ORIGIN, }; + void SendCredentialByID(int request_id, + const password_manager::CredentialInfo& credential); + // Sends a message via |js_manager_| to resolve the JavaScript Promise // associated with |request_id|. Invoked after a page-initiated credential // event is acknowledged by the PasswordStore.
diff --git a/ios/chrome/browser/passwords/credential_manager.mm b/ios/chrome/browser/passwords/credential_manager.mm index b1e86fd..1389ebae 100644 --- a/ios/chrome/browser/passwords/credential_manager.mm +++ b/ios/chrome/browser/passwords/credential_manager.mm
@@ -117,7 +117,7 @@ // Invoked when the page invokes navigator.credentials.request(), this // function will attempt to retrieve a Credential from the PasswordStore that // meets the specified parameters and, if successful, send it back to the page - // via SendCredential. + // via SendCredentialByID. DCHECK_GE(request_id, 0); password_manager::PasswordStore* store = GetPasswordStore(); @@ -139,7 +139,7 @@ // available, send back an empty credential. if (zero_click_only && !IsZeroClickAllowed()) { base::MessageLoop::current()->PostTask( - FROM_HERE, base::Bind(&CredentialManager::SendCredential, + FROM_HERE, base::Bind(&CredentialManager::SendCredentialByID, weak_factory_.GetWeakPtr(), request_id, password_manager::CredentialInfo())); return; @@ -161,8 +161,9 @@ std::vector<std::string> realms; pending_request_.reset( new password_manager::CredentialManagerPendingRequestTask( - this, request_id, zero_click_only, page_url, true, federation_urls, - realms)); + this, base::Bind(&CredentialManager::SendCredentialByID, + base::Unretained(this), request_id), + zero_click_only, page_url, true, federation_urls, realms)); store->GetAutofillableLogins(pending_request_.get()); } @@ -269,6 +270,12 @@ } void CredentialManager::SendCredential( + const password_manager::SendCredentialCallback& send_callback, + const password_manager::CredentialInfo& credential) { + send_callback.Run(credential); +} + +void CredentialManager::SendCredentialByID( int request_id, const password_manager::CredentialInfo& credential) { // Invoked when the asynchronous interaction with the PasswordStore completes, @@ -284,8 +291,9 @@ }]; } -void CredentialManager::SendPasswordForm(int request_id, - const autofill::PasswordForm* form) { +void CredentialManager::SendPasswordForm( + const password_manager::SendCredentialCallback& send_callback, + const autofill::PasswordForm* form) { password_manager::CredentialInfo info; if (form) { password_manager::CredentialType type_to_return = @@ -295,7 +303,7 @@ info = password_manager::CredentialInfo(*form, type_to_return); // TODO(vasilii): update |skip_zero_click| in the store (crbug.com/594110). } - SendCredential(request_id, info); + SendCredential(send_callback, info); } password_manager::PasswordManagerClient* CredentialManager::client() const {
diff --git a/ipc/ipc_message_start.h b/ipc/ipc_message_start.h index c3abddc0..ea1f7b998 100644 --- a/ipc/ipc_message_start.h +++ b/ipc/ipc_message_start.h
@@ -101,7 +101,6 @@ OzoneGpuMsgStart, ChromeUtilityExtensionsMsgStart, PlatformNotificationMsgStart, - CredentialManagerMsgStart, PDFMsgStart, ManifestManagerMsgStart, ExtensionUtilityMsgStart,
diff --git a/media/blink/webmediaplayer_impl.cc b/media/blink/webmediaplayer_impl.cc index b0affc0..be941de9 100644 --- a/media/blink/webmediaplayer_impl.cc +++ b/media/blink/webmediaplayer_impl.cc
@@ -50,6 +50,7 @@ #include "third_party/WebKit/public/platform/WebEncryptedMediaTypes.h" #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h" #include "third_party/WebKit/public/platform/WebMediaPlayerEncryptedMediaClient.h" +#include "third_party/WebKit/public/platform/WebMediaPlayerSource.h" #include "third_party/WebKit/public/platform/WebMediaSource.h" #include "third_party/WebKit/public/platform/WebRect.h" #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" @@ -270,8 +271,12 @@ media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_DESTROYED)); } -void WebMediaPlayerImpl::load(LoadType load_type, const blink::WebURL& url, +void WebMediaPlayerImpl::load(LoadType load_type, + const blink::WebMediaPlayerSource& source, CORSMode cors_mode) { + // Only URL or MSE blob URL is supported. + DCHECK(source.isURL()); + blink::WebURL url = source.getAsURL(); DVLOG(1) << __FUNCTION__ << "(" << load_type << ", " << url << ", " << cors_mode << ")"; if (!defer_load_cb_.is_null()) {
diff --git a/media/blink/webmediaplayer_impl.h b/media/blink/webmediaplayer_impl.h index 25a1e72..027841b 100644 --- a/media/blink/webmediaplayer_impl.h +++ b/media/blink/webmediaplayer_impl.h
@@ -96,7 +96,7 @@ ~WebMediaPlayerImpl() override; void load(LoadType load_type, - const blink::WebURL& url, + const blink::WebMediaPlayerSource& source, CORSMode cors_mode) override; // Playback controls.
diff --git a/net/websockets/websocket_event_interface.h b/net/websockets/websocket_event_interface.h index 25e12a0..1434841 100644 --- a/net/websockets/websocket_event_interface.h +++ b/net/websockets/websocket_event_interface.h
@@ -12,6 +12,7 @@ #include "base/compiler_specific.h" // for WARN_UNUSED_RESULT #include "base/macros.h" +#include "base/memory/scoped_ptr.h" #include "net/base/net_export.h" class GURL;
diff --git a/services/README.md b/services/README.md new file mode 100644 index 0000000..32fc8203 --- /dev/null +++ b/services/README.md
@@ -0,0 +1,38 @@ +Chrome Platform Services +==== + +### Overview + +This directory contains Chrome Platform Services. If you think of Chrome as a +"portable OS," Chrome Platform Services can be thought of as that OS' "system +services". + +Roughly each subdirectory here corresponds to a service that: + + * is a client of `//services/shell` with its own unique Identity. + * could logically run a standalone process for security/performance isolation + benefits depending on the constraints of the host OS. + +### Service Directory Structure + +Individual services are structured like so: + + //services/foo/ <-- Implementation code, may have subdirs. + /public/ + /cpp/ <-- C++ client libraries (optional) + /interfaces/ <-- Mojom interfaces + +### Dependencies + +Code within `//services` may only depend on each other via each other's +`/public/` directories, i.e. implementation code cannot be shared directly. + +Service code should also take care to tightly limit the dependencies on static +libraries from outside of `//services`. Dependencies to large platform +layers like `//content`, `//chrome` or `//third_party/WebKit` must be avoided. + +### Physical Packaging + +Note that while it may be possible to build a discrete physical package (DSO) +for each service, products consuming these services may package them +differently, e.g. by combining them into a single package.
diff --git a/testing/buildbot/chromium.fyi.json b/testing/buildbot/chromium.fyi.json index 9ee3d6d..54aaaa5 100644 --- a/testing/buildbot/chromium.fyi.json +++ b/testing/buildbot/chromium.fyi.json
@@ -748,6 +748,371 @@ } ] }, + "CFI Linux ToT": { + "gtest_tests": [ + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "accessibility_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "angle_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "app_list_shower_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "app_list_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "app_shell_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "aura_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "base_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "blimp_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "blink_heap_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "blink_platform_unittests" + }, + { + "args": [ + "--gtest_filter=-SaveType/SavePageMultiFrameBrowserTest.ObjectElements/0" + ], + "swarming": { + "can_use_on_swarming_builders": true, + "shards": 10 + }, + "test": "browser_tests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "cacheinvalidation_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "cast_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "cc_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "chromedriver_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "components_browsertests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "components_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "compositor_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "content_browsertests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "content_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "crypto_unittests" + }, + { + "test": "dbus_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "device_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "display_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "events_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "extensions_browsertests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "extensions_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "gcm_unit_tests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "gfx_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "gin_unittests" + }, + { + "test": "gl_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "gn_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "google_apis_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "gpu_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "interactive_ui_tests" + }, + { + "test": "ipc_mojo_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "ipc_tests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "jingle_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "media_blink_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "media_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "midi_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "mojo_common_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "mojo_public_bindings_unittests" + }, + { + "test": "mojo_public_system_unittests" + }, + { + "test": "mojo_system_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "nacl_loader_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "net_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "ppapi_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "printing_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "remoting_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "sandbox_linux_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "skia_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "sql_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "sync_unit_tests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "ui_base_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "ui_touch_selection_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "unit_tests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "url_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "views_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "webkit_unit_tests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "wm_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "wtf_unittests" + } + ] + }, "Chromium Mac 10.11": { "gtest_tests": [ {
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector/elements/event-listeners-framework-with-service-worker-expected.txt b/third_party/WebKit/LayoutTests/http/tests/inspector/elements/event-listeners-framework-with-service-worker-expected.txt index 7017b01..a1b29e9 100644 --- a/third_party/WebKit/LayoutTests/http/tests/inspector/elements/event-listeners-framework-with-service-worker-expected.txt +++ b/third_party/WebKit/LayoutTests/http/tests/inspector/elements/event-listeners-framework-with-service-worker-expected.txt
@@ -12,6 +12,7 @@ == normal [expanded] WindowRemoveevent-listeners-framework-with-service-worker.html:56 useCapture: false + passive: false handler: function onload(event) { runTest() }
diff --git a/third_party/WebKit/LayoutTests/inspector/console/command-line-api-getEventListeners-expected.txt b/third_party/WebKit/LayoutTests/inspector/console/command-line-api-getEventListeners-expected.txt index 7688bbd..cc532cb 100644 --- a/third_party/WebKit/LayoutTests/inspector/console/command-line-api-getEventListeners-expected.txt +++ b/third_party/WebKit/LayoutTests/inspector/console/command-line-api-getEventListeners-expected.txt
@@ -6,22 +6,34 @@ [page] keydown: { [page] 0: { [page] listener: function listener1() { } -[page] remove: function () {node.removeEventListener(this.type,this.listener,this.useCapture);} +[page] passive: false +[page] remove: function () {removeEventListenerWrapper(node,this.type,this.listener,this.useCapture,this.passive);} [page] type: "keydown" [page] useCapture: false [page] } [page] 1: { [page] listener: function listener2() { } -[page] remove: function () {node.removeEventListener(this.type,this.listener,this.useCapture);} +[page] passive: false +[page] remove: function () {removeEventListenerWrapper(node,this.type,this.listener,this.useCapture,this.passive);} [page] type: "keydown" [page] useCapture: true [page] } [page] } +[page] wheel: { +[page] 0: { +[page] listener: function listener2() { } +[page] passive: true +[page] remove: function () {removeEventListenerWrapper(node,this.type,this.listener,this.useCapture,this.passive);} +[page] type: "wheel" +[page] useCapture: false +[page] } +[page] } [page] - inner after a removal - [page] keydown: { [page] 0: { [page] listener: function listener2() { } -[page] remove: function () {node.removeEventListener(this.type,this.listener,this.useCapture);} +[page] passive: false +[page] remove: function () {removeEventListenerWrapper(node,this.type,this.listener,this.useCapture,this.passive);} [page] type: "keydown" [page] useCapture: true [page] } @@ -30,7 +42,8 @@ [page] keydown: { [page] 0: { [page] listener: function listener2() { } -[page] remove: function () {node.removeEventListener(this.type,this.listener,this.useCapture);} +[page] passive: false +[page] remove: function () {removeEventListenerWrapper(node,this.type,this.listener,this.useCapture,this.passive);} [page] type: "keydown" [page] useCapture: true [page] } @@ -38,7 +51,8 @@ [page] mousedown: { [page] 0: { [page] listener: function listener2() { } -[page] remove: function () {node.removeEventListener(this.type,this.listener,this.useCapture);} +[page] passive: false +[page] remove: function () {removeEventListenerWrapper(node,this.type,this.listener,this.useCapture,this.passive);} [page] type: "mousedown" [page] useCapture: true [page] } @@ -46,7 +60,8 @@ [page] mousemove: { [page] 0: { [page] listener: function listener1() { } -[page] remove: function () {node.removeEventListener(this.type,this.listener,this.useCapture);} +[page] passive: false +[page] remove: function () {removeEventListenerWrapper(node,this.type,this.listener,this.useCapture,this.passive);} [page] type: "mousemove" [page] useCapture: false [page] } @@ -55,7 +70,8 @@ [page] click: { [page] 0: { [page] listener: function onclick(event) { alert(1) } -[page] remove: function () {node.removeEventListener(this.type,this.listener,this.useCapture);} +[page] passive: false +[page] remove: function () {removeEventListenerWrapper(node,this.type,this.listener,this.useCapture,this.passive);} [page] type: "click" [page] useCapture: false [page] } @@ -63,7 +79,8 @@ [page] mouseover: { [page] 0: { [page] listener: function onmouseover(event) { listener2() } -[page] remove: function () {node.removeEventListener(this.type,this.listener,this.useCapture);} +[page] passive: false +[page] remove: function () {removeEventListenerWrapper(node,this.type,this.listener,this.useCapture,this.passive);} [page] type: "mouseover" [page] useCapture: false [page] } @@ -72,7 +89,8 @@ [page] load: { [page] 0: { [page] listener: function onload(event) { runTest() } -[page] remove: function () {node.removeEventListener(this.type,this.listener,this.useCapture);} +[page] passive: false +[page] remove: function () {removeEventListenerWrapper(node,this.type,this.listener,this.useCapture,this.passive);} [page] type: "load" [page] useCapture: false [page] } @@ -80,7 +98,8 @@ [page] popstate: { [page] 0: { [page] listener: function listener1() { } -[page] remove: function () {node.removeEventListener(this.type,this.listener,this.useCapture);} +[page] passive: false +[page] remove: function () {removeEventListenerWrapper(node,this.type,this.listener,this.useCapture,this.passive);} [page] type: "popstate" [page] useCapture: false [page] }
diff --git a/third_party/WebKit/LayoutTests/inspector/console/command-line-api-getEventListeners.html b/third_party/WebKit/LayoutTests/inspector/console/command-line-api-getEventListeners.html index 860e42f..cbd6791 100644 --- a/third_party/WebKit/LayoutTests/inspector/console/command-line-api-getEventListeners.html +++ b/third_party/WebKit/LayoutTests/inspector/console/command-line-api-getEventListeners.html
@@ -34,6 +34,7 @@ document.getElementById("inner").addEventListener("keydown", listener1, false); document.getElementById("inner").addEventListener("keydown", listener2, true); +document.getElementById("inner").addEventListener("wheel", listener2, {"passive": true}); document.getElementById("outer").addEventListener("mousemove", listener1, false); document.getElementById("outer").addEventListener("mousedown", listener2, true); document.getElementById("outer").addEventListener("keydown", listener2, true); @@ -82,6 +83,7 @@ var innerListeners = getEventListeners(document.getElementById("inner")); dumpObject(innerListeners); innerListeners.keydown[0].remove(); + innerListeners.wheel[0].remove(); output("- inner after a removal -"); dumpObject(getEventListeners(document.getElementById("inner"))); output("- outer -");
diff --git a/third_party/WebKit/LayoutTests/inspector/elements/event-listener-sidebar-custom-framework-expected.txt b/third_party/WebKit/LayoutTests/inspector/elements/event-listener-sidebar-custom-framework-expected.txt index 4843836f..2802416 100644 --- a/third_party/WebKit/LayoutTests/inspector/elements/event-listener-sidebar-custom-framework-expected.txt +++ b/third_party/WebKit/LayoutTests/inspector/elements/event-listener-sidebar-custom-framework-expected.txt
@@ -7,6 +7,7 @@ == frameworkInternal [expanded] button#inspectedNodeRemoveevent-listener-sidebar-custom-framework.html:23 useCapture: false + passive: false handler: function internalHandler(e) { console.log("I'm internal event handler"); @@ -20,6 +21,7 @@ == frameworkUser [expanded] button#inspectedNodeevent-listener-sidebar-custom-framework.html:13 useCapture: true + passive: false handler: function customFirstEventListener(e) { console.log("I'm first custom event listener"); @@ -29,6 +31,7 @@ == frameworkUser [expanded] button#inspectedNodeevent-listener-sidebar-custom-framework.html:18 useCapture: false + passive: false handler: function customSecondEventListener(e) { console.log("I'm second custom event listener"); @@ -39,6 +42,7 @@ == normal [expanded] button#inspectedNodeRemoveevent-listener-sidebar-custom-framework.html:23 useCapture: false + passive: false handler: function internalHandler(e) { console.log("I'm internal event handler"); @@ -54,7 +58,7 @@ internal handler isn't a function or empty internal handler isn't a function or empty fetcher call produced error: Error in getter - event listener's type isn't string or empty, event listener's useCapture isn't boolean or undefined, event listener's handler isn't a function or empty + event listener's type isn't string or empty, event listener's useCapture isn't boolean or undefined, event listener's passive isn't boolean or undefined, event listener's handler isn't a function or empty Error in getter Error in getter internal handler isn't a function or empty
diff --git a/third_party/WebKit/LayoutTests/inspector/elements/event-listener-sidebar-custom-framework.html b/third_party/WebKit/LayoutTests/inspector/elements/event-listener-sidebar-custom-framework.html index bc7e254..114aa31e 100644 --- a/third_party/WebKit/LayoutTests/inspector/elements/event-listener-sidebar-custom-framework.html +++ b/third_party/WebKit/LayoutTests/inspector/elements/event-listener-sidebar-custom-framework.html
@@ -36,8 +36,8 @@ function frameworkEventListeners(node) { if (node === inspectedNode) { - return {eventListeners: [{type: "customFirst", useCapture: true, handler: customFirstEventListener}, - {type: "customSecond", useCapture: false, handler: customSecondEventListener}], + return {eventListeners: [{type: "customFirst", useCapture: true, passive: false, handler: customFirstEventListener}, + {type: "customSecond", useCapture: false, passive: false, handler: customSecondEventListener}], internalHandlers: [internalHandler]}; } return {eventListeners: []}; @@ -141,4 +141,4 @@ </p> <button id="inspectedNode">Inspect Me</button> </body> -</html> \ No newline at end of file +</html>
diff --git a/third_party/WebKit/LayoutTests/inspector/elements/event-listener-sidebar-expected.txt b/third_party/WebKit/LayoutTests/inspector/elements/event-listener-sidebar-expected.txt index c2bd745..fa7d728a 100644 --- a/third_party/WebKit/LayoutTests/inspector/elements/event-listener-sidebar-expected.txt +++ b/third_party/WebKit/LayoutTests/inspector/elements/event-listener-sidebar-expected.txt
@@ -6,54 +6,72 @@ == normal [expanded] documentRemoveevent-listener-sidebar.html:6 useCapture: false + passive: false handler: function documentClickHandler(event) { console.log("click - document - attribute"); } == normal [expanded] documentRemoveevent-listener-sidebar.html:31 useCapture: true + passive: false handler: function () { console.log("click - document - handleEvent"); } == normal [expanded] documentRemoveevent-listener-sidebar.html:25 useCapture: true + passive: false handler: function ObjectHandler() { document.addEventListener("click", this, true); } == normal [expanded] documentRemoveevent-listener-sidebar.html:19 useCapture: true + passive: false handler: function (event) { console.log("click - document - capturing"); } == normal [expanded] button#nodeRemoveevent-listener-sidebar.html:17 useCapture: false + passive: false handler: function (event) { console.log("click - button - bubbling (registered after attribute)"); } == normal [expanded] button#nodeRemoveevent-listener-sidebar.html:16 useCapture: false + passive: false handler: function (event) { console.log("click - button - attribute"); } == normal [expanded] button#nodeRemoveevent-listener-sidebar.html:12 useCapture: false + passive: false handler: function clickHandler(event) { console.log("click - button - bubbling (registered before attribute)"); } == normal [expanded] button#nodeRemoveevent-listener-sidebar.html:15 useCapture: true + passive: false handler: function (event) { console.log("click - button - capturing"); } ======== custom event ======== == normal [expanded] bodyRemoveevent-listener-sidebar.html:10 useCapture: true + passive: false handler: function f() {} ======== hover ======== == normal [expanded] button#nodeRemoveevent-listener-sidebar.html:14 useCapture: false + passive: false handler: function hoverHandler(event) { console.log("hover - button - bubbling"); } ======== load ======== == normal -[expanded] WindowRemoveevent-listener-sidebar.html:73 +[expanded] WindowRemoveevent-listener-sidebar.html:76 useCapture: false + passive: false handler: function onload(event) { onloadHandler() } + +======== wheel ======== +== normal +[expanded] bodyRemoveevent-listener-sidebar.html:10 + useCapture: false + passive: true + handler: function f() {} Listeners for selected node only(should be no listeners):
diff --git a/third_party/WebKit/LayoutTests/inspector/elements/event-listener-sidebar-jquery1-expected.txt b/third_party/WebKit/LayoutTests/inspector/elements/event-listener-sidebar-jquery1-expected.txt index cbb537a..d529aba 100644 --- a/third_party/WebKit/LayoutTests/inspector/elements/event-listener-sidebar-jquery1-expected.txt +++ b/third_party/WebKit/LayoutTests/inspector/elements/event-listener-sidebar-jquery1-expected.txt
@@ -6,24 +6,29 @@ == frameworkUser [expanded] button#nodeRemoveevent-listener-sidebar-jquery1.html:11 useCapture: true + passive: false handler: function (){ console.log("second jquery"); } == frameworkUser [expanded] button#nodeRemoveevent-listener-sidebar-jquery1.html:10 useCapture: true + passive: false handler: function (){ console.log("first jquery"); } == normal [expanded] button#nodeRemoveevent-listener-sidebar-jquery1.html:12 useCapture: false + passive: false handler: function () { console.log("addEventListener"); } == frameworkInternal [expanded] button#nodeRemovejquery-1.11.3.min.js:4 useCapture: false + passive: false handler: function (a){return typeof m===K||a&&m.event.triggered===a.type?void 0:m.event.dispatch.apply(k.elem,arguments)} ======== load ======== == normal [expanded] WindowRemoveevent-listener-sidebar-jquery1.html:36 useCapture: false + passive: false handler: function onload(event) { onloadHandler() }
diff --git a/third_party/WebKit/LayoutTests/inspector/elements/event-listener-sidebar-jquery2-expected.txt b/third_party/WebKit/LayoutTests/inspector/elements/event-listener-sidebar-jquery2-expected.txt index 74a03804..1b5e7f0e 100644 --- a/third_party/WebKit/LayoutTests/inspector/elements/event-listener-sidebar-jquery2-expected.txt +++ b/third_party/WebKit/LayoutTests/inspector/elements/event-listener-sidebar-jquery2-expected.txt
@@ -6,28 +6,34 @@ == frameworkUser [expanded] button#nodeRemoveevent-listener-sidebar-jquery2.html:11 useCapture: true + passive: false handler: function (){ console.log("second jquery"); } == frameworkUser [expanded] button#nodeRemoveevent-listener-sidebar-jquery2.html:10 useCapture: true + passive: false handler: function (){ console.log("first jquery"); } == normal [expanded] button#nodeRemoveevent-listener-sidebar-jquery2.html:13 useCapture: false + passive: false handler: function () { constole.log("onclick"); } == normal [expanded] button#nodeRemoveevent-listener-sidebar-jquery2.html:12 useCapture: false + passive: false handler: function () { console.log("addEventListener"); } == frameworkInternal [expanded] button#nodeRemovejquery-2.1.4.min.js:3 useCapture: false + passive: false handler: function (b){return typeof n!==U&&n.event.triggered!==b.type?n.event.dispatch.apply(a,arguments):void 0} ======== load ======== == normal [expanded] WindowRemoveevent-listener-sidebar-jquery2.html:52 useCapture: false + passive: false handler: function onload(event) { onloadHandler() }
diff --git a/third_party/WebKit/LayoutTests/inspector/elements/event-listener-sidebar.html b/third_party/WebKit/LayoutTests/inspector/elements/event-listener-sidebar.html index fa7e35d0..dc15db6 100644 --- a/third_party/WebKit/LayoutTests/inspector/elements/event-listener-sidebar.html +++ b/third_party/WebKit/LayoutTests/inspector/elements/event-listener-sidebar.html
@@ -30,6 +30,9 @@ EventListenerImpl.prototype.toString = function() { return "EventListenerImpl"; } EventListenerImpl.prototype.handleEvent = function() { console.log("click - document - handleEvent"); } new EventListenerImpl(); + document.body.addEventListener("wheel", f, {"passive": true}); + document.body.addEventListener("wheel", f, {"passive": true, "capture": true}); + document.body.removeEventListener("wheel", f, {"passive": true, "capture": true}); } function test()
diff --git a/third_party/WebKit/LayoutTests/inspector/elements/event-listeners-about-blank-expected.txt b/third_party/WebKit/LayoutTests/inspector/elements/event-listeners-about-blank-expected.txt index fe2288ab..996a6d54 100644 --- a/third_party/WebKit/LayoutTests/inspector/elements/event-listeners-about-blank-expected.txt +++ b/third_party/WebKit/LayoutTests/inspector/elements/event-listeners-about-blank-expected.txt
@@ -6,11 +6,20 @@ == normal [expanded] bodyRemoveevent-listeners-about-blank.html:9 useCapture: true + passive: false handler: function f() {} ======== hover ======== == normal [expanded] div#div-in-iframeRemoveevent-listeners-about-blank.html:9 useCapture: true + passive: false + handler: function f() {} + +======== wheel ======== +== normal +[expanded] bodyRemoveevent-listeners-about-blank.html:9 + useCapture: false + passive: true handler: function f() {}
diff --git a/third_party/WebKit/LayoutTests/inspector/elements/event-listeners-about-blank.html b/third_party/WebKit/LayoutTests/inspector/elements/event-listeners-about-blank.html index 73d6343..97d9212 100644 --- a/third_party/WebKit/LayoutTests/inspector/elements/event-listeners-about-blank.html +++ b/third_party/WebKit/LayoutTests/inspector/elements/event-listeners-about-blank.html
@@ -14,6 +14,7 @@ div.id = "div-in-iframe"; div.addEventListener("hover", f, true); body.appendChild(div); + body.addEventListener("wheel", f, {"passive": true}); } function test()
diff --git a/third_party/WebKit/LayoutTests/media/video-move-to-new-document-srcobject.html b/third_party/WebKit/LayoutTests/media/video-move-to-new-document-srcobject.html new file mode 100644 index 0000000..9bb762f --- /dev/null +++ b/third_party/WebKit/LayoutTests/media/video-move-to-new-document-srcobject.html
@@ -0,0 +1,37 @@ +<!DOCTYPE html> +<title>Verify that moving a video element to a new document, still loads it normally</title> +<script src="../resources/testharness.js"></script> +<script src="../resources/testharnessreport.js"></script> +<script src="media-file.js"></script> +<video></video> +<iframe></iframe> +<script> + async_test(function(t) { + var video = document.querySelector('video'); + navigator.webkitGetUserMedia( + {video:true}, + t.step_func(stream => video.srcObject = stream), + t.unreached_func("Did not get mediastream")); + video.onloadeddata = this.step_func(function() { + video.onloadeddata = null; + assert_true(video.networkState == video.NETWORK_IDLE || video.networkState == video.NETWORK_LOADING); + assert_greater_than(video.readyState, video.HAVE_METADATA); + // Move the video element to iframe document from + // main document and verify that it loads properly + document.querySelector('iframe').contentDocument.body.appendChild(video); + assert_equals(video.networkState, video.NETWORK_NO_SOURCE); + assert_equals(video.readyState, video.HAVE_NOTHING); + var actual_events = []; + var expected_events = ['emptied', 'loadstart', 'loadeddata']; + expected_events.forEach(function(type) { + video.addEventListener(type, t.step_func(function() { + actual_events.push(type); + if (type == 'loadeddata') { + assert_array_equals(actual_events, expected_events); + t.done(); + } + })); + }); + }); + }); +</script>
diff --git a/third_party/WebKit/LayoutTests/media/video-srcobject-mediastream-src-file.html b/third_party/WebKit/LayoutTests/media/video-srcobject-mediastream-src-file.html new file mode 100644 index 0000000..e17eec4 --- /dev/null +++ b/third_party/WebKit/LayoutTests/media/video-srcobject-mediastream-src-file.html
@@ -0,0 +1,37 @@ +<!DOCTYPE HTML> +<title>Test that setting the srcObject attribute overrides the src attribute and if the srcObject is set to null, media is reloaded from the src attribute.</title> +<video autoplay></video> +<script src="../resources/testharness.js"></script> +<script src="../resources/testharnessreport.js"></script> +<script src="./w3c-media-utils.js"></script> +<script> + + async_test(test => { + var video = document.querySelector("video"); + assert_idl_attribute(video, "srcObject"); + assert_equals(video.srcObject, null); + video.src = getVideoURI("test"); + navigator.webkitGetUserMedia( + {video:true}, + test.step_func(stream => { + video.onplaying = test.step_func(playingSrcObject); + video.srcObject = stream; + }), + test.unreached_func("Did not get mediastream")); + + function playingSrcObject() + { + assert_not_equals(video.srcObject, null); + assert_class_string(video.srcObject, "MediaStream"); + assert_equals(video.currentSrc, ""); + video.onplaying = test.step_func_done(playingFileAfterSrcObjectRemoved); + video.srcObject = null; + } + + function playingFileAfterSrcObjectRemoved() + { + assert_equals(video.srcObject, null); + assert_equals(video.currentSrc, video.src); + } + }); +</script>
diff --git a/third_party/WebKit/LayoutTests/media/video-srcobject-mediastream.html b/third_party/WebKit/LayoutTests/media/video-srcobject-mediastream.html new file mode 100644 index 0000000..a7be482 --- /dev/null +++ b/third_party/WebKit/LayoutTests/media/video-srcobject-mediastream.html
@@ -0,0 +1,34 @@ +<!DOCTYPE HTML> +<title>Test assignment of a MediaStream via the srcObject attribute.</title> +<video autoplay></video> +<script src="../resources/testharness.js"></script> +<script src="../resources/testharnessreport.js"></script> +<script> + + async_test(test => { + var video = document.querySelector("video") + assert_idl_attribute(video, "srcObject"); + assert_equals(video.srcObject, null); + assert_equals(video.currentSrc, ""); + navigator.webkitGetUserMedia( + {video:true}, + test.step_func(stream => { + video.addEventListener("playing", test.step_func(playingSrcObject)); + video.srcObject = stream; + }), + test.unreached_func("Did not get mediastream")); + + function playingSrcObject() + { + video.addEventListener("emptied", test.step_func_done(_ => { + assert_equals(video.srcObject, null); + assert_equals(video.currentSrc, ""); + })); + assert_not_equals(video.srcObject, null); + assert_class_string(video.srcObject, "MediaStream"); + assert_equals(video.currentSrc, ""); + video.srcObject = null; + } + }) + +</script>
diff --git a/third_party/WebKit/LayoutTests/webexposed/element-instance-property-listing-expected.txt b/third_party/WebKit/LayoutTests/webexposed/element-instance-property-listing-expected.txt index 16982c9..d60c7df 100644 --- a/third_party/WebKit/LayoutTests/webexposed/element-instance-property-listing-expected.txt +++ b/third_party/WebKit/LayoutTests/webexposed/element-instance-property-listing-expected.txt
@@ -325,6 +325,7 @@ property setSinkId property sinkId property src + property srcObject property textTracks property videoTracks property volume @@ -1071,6 +1072,7 @@ property setSinkId property sinkId property src + property srcObject property textTracks property videoHeight property videoTracks
diff --git a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt index 39665f4e..70fe5568 100644 --- a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt +++ b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt
@@ -2626,6 +2626,7 @@ getter seeking getter sinkId getter src + getter srcObject getter textTracks getter videoTracks getter volume @@ -2653,6 +2654,7 @@ setter playbackRate setter preload setter src + setter srcObject setter volume interface HTMLMenuElement : HTMLElement attribute @@toStringTag
diff --git a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp index 32c2ce5f..2a76e95 100644 --- a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp +++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
@@ -84,6 +84,7 @@ #include "public/platform/WebAudioSourceProvider.h" #include "public/platform/WebContentDecryptionModule.h" #include "public/platform/WebInbandTextTrack.h" +#include "public/platform/WebMediaStream.h" #include "public/platform/modules/remoteplayback/WebRemotePlaybackClient.h" #include "public/platform/modules/remoteplayback/WebRemotePlaybackState.h" #include "wtf/CurrentTime.h" @@ -632,7 +633,7 @@ HTMLElement::insertedInto(insertionPoint); if (insertionPoint->inShadowIncludingDocument()) { UseCounter::count(document(), UseCounter::HTMLMediaElementInDocument); - if (!getAttribute(srcAttr).isEmpty() && m_networkState == NETWORK_EMPTY) { + if ((!getAttribute(srcAttr).isEmpty() || m_srcObject.isMediaProviderObject()) && m_networkState == NETWORK_EMPTY) { m_ignorePreloadNone = false; invokeLoadAlgorithm(); } @@ -727,6 +728,18 @@ setAttribute(srcAttr, url); } +void HTMLMediaElement::setSrcObject(const WebMediaPlayerSource& srcObject) +{ + // srcObject can be a media-provider object or null. + ASSERT(!srcObject.isURL()); + + // The srcObject IDL attribute, on setting, must set the element's assigned + // media provider object to the new value, and then invoke the element's + // media element load algorithm. + m_srcObject = srcObject; + invokeLoadAlgorithm(); +} + HTMLMediaElement::NetworkState HTMLMediaElement::getNetworkState() const { return m_networkState; @@ -905,68 +918,97 @@ { WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p)", this); - enum Mode { attribute, children }; + enum Mode { Object, Attribute, Children, Nothing }; + Mode mode = Nothing; - // 3 - If the media element has a src attribute, then let mode be attribute. - Mode mode = attribute; - if (!fastHasAttribute(srcAttr)) { - // Otherwise, if the media element does not have a src attribute but has a source - // element child, then let mode be children and let candidate be the first such - // source element child in tree order. - if (HTMLSourceElement* element = Traversal<HTMLSourceElement>::firstChild(*this)) { - mode = children; - m_nextChildNodeToConsider = element; - m_currentSourceNode = nullptr; - } else { - // Otherwise the media element has neither a src attribute nor a source element - // child: set the networkState to NETWORK_EMPTY, and abort these steps; the - // synchronous section ends. - m_loadState = WaitingForSource; - setShouldDelayLoadEvent(false); - setNetworkState(NETWORK_EMPTY); - updateDisplayState(); + // 6 - If the media element has an assigned media provider object, then let + // mode be object. + if (m_srcObject.isMediaProviderObject()) { + mode = Object; + } else if (fastHasAttribute(srcAttr)) { + // Otherwise, if the media element has no assigned media provider object + // but has a src attribute, then let mode be attribute. + mode = Attribute; + } else if (HTMLSourceElement* element = Traversal<HTMLSourceElement>::firstChild(*this)) { + // Otherwise, if the media element does not have an assigned media + // provider object and does not have a src attribute, but does have a + // source element child, then let mode be children and let candidate be + // the first such source element child in tree order. + mode = Children; + m_nextChildNodeToConsider = element; + m_currentSourceNode = nullptr; + } else { + // Otherwise the media element has no assigned media provider object and + // has neither a src attribute nor a source element child: set the + // networkState to NETWORK_EMPTY, and abort these steps; the synchronous + // section ends. + m_loadState = WaitingForSource; + setShouldDelayLoadEvent(false); + setNetworkState(NETWORK_EMPTY); + updateDisplayState(); - WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), nothing to load", this); - return; - } - } - - // 4 - Set the media element's delaying-the-load-event flag to true (this delays the load event), - // and set its networkState to NETWORK_LOADING. - setShouldDelayLoadEvent(true); - setNetworkState(NETWORK_LOADING); - - // 5 - Queue a task to fire a simple event named loadstart at the media element. - scheduleEvent(EventTypeNames::loadstart); - - // 6 - If mode is attribute, then run these substeps - if (mode == attribute) { - m_loadState = LoadingFromSrcAttr; - - const AtomicString& srcValue = fastGetAttribute(srcAttr); - // If the src attribute's value is the empty string ... jump down to the failed step below - if (srcValue.isEmpty()) { - mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); - WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), empty 'src'", this); - return; - } - - KURL mediaURL = document().completeURL(srcValue); - if (!isSafeToLoadURL(mediaURL, Complain)) { - mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); - return; - } - - // No type is available when the url comes from the 'src' attribute so MediaPlayer - // will have to pick a media engine based on the file extension. - ContentType contentType((String())); - loadResource(mediaURL, contentType); - WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), using 'src' attribute url", this); + WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), nothing to load", this); return; } - // Otherwise, the source elements will be used - loadNextSourceChild(); + // 7 - Set the media element's networkState to NETWORK_LOADING. + setNetworkState(NETWORK_LOADING); + + // 8 - Queue a task to fire a simple event named loadstart at the media element. + scheduleEvent(EventTypeNames::loadstart); + + // 9 - Run the appropriate steps... + switch (mode) { + case Object: + loadSourceFromObject(); + WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), using 'srcObject' attribute", this); + break; + case Attribute: + loadSourceFromAttribute(); + WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), using 'src' attribute url", this); + break; + case Children: + loadNextSourceChild(); + WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), using source element", this); + break; + default: + ASSERT_NOT_REACHED(); + } +} + +void HTMLMediaElement::loadSourceFromObject() +{ + ASSERT(m_srcObject.isMediaProviderObject()); + m_loadState = LoadingFromSrcObject; + + // No type is available when the resource comes from the 'srcObject' + // attribute. + ContentType contentType((String())); + loadResource(m_srcObject, contentType); +} + +void HTMLMediaElement::loadSourceFromAttribute() +{ + m_loadState = LoadingFromSrcAttr; + const AtomicString& srcValue = fastGetAttribute(srcAttr); + + // If the src attribute's value is the empty string ... jump down to the failed step below + if (srcValue.isEmpty()) { + mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); + WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), empty 'src'", this); + return; + } + + KURL mediaURL = document().completeURL(srcValue); + if (!isSafeToLoadURL(mediaURL, Complain)) { + mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); + return; + } + + // No type is available when the url comes from the 'src' attribute so + // MediaPlayer will have to pick a media engine based on the file extension. + ContentType contentType((String())); + loadResource(WebMediaPlayerSource(WebURL(mediaURL)), contentType); } void HTMLMediaElement::loadNextSourceChild() @@ -982,15 +1024,18 @@ resetMediaPlayerAndMediaSource(); m_loadState = LoadingFromSourceElement; - loadResource(mediaURL, contentType); + loadResource(WebMediaPlayerSource(WebURL(mediaURL)), contentType); } -void HTMLMediaElement::loadResource(const KURL& url, ContentType& contentType) +void HTMLMediaElement::loadResource(const WebMediaPlayerSource& source, ContentType& contentType) { ASSERT(isMainThread()); - ASSERT(isSafeToLoadURL(url, Complain)); - - WTF_LOG(Media, "HTMLMediaElement::loadResource(%p, %s, %s)", this, urlForLoggingMedia(url).utf8().data(), contentType.raw().utf8().data()); + KURL url; + if (source.isURL()) { + url = source.getAsURL(); + ASSERT(isSafeToLoadURL(url, Complain)); + WTF_LOG(Media, "HTMLMediaElement::loadResource(%p, %s, %s)", this, urlForLoggingMedia(url).utf8().data(), contentType.raw().utf8().data()); + } LocalFrame* frame = document().frame(); if (!frame) { @@ -1027,8 +1072,10 @@ bool attemptLoad = true; - if (url.protocolIs(mediaSourceBlobProtocol)) { - if (isMediaStreamURL(url.getString())) { + bool isObjectOrBlobURL = source.isMediaProviderObject() || url.protocolIs(mediaSourceBlobProtocol); + if (isObjectOrBlobURL) { + bool isMediaStream = source.isMediaStream() || (source.isURL() && isMediaStreamURL(url.getString())); + if (isMediaStream) { m_autoplayHelper->removeUserGestureRequirement(GesturelessPlaybackEnabledByStream); } else { m_mediaSource = HTMLMediaSource::lookup(url.getString()); @@ -1044,7 +1091,8 @@ } } - if (attemptLoad && canLoadURL(url, contentType)) { + bool canLoadResource = source.isMediaProviderObject() || canLoadURL(url, contentType); + if (attemptLoad && canLoadResource) { ASSERT(!webMediaPlayer()); if (effectivePreloadType() == WebMediaPlayer::PreloadNone) { @@ -1068,24 +1116,33 @@ void HTMLMediaElement::startPlayerLoad() { ASSERT(!m_webMediaPlayer); - // Filter out user:pass as those two URL components aren't - // considered for media resource fetches (including for the CORS - // use-credentials mode.) That behavior aligns with Gecko, with IE - // being more restrictive and not allowing fetches to such URLs. - // - // Spec reference: http://whatwg.org/c/#concept-media-load-resource - // - // FIXME: when the HTML spec switches to specifying resource - // fetches in terms of Fetch (http://fetch.spec.whatwg.org), and - // along with that potentially also specifying a setting for its - // 'authentication flag' to control how user:pass embedded in a - // media resource URL should be treated, then update the handling - // here to match. - KURL requestURL = m_currentSrc; - if (!requestURL.user().isEmpty()) - requestURL.setUser(String()); - if (!requestURL.pass().isEmpty()) - requestURL.setPass(String()); + + WebMediaPlayerSource source; + if (m_srcObject.isMediaProviderObject()) { + source = m_srcObject; + } else { + // Filter out user:pass as those two URL components aren't + // considered for media resource fetches (including for the CORS + // use-credentials mode.) That behavior aligns with Gecko, with IE + // being more restrictive and not allowing fetches to such URLs. + // + // Spec reference: http://whatwg.org/c/#concept-media-load-resource + // + // FIXME: when the HTML spec switches to specifying resource + // fetches in terms of Fetch (http://fetch.spec.whatwg.org), and + // along with that potentially also specifying a setting for its + // 'authentication flag' to control how user:pass embedded in a + // media resource URL should be treated, then update the handling + // here to match. + KURL requestURL = m_currentSrc; + if (!requestURL.user().isEmpty()) + requestURL.setUser(String()); + if (!requestURL.pass().isEmpty()) + requestURL.setPass(String()); + + KURL kurl(ParsedURLString, requestURL); + source = WebMediaPlayerSource(WebURL(kurl)); + } LocalFrame* frame = document().frame(); // TODO(srirama.m): Figure out how frame can be null when @@ -1095,8 +1152,7 @@ return; } - KURL kurl(ParsedURLString, requestURL); - m_webMediaPlayer = frame->loader().client()->createWebMediaPlayer(*this, kurl, this); + m_webMediaPlayer = frame->loader().client()->createWebMediaPlayer(*this, source, this); if (!m_webMediaPlayer) { mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); return; @@ -1112,7 +1168,7 @@ m_webMediaPlayer->setPreload(effectivePreloadType()); - m_webMediaPlayer->load(loadType(), kurl, corsMode()); + m_webMediaPlayer->load(loadType(), source, corsMode()); if (isFullscreen()) { // This handles any transition to or from fullscreen overlay mode. @@ -1205,7 +1261,7 @@ if (m_mediaSource) return WebMediaPlayer::LoadTypeMediaSource; - if (isMediaStreamURL(m_currentSrc.getString())) + if (m_srcObject.isMediaStream() || isMediaStreamURL(m_currentSrc.getString())) return WebMediaPlayer::LoadTypeMediaStream; return WebMediaPlayer::LoadTypeURL;
diff --git a/third_party/WebKit/Source/core/html/HTMLMediaElement.h b/third_party/WebKit/Source/core/html/HTMLMediaElement.h index 3693e72..14794bf 100644 --- a/third_party/WebKit/Source/core/html/HTMLMediaElement.h +++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.h
@@ -39,6 +39,7 @@ #include "platform/audio/AudioSourceProvider.h" #include "public/platform/WebAudioSourceProviderClient.h" #include "public/platform/WebMediaPlayerClient.h" +#include "public/platform/WebMediaPlayerSource.h" #include "public/platform/WebMimeRegistry.h" #if !ENABLE(OILPAN) @@ -114,6 +115,8 @@ // network state void setSrc(const AtomicString&); const KURL& currentSrc() const { return m_currentSrc; } + void setSrcObject(const WebMediaPlayerSource&); + const WebMediaPlayerSource& getSrcObject() const { return m_srcObject; } enum NetworkState { NETWORK_EMPTY, NETWORK_IDLE, NETWORK_LOADING, NETWORK_NO_SOURCE }; NetworkState getNetworkState() const; @@ -366,11 +369,13 @@ void invokeResourceSelectionAlgorithm(); void loadInternal(); void selectMediaResource(); - void loadResource(const KURL&, ContentType&); + void loadResource(const WebMediaPlayerSource&, ContentType&); void startPlayerLoad(); void setPlayerPreload(); WebMediaPlayer::LoadType loadType() const; void scheduleNextSourceChild(); + void loadSourceFromObject(); + void loadSourceFromAttribute(); void loadNextSourceChild(); void clearMediaPlayer(); void clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); @@ -487,6 +492,7 @@ ReadyState m_readyState; ReadyState m_readyStateMaximum; KURL m_currentSrc; + WebMediaPlayerSource m_srcObject; Member<MediaError> m_error; @@ -508,7 +514,7 @@ double m_defaultPlaybackStartPosition; // Loading state. - enum LoadState { WaitingForSource, LoadingFromSrcAttr, LoadingFromSourceElement }; + enum LoadState { WaitingForSource, LoadingFromSrcObject, LoadingFromSrcAttr, LoadingFromSourceElement }; LoadState m_loadState; Member<HTMLSourceElement> m_currentSourceNode; Member<Node> m_nextChildNodeToConsider;
diff --git a/third_party/WebKit/Source/core/html/HTMLVideoElementTest.cpp b/third_party/WebKit/Source/core/html/HTMLVideoElementTest.cpp index 61e2b50..0ac931a 100644 --- a/third_party/WebKit/Source/core/html/HTMLVideoElementTest.cpp +++ b/third_party/WebKit/Source/core/html/HTMLVideoElementTest.cpp
@@ -21,7 +21,7 @@ class EmptyWebMediaPlayer : public WebMediaPlayer { public: - void load(LoadType, const WebURL&, CORSMode) override { }; + void load(LoadType, const WebMediaPlayerSource&, CORSMode) override { }; void play() override { }; void pause() override { }; bool supportsSave() const override { return false; }; @@ -64,7 +64,7 @@ return new StubFrameLoaderClient; } - PassOwnPtr<WebMediaPlayer> createWebMediaPlayer(HTMLMediaElement&, const WebURL&, WebMediaPlayerClient*) override + PassOwnPtr<WebMediaPlayer> createWebMediaPlayer(HTMLMediaElement&, const WebMediaPlayerSource&, WebMediaPlayerClient*) override { return adoptPtr(new MockWebMediaPlayer); }
diff --git a/third_party/WebKit/Source/core/inspector/InspectorDOMDebuggerAgent.cpp b/third_party/WebKit/Source/core/inspector/InspectorDOMDebuggerAgent.cpp index 006d26d7..b8ce5d2 100644 --- a/third_party/WebKit/Source/core/inspector/InspectorDOMDebuggerAgent.cpp +++ b/third_party/WebKit/Source/core/inspector/InspectorDOMDebuggerAgent.cpp
@@ -113,7 +113,7 @@ v8::Local<v8::Object> handler = v8Listener->getListenerObject(executionContext); if (handler.IsEmpty()) continue; - eventInformation.append(V8EventListenerInfo(type, listeners->at(k).useCapture, handler)); + eventInformation.append(V8EventListenerInfo(type, listeners->at(k).useCapture, listeners->at(k).passive, handler)); } } } @@ -398,6 +398,7 @@ OwnPtr<protocol::DOMDebugger::EventListener> value = protocol::DOMDebugger::EventListener::create() .setType(info.eventType) .setUseCapture(info.useCapture) + .setPassive(info.passive) .setLocation(location.release()).build(); if (!objectGroupId.isEmpty()) { value->setHandler(m_runtimeAgent->wrapObject(context, function, objectGroupId));
diff --git a/third_party/WebKit/Source/core/loader/EmptyClients.cpp b/third_party/WebKit/Source/core/loader/EmptyClients.cpp index a805760..0e0a45ec 100644 --- a/third_party/WebKit/Source/core/loader/EmptyClients.cpp +++ b/third_party/WebKit/Source/core/loader/EmptyClients.cpp
@@ -152,7 +152,7 @@ return nullptr; } -PassOwnPtr<WebMediaPlayer> EmptyFrameLoaderClient::createWebMediaPlayer(HTMLMediaElement&, const WebURL&, WebMediaPlayerClient*) +PassOwnPtr<WebMediaPlayer> EmptyFrameLoaderClient::createWebMediaPlayer(HTMLMediaElement&, const WebMediaPlayerSource&, WebMediaPlayerClient*) { return nullptr; }
diff --git a/third_party/WebKit/Source/core/loader/EmptyClients.h b/third_party/WebKit/Source/core/loader/EmptyClients.h index 7e63973..0dcedbf 100644 --- a/third_party/WebKit/Source/core/loader/EmptyClients.h +++ b/third_party/WebKit/Source/core/loader/EmptyClients.h
@@ -245,7 +245,7 @@ LocalFrame* createFrame(const FrameLoadRequest&, const AtomicString&, HTMLFrameOwnerElement*) override; Widget* createPlugin(HTMLPlugInElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool, DetachedPluginPolicy) override; bool canCreatePluginWithoutRenderer(const String& mimeType) const override { return false; } - PassOwnPtr<WebMediaPlayer> createWebMediaPlayer(HTMLMediaElement&, const WebURL&, WebMediaPlayerClient*) override; + PassOwnPtr<WebMediaPlayer> createWebMediaPlayer(HTMLMediaElement&, const WebMediaPlayerSource&, WebMediaPlayerClient*) override; PassOwnPtr<WebMediaSession> createWebMediaSession() override; ObjectContentType getObjectContentType(const KURL&, const String&, bool) override { return ObjectContentType(); }
diff --git a/third_party/WebKit/Source/core/loader/FrameLoaderClient.h b/third_party/WebKit/Source/core/loader/FrameLoaderClient.h index 550d93d..1e568be 100644 --- a/third_party/WebKit/Source/core/loader/FrameLoaderClient.h +++ b/third_party/WebKit/Source/core/loader/FrameLoaderClient.h
@@ -69,7 +69,9 @@ class WebCookieJar; class WebMediaPlayer; class WebMediaPlayerClient; +class WebMediaPlayerSource; class WebMediaSession; +class WebMediaStream; class WebRTCPeerConnectionHandler; class WebServiceWorkerProvider; class WebSocketHandle; @@ -161,7 +163,7 @@ virtual bool canCreatePluginWithoutRenderer(const String& mimeType) const = 0; virtual Widget* createPlugin(HTMLPlugInElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool loadManually, DetachedPluginPolicy) = 0; - virtual PassOwnPtr<WebMediaPlayer> createWebMediaPlayer(HTMLMediaElement&, const WebURL&, WebMediaPlayerClient*) = 0; + virtual PassOwnPtr<WebMediaPlayer> createWebMediaPlayer(HTMLMediaElement&, const WebMediaPlayerSource&, WebMediaPlayerClient*) = 0; virtual PassOwnPtr<WebMediaSession> createWebMediaSession() = 0;
diff --git a/third_party/WebKit/Source/devtools/front_end/components/EventListenersUtils.js b/third_party/WebKit/Source/devtools/front_end/components/EventListenersUtils.js index 146a4bd..acd0e06 100644 --- a/third_party/WebKit/Source/devtools/front_end/components/EventListenersUtils.js +++ b/third_party/WebKit/Source/devtools/front_end/components/EventListenersUtils.js
@@ -5,7 +5,7 @@ /** @typedef {{eventListeners:!Array<!WebInspector.EventListener>, internalHandlers:?WebInspector.RemoteArray}} */ WebInspector.FrameworkEventListenersObject; -/** @typedef {{type: string, useCapture: boolean, handler: function()}} */ +/** @typedef {{type: string, useCapture: boolean, passive: boolean, handler: function()}} */ WebInspector.EventListenerObjectInInspectedPage; /** @@ -74,6 +74,8 @@ var type; /** @type {boolean} */ var useCapture; + /** @type {boolean} */ + var passive; /** @type {?WebInspector.RemoteObject} */ var handler = null; /** @type {?WebInspector.RemoteObject} */ @@ -89,20 +91,21 @@ /** * @suppressReceiverCheck * @this {WebInspector.EventListenerObjectInInspectedPage} - * @return {!{type:string, useCapture:boolean}} + * @return {!{type:string, useCapture:boolean, passive:boolean}} */ function truncatePageEventListener() { - return {type: this.type, useCapture: this.useCapture}; + return {type: this.type, useCapture: this.useCapture, passive: this.passive}; } /** - * @param {!{type:string, useCapture: boolean}} truncatedListener + * @param {!{type:string, useCapture: boolean, passive: boolean}} truncatedListener */ function storeTruncatedListener(truncatedListener) { type = truncatedListener.type; useCapture = truncatedListener.useCapture; + passive = truncatedListener.passive; } promises.push(listenerObject.callFunctionPromise(handlerFunction).then(assertCallFunctionResult).then(storeOriginalHandler).then(toTargetFunction).then(storeFunctionWithDetails)); @@ -176,7 +179,7 @@ { if (!location) throw new Error("Empty event listener's location"); - return new WebInspector.EventListener(handler._target, type, useCapture, handler, originalHandler, location, removeFunctionObject, "frameworkUser"); + return new WebInspector.EventListener(handler._target, type, useCapture, passive, handler, originalHandler, location, removeFunctionObject, "frameworkUser"); } } } @@ -271,8 +274,9 @@ { "handler": function(), "useCapture": true, + "passive": false, "type": "change", - "remove": function(type, handler, useCapture) + "remove": function(type, handler, useCapture, passive) }, ... ], @@ -358,6 +362,9 @@ var useCapture = eventListener.useCapture; if (typeof useCapture !== "boolean") errorString += "event listener's useCapture isn't boolean or undefined, "; + var passive = eventListener.passive; + if (typeof passive !== "boolean") + errorString += "event listener's passive isn't boolean or undefined, "; var handler = eventListener.handler; if (!handler || (typeof handler !== "function")) errorString += "event listener's handler isn't a function or empty, "; @@ -365,7 +372,7 @@ if (remove && (typeof remove !== "function")) errorString += "event listener's remove isn't a function, "; if (!errorString){ - return {type: type, useCapture: useCapture, handler: handler, remove: remove}; + return {type: type, useCapture: useCapture, passive: passive, handler: handler, remove: remove}; } else { errorLines.push(errorString.substr(0, errorString.length - 2)); return null; @@ -433,6 +440,7 @@ var listener = { handler: frameworkListener.handler || frameworkListener, useCapture: true, + passive: false, type: type }; listener.remove = jQueryRemove.bind(node, frameworkListener.selector); @@ -454,6 +462,7 @@ var listener = { handler: events[key], useCapture: true, + passive: false, type: type }; // We don't support removing for old version < 1.4 of jQuery because it doesn't provide API for getting "selector".
diff --git a/third_party/WebKit/Source/devtools/front_end/components/EventListenersView.js b/third_party/WebKit/Source/devtools/front_end/components/EventListenersView.js index 17f30a7..bd469c9d 100644 --- a/third_party/WebKit/Source/devtools/front_end/components/EventListenersView.js +++ b/third_party/WebKit/Source/devtools/front_end/components/EventListenersView.js
@@ -144,8 +144,10 @@ /** * @param {boolean} showFramework + * @param {boolean} showPassive + * @param {boolean} showBlocking */ - showFrameworkListeners: function(showFramework) + showFrameworkListeners: function(showFramework, showPassive, showBlocking) { var eventTypes = this._treeOutline.rootElement().children(); for (var eventType of eventTypes) { @@ -157,6 +159,10 @@ hidden = true; if (listenerType === "frameworkInternal" && showFramework) hidden = true; + if (!showPassive && listenerElement.eventListener().passive()) + hidden = true; + if (!showBlocking && !listenerElement.eventListener().passive()) + hidden = true; listenerElement.hidden = hidden; hiddenEventType = hiddenEventType && hidden; } @@ -267,6 +273,7 @@ var eventListener = this._eventListener; var runtimeModel = eventListener.target().runtimeModel; properties.push(runtimeModel.createRemotePropertyFromPrimitiveValue("useCapture", eventListener.useCapture())); + properties.push(runtimeModel.createRemotePropertyFromPrimitiveValue("passive", eventListener.passive())); if (typeof eventListener.handler() !== "undefined") properties.push(new WebInspector.RemoteObjectProperty("handler", eventListener.handler())); WebInspector.ObjectPropertyTreeElement.populateWithProperties(this, properties, [], true, null);
diff --git a/third_party/WebKit/Source/devtools/front_end/elements/EventListenersWidget.js b/third_party/WebKit/Source/devtools/front_end/elements/EventListenersWidget.js index efbf650..0ae03f13 100644 --- a/third_party/WebKit/Source/devtools/front_end/elements/EventListenersWidget.js +++ b/third_party/WebKit/Source/devtools/front_end/elements/EventListenersWidget.js
@@ -38,12 +38,22 @@ this._showForAncestorsSetting = WebInspector.settings.createSetting("showEventListenersForAncestors", true); this._showForAncestorsSetting.addChangeListener(this.update.bind(this)); + + this._dispatchFilterBySetting = WebInspector.settings.createSetting("eventListenerDispatchFilterType", WebInspector.EventListenersWidget.DispatchFilterBy.All); + this._dispatchFilterBySetting.addChangeListener(this.update.bind(this)); + this._showFrameworkListenersSetting = WebInspector.settings.createSetting("showFrameowkrListeners", true); this._showFrameworkListenersSetting.addChangeListener(this._showFrameworkListenersChanged.bind(this)); this._eventListenersView = new WebInspector.EventListenersView(this.element); WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, this.update, this); } +WebInspector.EventListenersWidget.DispatchFilterBy = { + All : "All", + Blocking : "Blocking", + Passive : "Passive" +} + /** * @return {!WebInspector.ElementsSidebarViewWrapperPane} */ @@ -55,6 +65,24 @@ refreshButton.addEventListener("click", widget.update.bind(widget)); result.toolbar().appendToolbarItem(refreshButton); result.toolbar().appendToolbarItem(new WebInspector.ToolbarCheckbox(WebInspector.UIString("Ancestors"), WebInspector.UIString("Show listeners on the ancestors"), widget._showForAncestorsSetting)); + var dispatchFilter = new WebInspector.ToolbarComboBox(widget._onDispatchFilterTypeChanged.bind(widget)); + + /** + * @param {string} name + * @param {string} value + */ + function addDispatchFilterOption(name, value) + { + var option = dispatchFilter.createOption(name, "", value); + if (value === widget._dispatchFilterBySetting.get()) + dispatchFilter.select(option); + } + addDispatchFilterOption(WebInspector.UIString("All"), WebInspector.EventListenersWidget.DispatchFilterBy.All); + addDispatchFilterOption(WebInspector.UIString("Passive"), WebInspector.EventListenersWidget.DispatchFilterBy.Passive); + addDispatchFilterOption(WebInspector.UIString("Blocking"), WebInspector.EventListenersWidget.DispatchFilterBy.Blocking); + dispatchFilter.setMaxWidth(200); + result.toolbar().appendToolbarItem(dispatchFilter); + result.toolbar().appendToolbarItem(new WebInspector.ToolbarCheckbox(WebInspector.UIString("Framework listeners"), WebInspector.UIString("Resolve event listeners bound with framework"), widget._showFrameworkListenersSetting)); return result; } @@ -95,10 +123,20 @@ return Promise.all(promises).then(this._eventListenersView.addObjects.bind(this._eventListenersView)).then(this._showFrameworkListenersChanged.bind(this)); }, + /** + * @param {!Event} event + */ + _onDispatchFilterTypeChanged: function(event) + { + this._dispatchFilterBySetting.set(event.target.value); + }, _showFrameworkListenersChanged: function() { - this._eventListenersView.showFrameworkListeners(this._showFrameworkListenersSetting.get()); + var dispatchFilter = this._dispatchFilterBySetting.get(); + var showPassive = dispatchFilter == WebInspector.EventListenersWidget.DispatchFilterBy.All || dispatchFilter == WebInspector.EventListenersWidget.DispatchFilterBy.Passive; + var showBlocking = dispatchFilter == WebInspector.EventListenersWidget.DispatchFilterBy.All || dispatchFilter == WebInspector.EventListenersWidget.DispatchFilterBy.Blocking; + this._eventListenersView.showFrameworkListeners(this._showFrameworkListenersSetting.get(), showPassive, showBlocking); }, /**
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/RemoteObject.js b/third_party/WebKit/Source/devtools/front_end/sdk/RemoteObject.js index ee63ffe5..bba2c6e 100644 --- a/third_party/WebKit/Source/devtools/front_end/sdk/RemoteObject.js +++ b/third_party/WebKit/Source/devtools/front_end/sdk/RemoteObject.js
@@ -591,7 +591,7 @@ /** * @suppressReceiverCheck * @this {Node} - * @return {function(this:Node, string, function(), boolean=): undefined} + * @return {function(this:Node, string, function(), boolean=, boolean=): undefined} */ function nodeRemoveEventListener() { @@ -600,11 +600,27 @@ * @param {string} type * @param {function()} handler * @param {boolean=} useCapture + * @param {boolean=} passive * @this {Node} */ - function removeEventListenerWrapper(type, handler, useCapture) + function removeEventListenerWrapper(type, handler, useCapture, passive) { - this.removeEventListener(type, handler, useCapture); + // TODO(dtapuska): Remove this one closure compiler is updated + // to handle EventListenerOptions and passive event listeners + // has shipped. Don't JSDoc these otherwise it will fail. + // @return {boolean|undefined|{capture: (boolean|undefined), passive: boolean}} + function eventListenerOptions() + { + if (passive && useCapture) + return {"capture": useCapture, "passive": passive}; + else if (passive) + return {"passive": passive}; + else if (useCapture) + return {"capture": useCapture}; + else + return {}; + } + this.removeEventListener(type, handler, eventListenerOptions()); if (this["on" + type]) this["on" + type] = null; } @@ -619,6 +635,7 @@ return new WebInspector.EventListener(this._target, payload.type, payload.useCapture, + payload.passive, payload.handler ? this.target().runtimeModel.createRemoteObject(payload.handler) : null, payload.originalHandler ? this.target().runtimeModel.createRemoteObject(payload.originalHandler) : null, WebInspector.DebuggerModel.Location.fromPayload(this._debuggerModel, payload.location),
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/RuntimeModel.js b/third_party/WebKit/Source/devtools/front_end/sdk/RuntimeModel.js index 5d3a91ff..bd8c6cb 100644 --- a/third_party/WebKit/Source/devtools/front_end/sdk/RuntimeModel.js +++ b/third_party/WebKit/Source/devtools/front_end/sdk/RuntimeModel.js
@@ -613,17 +613,19 @@ * @param {!WebInspector.Target} target * @param {string} type * @param {boolean} useCapture + * @param {boolean} passive * @param {?WebInspector.RemoteObject} handler * @param {?WebInspector.RemoteObject} originalHandler * @param {!WebInspector.DebuggerModel.Location} location * @param {?WebInspector.RemoteObject} removeFunction * @param {string=} listenerType */ -WebInspector.EventListener = function(target, type, useCapture, handler, originalHandler, location, removeFunction, listenerType) +WebInspector.EventListener = function(target, type, useCapture, passive, handler, originalHandler, location, removeFunction, listenerType) { WebInspector.SDKObject.call(this, target); this._type = type; this._useCapture = useCapture; + this._passive = passive; this._handler = handler; this._originalHandler = originalHandler || handler; this._location = location; @@ -651,6 +653,14 @@ }, /** + * @return {boolean} + */ + passive: function() + { + return this._passive; + }, + + /** * @return {?WebInspector.RemoteObject} */ handler: function() @@ -709,18 +719,20 @@ WebInspector.RemoteObject.toCallArgument(this._removeFunction), WebInspector.RemoteObject.toCallArgument(this._type), WebInspector.RemoteObject.toCallArgument(this._originalHandler), - WebInspector.RemoteObject.toCallArgument(this._useCapture) + WebInspector.RemoteObject.toCallArgument(this._useCapture), + WebInspector.RemoteObject.toCallArgument(this._passive), ], success); /** - * @param {function(string, function(), boolean)} func + * @param {function(string, function(), boolean, boolean)} func * @param {string} type * @param {function()} listener * @param {boolean} useCapture + * @param {boolean} passive */ - function callCustomRemove(func, type, listener, useCapture) + function callCustomRemove(func, type, listener, useCapture, passive) { - func.call(null, type, listener, useCapture); + func.call(null, type, listener, useCapture, passive); } } },
diff --git a/third_party/WebKit/Source/devtools/protocol.json b/third_party/WebKit/Source/devtools/protocol.json index e069b4d..211e420 100644 --- a/third_party/WebKit/Source/devtools/protocol.json +++ b/third_party/WebKit/Source/devtools/protocol.json
@@ -3786,6 +3786,7 @@ "properties": [ { "name": "type", "type": "string", "description": "<code>EventListener</code>'s type." }, { "name": "useCapture", "type": "boolean", "description": "<code>EventListener</code>'s useCapture." }, + { "name": "passive", "type": "boolean", "description": "<code>EventListener</code>'s passive flag." }, { "name": "location", "$ref": "Debugger.Location", "description": "Handler code location." }, { "name": "handler", "$ref": "Runtime.RemoteObject", "optional": true, "description": "Event handler function value." }, { "name": "originalHandler", "$ref": "Runtime.RemoteObject", "optional": true, "description": "Event original handler function value." }
diff --git a/third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp b/third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp index e874db8..05633888 100644 --- a/third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp +++ b/third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp
@@ -1617,7 +1617,7 @@ // Case 4: node is an inline with a continuation. Next sibling is the next sibling of the end // of the continuation chain. nextSibling = endOfContinuations(m_layoutObject)->nextSibling(); - } else if (isInlineWithContinuation(m_layoutObject->parent())) { + } else if (m_layoutObject->parent() && isInlineWithContinuation(m_layoutObject->parent())) { // Case 5: node has no next sibling, and its parent is an inline with a continuation. LayoutObject* continuation = toLayoutInline(m_layoutObject->parent())->continuation();
diff --git a/third_party/WebKit/Source/modules/mediastream/MediaStream.cpp b/third_party/WebKit/Source/modules/mediastream/MediaStream.cpp index 06bf3e57..68df433 100644 --- a/third_party/WebKit/Source/modules/mediastream/MediaStream.cpp +++ b/third_party/WebKit/Source/modules/mediastream/MediaStream.cpp
@@ -421,4 +421,9 @@ MediaStreamDescriptorClient::trace(visitor); } +MediaStream* toMediaStream(MediaStreamDescriptor* descriptor) +{ + return static_cast<MediaStream*>(descriptor->client()); +} + } // namespace blink
diff --git a/third_party/WebKit/Source/modules/mediastream/MediaStream.h b/third_party/WebKit/Source/modules/mediastream/MediaStream.h index f004425..81ed46f3 100644 --- a/third_party/WebKit/Source/modules/mediastream/MediaStream.h +++ b/third_party/WebKit/Source/modules/mediastream/MediaStream.h
@@ -116,6 +116,8 @@ typedef HeapVector<Member<MediaStream>> MediaStreamVector; +MediaStream* toMediaStream(MediaStreamDescriptor*); + } // namespace blink #endif // MediaStream_h
diff --git a/third_party/WebKit/Source/modules/modules.gypi b/third_party/WebKit/Source/modules/modules.gypi index 23c88c78..4cfaa4b2 100644 --- a/third_party/WebKit/Source/modules/modules.gypi +++ b/third_party/WebKit/Source/modules/modules.gypi
@@ -397,6 +397,7 @@ 'serviceworkers/NavigatorServiceWorker.idl', 'speech/WindowSpeech.idl', 'speech/WindowSpeechSynthesis.idl', + 'srcobject/HTMLMediaElementSrcObject.idl', 'storage/WindowStorage.idl', 'vibration/NavigatorVibration.idl', 'vr/NavigatorVRDevice.idl', @@ -1528,6 +1529,8 @@ 'speech/SpeechSynthesisUtterance.h', 'speech/SpeechSynthesisVoice.cpp', 'speech/SpeechSynthesisVoice.h', + 'srcobject/HTMLMediaElementSrcObject.cpp', + 'srcobject/HTMLMediaElementSrcObject.h', 'storage/DOMWindowStorage.cpp', 'storage/DOMWindowStorage.h', 'storage/DOMWindowStorageController.cpp',
diff --git a/third_party/WebKit/Source/modules/srcobject/HTMLMediaElementSrcObject.cpp b/third_party/WebKit/Source/modules/srcobject/HTMLMediaElementSrcObject.cpp new file mode 100644 index 0000000..b3465b5 --- /dev/null +++ b/third_party/WebKit/Source/modules/srcobject/HTMLMediaElementSrcObject.cpp
@@ -0,0 +1,40 @@ +// Copyright 2016 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 "modules/srcobject/HTMLMediaElementSrcObject.h" + +#include "core/html/HTMLMediaElement.h" +#include "modules/mediastream/MediaStream.h" +#include "platform/mediastream/MediaStreamDescriptor.h" +#include "public/platform/WebMediaPlayerSource.h" +#include "public/platform/WebMediaStream.h" + +namespace blink { + +// static +MediaStream* HTMLMediaElementSrcObject::srcObject(HTMLMediaElement& element) +{ + const WebMediaPlayerSource& source = element.getSrcObject(); + if (source.isMediaStream()) { + MediaStreamDescriptor* descriptor = source.getAsMediaStream(); + MediaStream* stream = toMediaStream(descriptor); + return stream; + } + + return nullptr; +} + +// static +void HTMLMediaElementSrcObject::setSrcObject(HTMLMediaElement& element, MediaStream* mediaStream) +{ + if (!mediaStream) { + element.setSrcObject(WebMediaPlayerSource()); + return; + } + WebMediaStream webStream = WebMediaStream(mediaStream->descriptor()); + WebMediaPlayerSource source(webStream); + element.setSrcObject(source); +} + +} // namespace blink
diff --git a/third_party/WebKit/Source/modules/srcobject/HTMLMediaElementSrcObject.h b/third_party/WebKit/Source/modules/srcobject/HTMLMediaElementSrcObject.h new file mode 100644 index 0000000..8451a17c --- /dev/null +++ b/third_party/WebKit/Source/modules/srcobject/HTMLMediaElementSrcObject.h
@@ -0,0 +1,25 @@ +// Copyright 2016 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 HTMLMediaElementSrcObject_h +#define HTMLMediaElementSrcObject_h + +#include "modules/ModulesExport.h" +#include "wtf/Allocator.h" + +namespace blink { + +class MediaStream; +class HTMLMediaElement; + +class MODULES_EXPORT HTMLMediaElementSrcObject { + STATIC_ONLY(HTMLMediaElementSrcObject); +public: + static MediaStream* srcObject(HTMLMediaElement&); + static void setSrcObject(HTMLMediaElement&, MediaStream*); +}; + +} // namespace blink + +#endif
diff --git a/third_party/WebKit/Source/modules/srcobject/HTMLMediaElementSrcObject.idl b/third_party/WebKit/Source/modules/srcobject/HTMLMediaElementSrcObject.idl new file mode 100644 index 0000000..11d44c32 --- /dev/null +++ b/third_party/WebKit/Source/modules/srcobject/HTMLMediaElementSrcObject.idl
@@ -0,0 +1,18 @@ +// Copyright 2016 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. + +// https://html.spec.whatwg.org/multipage/embedded-content.html#dom-media-srcobject + +// TODO(guidou): Add support for MediaSource and Blob, as defined in the spec. +typedef MediaStream MediaProvider; + +[ + RuntimeEnabled=SrcObject +] partial interface HTMLMediaElement { + // TODO(haraken): Per the spec, the srcObject should be defined in + // HTMLMediaElement.idl. However, we cannot define srcObject in + // HTMLMediaElement.idl because of the dependency restriction from modules/ + // to core/. For now we avoid the problem by using a partial interface. + attribute MediaProvider? srcObject; +};
diff --git a/third_party/WebKit/Source/modules/srcobject/OWNERS b/third_party/WebKit/Source/modules/srcobject/OWNERS new file mode 100644 index 0000000..05cb9bd3 --- /dev/null +++ b/third_party/WebKit/Source/modules/srcobject/OWNERS
@@ -0,0 +1 @@ +guidou@chromium.org
diff --git a/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in b/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in index c8e01875..2593461 100644 --- a/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in +++ b/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in
@@ -204,6 +204,7 @@ // like to enable this always but can't until more websites fix this bug. // Chromium sets this conditionally (eg. based on the presence of a // touchscreen) in ApplyWebPreferences. +SrcObject status=test Touch status=stable TrustedEvents status=stable TrustedEventsDefaultAction
diff --git a/third_party/WebKit/Source/platform/blink_platform.gypi b/third_party/WebKit/Source/platform/blink_platform.gypi index d007d0e..d13db85 100644 --- a/third_party/WebKit/Source/platform/blink_platform.gypi +++ b/third_party/WebKit/Source/platform/blink_platform.gypi
@@ -326,6 +326,7 @@ 'exported/WebMediaDeviceInfo.cpp', 'exported/WebMediaPlayerClient.cpp', 'exported/WebMediaPlayerEncryptedMediaClient.cpp', + 'exported/WebMediaPlayerSource.cpp', 'exported/WebMediaRecorderHandler.cpp', 'exported/WebMediaStream.cpp', 'exported/WebMediaStreamSource.cpp',
diff --git a/third_party/WebKit/Source/platform/exported/WebMediaPlayerSource.cpp b/third_party/WebKit/Source/platform/exported/WebMediaPlayerSource.cpp new file mode 100644 index 0000000..7ebfd243 --- /dev/null +++ b/third_party/WebKit/Source/platform/exported/WebMediaPlayerSource.cpp
@@ -0,0 +1,53 @@ +// Copyright 2016 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 "public/platform/WebMediaPlayerSource.h" + +namespace blink { + +WebMediaPlayerSource::WebMediaPlayerSource() +{ +} + +WebMediaPlayerSource::WebMediaPlayerSource(const WebURL& url) + : m_url(url) +{ +} + +WebMediaPlayerSource::WebMediaPlayerSource(const WebMediaStream& mediaStream) + : m_mediaStream(mediaStream) +{ +} + +WebMediaPlayerSource::~WebMediaPlayerSource() +{ + m_mediaStream.reset(); +} + +bool WebMediaPlayerSource::isURL() const +{ + return !m_url.isEmpty(); +} + +WebURL WebMediaPlayerSource::getAsURL() const +{ + return m_url; +} + +bool WebMediaPlayerSource::isMediaProviderObject() const +{ + return isMediaStream(); +} + +bool WebMediaPlayerSource::isMediaStream() const +{ + return !m_mediaStream.isNull(); +} + +WebMediaStream WebMediaPlayerSource::getAsMediaStream() const +{ + return m_mediaStream; +} + +} // namespace blink
diff --git a/third_party/WebKit/Source/platform/v8_inspector/InjectedScriptSource.js b/third_party/WebKit/Source/platform/v8_inspector/InjectedScriptSource.js index ee26d373..88b8210 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/InjectedScriptSource.js +++ b/third_party/WebKit/Source/platform/v8_inspector/InjectedScriptSource.js
@@ -1393,10 +1393,34 @@ var result = nullifyObjectProto(InjectedScriptHost.getEventListeners(node)); if (!result) return; - /** @this {{type: string, listener: function(), useCapture: boolean}} */ + + // TODO(dtapuska): Remove this one closure compiler is updated + // to handle EventListenerOptions and passive event listeners + // has shipped. Don't JSDoc these otherwise it will fail. + // @param {boolean} capture + // @param {boolean} passive + // @return {boolean|undefined|{capture: (boolean|undefined), passive: boolean}} + function eventListenerOptions(capture, passive) + { + return {"capture": capture, "passive": passive}; + } + + /** + * @param {!Node} node + * @param {string} type + * @param {function()} listener + * @param {boolean} capture + * @param {boolean} passive + */ + function removeEventListenerWrapper(node, type, listener, capture, passive) + { + node.removeEventListener(type, listener, eventListenerOptions(capture, passive)); + } + + /** @this {{type: string, listener: function(), useCapture: boolean, passive: boolean}} */ var removeFunc = function() { - node.removeEventListener(this.type, this.listener, this.useCapture); + removeEventListenerWrapper(node, this.type, this.listener, this.useCapture, this.passive); } for (var type in result) { var listeners = result[type];
diff --git a/third_party/WebKit/Source/platform/v8_inspector/V8InjectedScriptHost.cpp b/third_party/WebKit/Source/platform/v8_inspector/V8InjectedScriptHost.cpp index f93990e..623300e 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/V8InjectedScriptHost.cpp +++ b/third_party/WebKit/Source/platform/v8_inspector/V8InjectedScriptHost.cpp
@@ -179,6 +179,7 @@ v8::Local<v8::Object> listenerEntry = v8::Object::New(isolate); listenerEntry->Set(toV8StringInternalized(isolate, "listener"), function); listenerEntry->Set(toV8StringInternalized(isolate, "useCapture"), v8::Boolean::New(isolate, listeners[i].useCapture)); + listenerEntry->Set(toV8StringInternalized(isolate, "passive"), v8::Boolean::New(isolate, listeners[i].passive)); result->Set(v8::Number::New(isolate, outputIndex++), listenerEntry); } return result;
diff --git a/third_party/WebKit/Source/platform/v8_inspector/public/V8EventListenerInfo.h b/third_party/WebKit/Source/platform/v8_inspector/public/V8EventListenerInfo.h index 1acb360..03370be8 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/public/V8EventListenerInfo.h +++ b/third_party/WebKit/Source/platform/v8_inspector/public/V8EventListenerInfo.h
@@ -14,15 +14,17 @@ class V8EventListenerInfo { public: - V8EventListenerInfo(const String16& eventType, bool useCapture, v8::Local<v8::Object> handler) + V8EventListenerInfo(const String16& eventType, bool useCapture, bool passive, v8::Local<v8::Object> handler) : eventType(eventType) , useCapture(useCapture) + , passive(passive) , handler(handler) { } const String16 eventType; bool useCapture; + bool passive; v8::Local<v8::Object> handler; };
diff --git a/third_party/WebKit/Source/web/FrameLoaderClientImpl.cpp b/third_party/WebKit/Source/web/FrameLoaderClientImpl.cpp index e71486a..048f7252 100644 --- a/third_party/WebKit/Source/web/FrameLoaderClientImpl.cpp +++ b/third_party/WebKit/Source/web/FrameLoaderClientImpl.cpp
@@ -75,6 +75,7 @@ #include "platform/plugins/PluginData.h" #include "public/platform/Platform.h" #include "public/platform/WebApplicationCacheHost.h" +#include "public/platform/WebMediaPlayerSource.h" #include "public/platform/WebMimeRegistry.h" #include "public/platform/WebRTCPeerConnectionHandler.h" #include "public/platform/WebSecurityOrigin.h" @@ -820,7 +821,7 @@ PassOwnPtr<WebMediaPlayer> FrameLoaderClientImpl::createWebMediaPlayer( HTMLMediaElement& htmlMediaElement, - const WebURL& url, + const WebMediaPlayerSource& source, WebMediaPlayerClient* client) { WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame( @@ -835,7 +836,8 @@ HTMLMediaElementEncryptedMedia& encryptedMedia = HTMLMediaElementEncryptedMedia::from(htmlMediaElement); WebString sinkId(HTMLMediaElementAudioOutputDevice::sinkId(htmlMediaElement)); - return adoptPtr(webFrame->client()->createMediaPlayer(url, client, &encryptedMedia, + return adoptPtr(webFrame->client()->createMediaPlayer(source, + client, &encryptedMedia, encryptedMedia.contentDecryptionModule(), sinkId, webMediaSession)); }
diff --git a/third_party/WebKit/Source/web/FrameLoaderClientImpl.h b/third_party/WebKit/Source/web/FrameLoaderClientImpl.h index 22ad6d58e..a154bb4 100644 --- a/third_party/WebKit/Source/web/FrameLoaderClientImpl.h +++ b/third_party/WebKit/Source/web/FrameLoaderClientImpl.h
@@ -129,7 +129,7 @@ HTMLPlugInElement*, const KURL&, const Vector<WTF::String>&, const Vector<WTF::String>&, const WTF::String&, bool loadManually, DetachedPluginPolicy) override; - PassOwnPtr<WebMediaPlayer> createWebMediaPlayer(HTMLMediaElement&, const WebURL&, WebMediaPlayerClient*) override; + PassOwnPtr<WebMediaPlayer> createWebMediaPlayer(HTMLMediaElement&, const WebMediaPlayerSource&, WebMediaPlayerClient*) override; PassOwnPtr<WebMediaSession> createWebMediaSession() override; ObjectContentType getObjectContentType( const KURL&, const WTF::String& mimeType, bool shouldPreferPlugInsForImages) override;
diff --git a/third_party/WebKit/public/blink_headers.gypi b/third_party/WebKit/public/blink_headers.gypi index 1361a43..42a17f0 100644 --- a/third_party/WebKit/public/blink_headers.gypi +++ b/third_party/WebKit/public/blink_headers.gypi
@@ -125,6 +125,7 @@ "platform/WebMediaKeySystemMediaCapability.h", "platform/WebMediaPlayer.h", "platform/WebMediaPlayerClient.h", + "platform/WebMediaPlayerSource.h", "platform/WebMediaRecorderHandler.h", "platform/WebMediaRecorderHandlerClient.h", "platform/WebMediaSource.h",
diff --git a/third_party/WebKit/public/platform/WebMediaPlayer.h b/third_party/WebKit/public/platform/WebMediaPlayer.h index 36f5f0bab..23bb865 100644 --- a/third_party/WebKit/public/platform/WebMediaPlayer.h +++ b/third_party/WebKit/public/platform/WebMediaPlayer.h
@@ -50,6 +50,7 @@ class WebAudioSourceProvider; class WebContentDecryptionModule; +class WebMediaPlayerSource; class WebSecurityOrigin; class WebString; class WebURL; @@ -106,7 +107,7 @@ virtual ~WebMediaPlayer() { } - virtual void load(LoadType, const WebURL&, CORSMode) = 0; + virtual void load(LoadType, const WebMediaPlayerSource&, CORSMode) = 0; // Playback controls. virtual void play() = 0;
diff --git a/third_party/WebKit/public/platform/WebMediaPlayerSource.h b/third_party/WebKit/public/platform/WebMediaPlayerSource.h new file mode 100644 index 0000000..606a4a2b --- /dev/null +++ b/third_party/WebKit/public/platform/WebMediaPlayerSource.h
@@ -0,0 +1,36 @@ +// Copyright 2016 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 WebMediaPlayerSource_h +#define WebMediaPlayerSource_h + +#include "WebCommon.h" +#include "WebMediaStream.h" +#include "WebURL.h" + +namespace blink { + +class BLINK_PLATFORM_EXPORT WebMediaPlayerSource { +public: + WebMediaPlayerSource(); + explicit WebMediaPlayerSource(const WebURL&); + explicit WebMediaPlayerSource(const WebMediaStream&); + ~WebMediaPlayerSource(); + + bool isURL() const; + WebURL getAsURL() const; + + bool isMediaProviderObject() const; + + bool isMediaStream() const; + WebMediaStream getAsMediaStream() const; + +private: + WebURL m_url; + WebMediaStream m_mediaStream; +}; + +} // namespace blink + +#endif // WebMediaPlayerSource_h
diff --git a/third_party/WebKit/public/web/WebFrameClient.h b/third_party/WebKit/public/web/WebFrameClient.h index 53ae47d..a396b34 100644 --- a/third_party/WebKit/public/web/WebFrameClient.h +++ b/third_party/WebKit/public/web/WebFrameClient.h
@@ -80,7 +80,9 @@ class WebMediaPlayer; class WebMediaPlayerClient; class WebMediaPlayerEncryptedMediaClient; +class WebMediaPlayerSource; class WebMediaSession; +class WebMediaStream; class WebMIDIClient; class WebNotificationPermissionCallback; class WebPermissionClient; @@ -116,7 +118,7 @@ // May return null. // WebContentDecryptionModule* may be null if one has not yet been set. - virtual WebMediaPlayer* createMediaPlayer(const WebURL&, WebMediaPlayerClient*, WebMediaPlayerEncryptedMediaClient*, WebContentDecryptionModule*, const WebString& sinkId, WebMediaSession*) { return 0; } + virtual WebMediaPlayer* createMediaPlayer(const WebMediaPlayerSource&, WebMediaPlayerClient*, WebMediaPlayerEncryptedMediaClient*, WebContentDecryptionModule*, const WebString& sinkId, WebMediaSession*) { return 0; } // May return null. virtual WebMediaSession* createMediaSession() { return 0; }
diff --git a/third_party/closure_compiler/compiler_test.py b/third_party/closure_compiler/compiler_test.py index 479fb73..ebeb738 100755 --- a/third_party/closure_compiler/compiler_test.py +++ b/third_party/closure_compiler/compiler_test.py
@@ -32,7 +32,9 @@ class CompilerTest(unittest.TestCase): _ASSERT_DEFINITION = Processor(_ASSERT_JS).contents - _CR_DEFINE_DEFINITION = (Processor(_PROMISE_RESOLVER_JS).contents + + _PROMISE_RESOLVER_DEFINITION = (_ASSERT_DEFINITION + + Processor(_PROMISE_RESOLVER_JS).contents) + _CR_DEFINE_DEFINITION = (_PROMISE_RESOLVER_DEFINITION + Processor(_CR_JS).contents) _CR_UI_DECORATE_DEFINITION = Processor(_CR_UI_JS).contents
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index 9e2a2e1..cf5e0ca 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml
@@ -54934,6 +54934,9 @@ </histogram> <histogram name="UMA.LogLoadComplete called"> + <obsolete> + No longer tracked. + </obsolete> <owner>asvitkine@chromium.org</owner> <summary> Simple counter of the number of times LogLoadComplete was called (bug @@ -55180,6 +55183,9 @@ </histogram> <histogram name="UMA.UsedResetVariationsFlag" enum="BooleanUsage"> + <obsolete> + No longer tracked. + </obsolete> <owner>asvitkine@chromium.org</owner> <summary> Log whether the --reset-variation-state flag was set before the low entropy @@ -61482,6 +61488,7 @@ <int value="4" label="CPMD_BAD_ORIGIN_FOCUSED_PASSWORD_FORM_FOUND"/> <int value="5" label="CPMD_BAD_ORIGIN_IN_PAGE_NAVIGATION"/> <int value="6" label="CPMD_BAD_ORIGIN_PASSWORD_NO_LONGER_GENERATED"/> + <int value="7" label="CPMD_BAD_ORIGIN_PRESAVE_GENERATED_PASSWORD"/> </enum> <enum name="BadSyncDataReason" type="int">
diff --git a/ui/webui/resources/html/promise_resolver.html b/ui/webui/resources/html/promise_resolver.html index 3a171fa..01c2f2c328 100644 --- a/ui/webui/resources/html/promise_resolver.html +++ b/ui/webui/resources/html/promise_resolver.html
@@ -1 +1,2 @@ +<link rel="import" href="chrome://resources/html/assert.html"> <script src="chrome://resources/js/promise_resolver.js"></script>
diff --git a/ui/webui/resources/js/compiled_resources2.gyp b/ui/webui/resources/js/compiled_resources2.gyp index e24ce72..609027d 100644 --- a/ui/webui/resources/js/compiled_resources2.gyp +++ b/ui/webui/resources/js/compiled_resources2.gyp
@@ -60,6 +60,7 @@ }, { 'target_name': 'promise_resolver', + 'dependencies': ['assert'], 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'], }, {
diff --git a/ui/webui/resources/js/promise_resolver.js b/ui/webui/resources/js/promise_resolver.js index 0759c95..ba84ada0 100644 --- a/ui/webui/resources/js/promise_resolver.js +++ b/ui/webui/resources/js/promise_resolver.js
@@ -21,15 +21,29 @@ * @template T */ function PromiseResolver() { - /** @type {function(T): void} */ - this.resolve; + /** @private {function(T): void} */ + this.resolve_; - /** @type {function(*=): void} */ - this.reject; + /** @private {function(*=): void} */ + this.reject_; - /** @type {!Promise<T>} */ - this.promise = new Promise(function(resolve, reject) { - this.resolve = resolve; - this.reject = reject; + /** @private {!Promise<T>} */ + this.promise_ = new Promise(function(resolve, reject) { + this.resolve_ = resolve; + this.reject_ = reject; }.bind(this)); } + +PromiseResolver.prototype = { + /** @return {!Promise<T>} */ + get promise() { return this.promise_; }, + set promise(p) { assertNotReached(); }, + + /** @return {function(T): void} */ + get resolve() { return this.resolve_; }, + set resolve(r) { assertNotReached(); }, + + /** @return {function(*=): void} */ + get reject() { return this.reject_; }, + set reject(s) { assertNotReached(); }, +};