Skip to content

Commit

Permalink
Fix remaining incompatibilities between scoped_ptr and unique_ptr.
Browse files Browse the repository at this point in the history
scoped_ptr is more convertible to bool than std::unique_ptr.
  bool x = scoped_ptr<int>();  // compiles
  bool y = std::unique_ptr<int>();  // explodes

std::unique_ptr is not streamable:
  LOG(ERROR) << scoped_ptr<int>();  // compiles
  LOG(ERROR) << std::unique_ptr<int>();  // explodes

BUG=579269,579270
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel

Review URL: https://codereview.chromium.org/1609923002

Cr-Commit-Position: refs/heads/master@{#370266}
  • Loading branch information
zetafunction authored and Commit bot committed Jan 20, 2016
1 parent ec93329 commit 5d64b52
Show file tree
Hide file tree
Showing 60 changed files with 71 additions and 76 deletions.
2 changes: 1 addition & 1 deletion ash/test/test_keyboard_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ TestKeyboardUI::TestKeyboardUI() {}
TestKeyboardUI::~TestKeyboardUI() {}

bool TestKeyboardUI::HasKeyboardWindow() const {
return keyboard_;
return !!keyboard_;
}

bool TestKeyboardUI::ShouldWindowOverscroll(aura::Window* window) const {
Expand Down
2 changes: 1 addition & 1 deletion ash/wm/window_state.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ WindowState::~WindowState() {
}

bool WindowState::HasDelegate() const {
return delegate_;
return !!delegate_;
}

void WindowState::SetDelegate(scoped_ptr<WindowStateDelegate> delegate) {
Expand Down
4 changes: 1 addition & 3 deletions ash/wm/window_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,7 @@ class ASH_EXPORT WindowState : public aura::WindowObserver {
void RemoveObserver(WindowStateObserver* observer);

// Whether the window is being dragged.
bool is_dragged() const {
return drag_details_;
}
bool is_dragged() const { return !!drag_details_; }

// Whether or not the window's position can be managed by the
// auto management logic.
Expand Down
2 changes: 1 addition & 1 deletion blimp/net/blimp_message_output_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ int BlimpMessageOutputBuffer::GetUnacknowledgedMessageCountForTest() const {
void BlimpMessageOutputBuffer::ProcessMessage(
scoped_ptr<BlimpMessage> message,
const net::CompletionCallback& callback) {
DVLOG(2) << "OutputBuffer::ProcessMessage " << message;
DVLOG(2) << "OutputBuffer::ProcessMessage " << message.get();

message->set_message_id(++prev_message_id_);

Expand Down
2 changes: 1 addition & 1 deletion blimp/net/browser_connection_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ scoped_ptr<BlimpMessageProcessor> BrowserConnectionHandler::RegisterFeature(
void BrowserConnectionHandler::HandleConnection(
scoped_ptr<BlimpConnection> connection) {
DCHECK(connection);
VLOG(1) << "HandleConnection " << connection;
VLOG(1) << "HandleConnection " << connection.get();

if (connection_) {
DropCurrentConnection();
Expand Down
2 changes: 1 addition & 1 deletion blimp/net/engine_authentication_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void Authenticator::ProcessMessage(scoped_ptr<BlimpMessage> message,
<< message->protocol_control().start_connection().client_token();
OnConnectionAuthenticated(true);
} else {
DVLOG(1) << "Expected START_CONNECTION message, got " << message
DVLOG(1) << "Expected START_CONNECTION message, got " << message.get()
<< " instead.";
OnConnectionAuthenticated(false);
}
Expand Down
4 changes: 2 additions & 2 deletions cc/animation/element_animations.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ class CC_EXPORT ElementAnimations : public AnimationDelegate,
void LayerUnregistered(int layer_id, LayerTreeType tree_type);

bool has_active_value_observer_for_testing() const {
return active_value_observer_;
return !!active_value_observer_;
}
bool has_pending_value_observer_for_testing() const {
return pending_value_observer_;
return !!pending_value_observer_;
}

void AddPlayer(AnimationPlayer* player);
Expand Down
2 changes: 1 addition & 1 deletion cc/input/top_controls_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class CC_EXPORT TopControlsManager
float TopControlsShownRatio() const;
float TopControlsHeight() const;

bool has_animation() const { return top_controls_animation_; }
bool has_animation() const { return !!top_controls_animation_; }
AnimationDirection animation_direction() { return animation_direction_; }

void UpdateTopControlsState(TopControlsState constraints,
Expand Down
4 changes: 2 additions & 2 deletions cc/layers/layer_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver,
const LayerImpl* replica_layer() const { return replica_layer_.get(); }
scoped_ptr<LayerImpl> TakeReplicaLayer();

bool has_mask() const { return mask_layer_; }
bool has_replica() const { return replica_layer_; }
bool has_mask() const { return !!mask_layer_; }
bool has_replica() const { return !!replica_layer_; }
bool replica_has_mask() const {
return replica_layer_ && (mask_layer_ || replica_layer_->mask_layer_);
}
Expand Down
2 changes: 1 addition & 1 deletion cc/trees/single_thread_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void SingleThreadProxy::FinishAllRendering() {

bool SingleThreadProxy::IsStarted() const {
DCHECK(task_runner_provider_->IsMainThread());
return layer_tree_host_impl_;
return !!layer_tree_host_impl_;
}

bool SingleThreadProxy::CommitToActiveTree() const {
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/certificate_manager_model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ void CertificateManagerModel::DidGetCertDBOnIOThread(
net::NSSCertDatabase* cert_db) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);

bool is_user_db_available = cert_db->GetPublicSlot();
bool is_user_db_available = !!cert_db->GetPublicSlot();
bool is_tpm_available = false;
#if defined(OS_CHROMEOS)
is_tpm_available = crypto::IsTPMTokenEnabledForNSS();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,7 @@ bool FileSystemChooseEntryFunction::RunAsync() {

file_system::ChooseEntryOptions* options = params->options.get();
if (options) {
multiple_ = options->accepts_multiple;
multiple_ = !!options->accepts_multiple;
if (multiple_)
picker_type = ui::SelectFileDialog::SELECT_OPEN_MULTI_FILE;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void PrivetV3Session::FetcherDelegate::OnURLFetchComplete(
}

bool has_error = value->HasKey(kPrivetV3KeyError);
LOG_IF(ERROR, has_error) << "Response: " << value;
LOG_IF(ERROR, has_error) << "Response: " << value.get();
ReplyAndDestroyItself(
has_error ? Result::STATUS_DEVICEERROR : Result::STATUS_SUCCESS, *value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,11 @@ void WebstorePrivateBeginInstallWithManifest3Function::HandleInstallProceed() {
WebstoreInstaller::Approval::CreateWithNoInstallPrompt(
chrome_details_.GetProfile(), details().id,
std::move(parsed_manifest_), false));
approval->use_app_installed_bubble = details().app_install_bubble;
approval->enable_launcher = details().enable_launcher;
approval->use_app_installed_bubble = !!details().app_install_bubble;
approval->enable_launcher = !!details().enable_launcher;
// If we are enabling the launcher, we should not show the app list in order
// to train the user to open it themselves at least once.
approval->skip_post_install_ui = details().enable_launcher;
approval->skip_post_install_ui = !!details().enable_launcher;
approval->dummy_extension = dummy_extension_.get();
approval->installing_icon = gfx::ImageSkia::CreateFrom1xBitmap(icon_);
if (details().authuser)
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/profile_resetter/brandcode_config_fetcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class BrandcodeConfigFetcher : public net::URLFetcherDelegate {
const std::string& brandcode);
~BrandcodeConfigFetcher() override;

bool IsActive() const { return config_fetcher_; }
bool IsActive() const { return !!config_fetcher_; }

scoped_ptr<BrandcodedDefaultSettings> GetSettings() {
return std::move(default_settings_);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,7 @@ class TestLockHandler : public proximity_auth::ScreenlockBridge::LockHandler {
}

// Whether the custom icon is set.
bool HasCustomIcon() const {
return last_custom_icon_;
}
bool HasCustomIcon() const { return !!last_custom_icon_; }

// If custom icon is set, returns the icon's id.
// If there is no icon, or if it doesn't have an id set, returns an empty
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ssl/common_name_mismatch_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,5 @@ void CommonNameMismatchHandler::OnURLFetchComplete(
}

bool CommonNameMismatchHandler::IsCheckingSuggestedUrl() const {
return url_fetcher_;
return !!url_fetcher_;
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class SyncTaskToken {
void FinalizeTaskLog(const std::string& result_description);
void RecordLog(const std::string& message);

bool has_task_log() const { return task_log_; }
bool has_task_log() const { return !!task_log_; }
void SetTaskLog(scoped_ptr<TaskLogger::TaskLog> task_log);
scoped_ptr<TaskLogger::TaskLog> PassTaskLog();

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/extensions/extension_installed_bubble.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class ExtensionInstalledBubble : public BubbleDelegate {
const Browser* browser() const { return browser_; }
const SkBitmap& icon() const { return icon_; }
BubbleType type() const { return type_; }
bool has_command_keybinding() const { return action_command_; }
bool has_command_keybinding() const { return !!action_command_; }
int options() const { return options_; }
AnchorPosition anchor_position() const { return anchor_position_; }

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/omnibox/chrome_omnibox_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ void ChromeOmniboxClient::OnResultChanged(

const auto match = std::find_if(
result.begin(), result.end(),
[](const AutocompleteMatch& current)->bool { return current.answer; });
[](const AutocompleteMatch& current) { return !!current.answer; });
if (match != result.end()) {
BitmapFetcherService* image_service =
BitmapFetcherServiceFactory::GetForBrowserContext(profile_);
Expand Down
2 changes: 1 addition & 1 deletion components/autofill/core/browser/autofill_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ void AutofillManager::ImportFormData(const FormStructure& submitted_form) {
}
}

DumpAutofillData(imported_credit_card);
DumpAutofillData(!!imported_credit_card);
}
#endif // ENABLE_FORM_DEBUG_DUMP

Expand Down
2 changes: 1 addition & 1 deletion components/drive/resource_metadata_storage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ bool ResourceMetadataStorage::Initialize() {
UMA_HISTOGRAM_ENUMERATION("Drive.MetadataDBInitResult",
init_result,
DB_INIT_MAX_VALUE);
return resource_map_;
return !!resource_map_;
}

void ResourceMetadataStorage::RecoverCacheInfoFromTrashedResourceMap(
Expand Down
2 changes: 1 addition & 1 deletion components/drive/service/fake_drive_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ bool FakeDriveService::LoadAppListForDriveApi(
CHECK_EQ(base::Value::TYPE_DICTIONARY, value->GetType());
app_info_value_.reset(
static_cast<base::DictionaryValue*>(value.release()));
return app_info_value_;
return !!app_info_value_;
}

void FakeDriveService::AddApp(const std::string& app_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,9 @@ class TrackedPreferencesMigrationTest : public testing::Test {
bool HasPrefs(MockPrefStoreID store_id) {
switch (store_id) {
case MOCK_UNPROTECTED_PREF_STORE:
return unprotected_prefs_;
return !!unprotected_prefs_;
case MOCK_PROTECTED_PREF_STORE:
return protected_prefs_;
return !!protected_prefs_;
}
NOTREACHED();
return false;
Expand Down
2 changes: 1 addition & 1 deletion content/browser/compositor/delegated_frame_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class CONTENT_EXPORT DelegatedFrameHost
void BeginFrameSubscription(
scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber);
void EndFrameSubscription();
bool HasFrameSubscriber() const { return frame_subscriber_; }
bool HasFrameSubscriber() const { return !!frame_subscriber_; }
uint32_t GetSurfaceIdNamespace();
// Returns a null SurfaceId if this DelegatedFrameHost has not yet created
// a compositor Surface.
Expand Down
4 changes: 2 additions & 2 deletions content/browser/media/media_web_contents_observer.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ class CONTENT_EXPORT MediaWebContentsObserver : public WebContentsObserver {
void WasHidden() override;

bool has_audio_power_save_blocker_for_testing() const {
return audio_power_save_blocker_;
return !!audio_power_save_blocker_;
}

bool has_video_power_save_blocker_for_testing() const {
return video_power_save_blocker_;
return !!video_power_save_blocker_;
}

private:
Expand Down
2 changes: 1 addition & 1 deletion content/browser/renderer_host/input/touch_emulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class CONTENT_EXPORT TouchEmulator : public ui::GestureProviderClient {

// Note that TouchEmulator should always listen to touch events and their acks
// (even in disabled state) to track native stream presence.
bool enabled() const { return gesture_provider_; }
bool enabled() const { return !!gesture_provider_; }

// Returns |true| if the event was consumed. Consumed event should not
// propagate any further.
Expand Down
2 changes: 1 addition & 1 deletion content/browser/renderer_host/input/touch_event_queue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ bool TouchEventQueue::IsAckTimeoutEnabled() const {
}

bool TouchEventQueue::HasPendingAsyncTouchMoveForTesting() const {
return pending_async_touchmove_;
return !!pending_async_touchmove_;
}

bool TouchEventQueue::IsTimeoutRunningForTesting() const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ bool TouchscreenTapSuppressionController::FilterTapEvent(
return true;

case WebInputEvent::GestureTapUnconfirmed:
return stashed_tap_down_;
return !!stashed_tap_down_;

case WebInputEvent::GestureTapCancel:
case WebInputEvent::GestureTap:
Expand Down
2 changes: 1 addition & 1 deletion content/browser/ssl/ssl_client_auth_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class SSLClientAuthHandler::Core : public base::RefCountedThreadSafe<Core> {
client_cert_store_(std::move(client_cert_store)),
cert_request_info_(cert_request_info) {}

bool has_client_cert_store() const { return client_cert_store_; }
bool has_client_cert_store() const { return !!client_cert_store_; }

void GetClientCerts() {
if (client_cert_store_) {
Expand Down
2 changes: 1 addition & 1 deletion content/browser/tracing/background_tracing_manager_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ bool BackgroundTracingManagerImpl::SetActiveScenario(
}

bool BackgroundTracingManagerImpl::HasActiveScenario() {
return config_;
return !!config_;
}

bool BackgroundTracingManagerImpl::IsTracingForTesting() {
Expand Down
2 changes: 1 addition & 1 deletion content/browser/wake_lock/wake_lock_service_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void WakeLockServiceContext::CancelWakeLock(int render_process_id,
}

bool WakeLockServiceContext::HasWakeLockForTests() const {
return wake_lock_;
return !!wake_lock_;
}

void WakeLockServiceContext::CreateWakeLock() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class OverscrollNavigationOverlayTest : public RenderViewHostImplTestHarness {
// offset -1 on layer_delegate_.
scoped_ptr<aura::Window> window(
GetOverlay()->CreateBackWindow(GetBackSlideWindowBounds()));
bool window_created = window;
bool window_created = !!window;
// Performs BACK navigation, sets image from layer_delegate_ on
// image_delegate_.
GetOverlay()->OnOverscrollCompleting();
Expand Down
2 changes: 1 addition & 1 deletion crypto/scoped_test_nss_db.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CRYPTO_EXPORT ScopedTestNSSDB {
ScopedTestNSSDB();
~ScopedTestNSSDB();

bool is_open() const { return slot_; }
bool is_open() const { return !!slot_; }
PK11SlotInfo* slot() const { return slot_.get(); }

private:
Expand Down
3 changes: 2 additions & 1 deletion extensions/browser/api/storage/storage_api_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ class StorageApiUnittest : public ApiUnitTest {
return testing::AssertionFailure() << "No result";
base::DictionaryValue* dict = NULL;
if (!result->GetAsDictionary(&dict))
return testing::AssertionFailure() << result << " was not a dictionary.";
return testing::AssertionFailure() << result.get()
<< " was not a dictionary.";
if (!dict->GetString(key, value)) {
return testing::AssertionFailure() << " could not retrieve a string from"
<< dict << " at " << key;
Expand Down
2 changes: 1 addition & 1 deletion media/audio/sounds/audio_stream_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ AudioStreamHandler::~AudioStreamHandler() {

bool AudioStreamHandler::IsInitialized() const {
DCHECK(CalledOnValidThread());
return stream_;
return !!stream_;
}

bool AudioStreamHandler::Play() {
Expand Down
2 changes: 1 addition & 1 deletion media/base/bind_to_current_loop_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void BoundBoolSetFromScopedPtr(bool* var, scoped_ptr<bool> val) {
void BoundBoolSetFromScopedPtrFreeDeleter(
bool* var,
scoped_ptr<bool, base::FreeDeleter> val) {
*var = val;
*var = *val;
}

void BoundBoolSetFromScopedArray(bool* var, scoped_ptr<bool[]> val) {
Expand Down
2 changes: 1 addition & 1 deletion media/base/pipeline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ void Pipeline::OnAddTextTrack(const TextTrackConfig& config,

void Pipeline::InitializeDemuxer(const PipelineStatusCB& done_cb) {
DCHECK(task_runner_->BelongsToCurrentThread());
demuxer_->Initialize(this, done_cb, text_renderer_);
demuxer_->Initialize(this, done_cb, !!text_renderer_);
}

void Pipeline::InitializeRenderer(const PipelineStatusCB& done_cb) {
Expand Down
2 changes: 1 addition & 1 deletion media/blink/buffered_resource_loader_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ class BufferedResourceLoaderTest : public testing::Test {
EXPECT_LE(loader_->buffer_.backward_capacity(), kMaxBufferCapacity);
}

bool HasActiveLoader() { return loader_->active_loader_; }
bool HasActiveLoader() { return !!loader_->active_loader_; }

MOCK_METHOD1(StartCallback, void(BufferedResourceLoader::Status));
MOCK_METHOD2(ReadCallback, void(BufferedResourceLoader::Status, int));
Expand Down
2 changes: 1 addition & 1 deletion media/filters/decoder_stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ void DecoderStream<StreamType>::OnDecoderSelected(
}

media_log_->SetBooleanProperty(GetStreamTypeString() + "_dds",
decrypting_demuxer_stream_);
!!decrypting_demuxer_stream_);
media_log_->SetStringProperty(GetStreamTypeString() + "_decoder",
decoder_->GetDisplayName());

Expand Down
2 changes: 1 addition & 1 deletion net/cert/ct_objects_extractor_openssl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ bool GetPrecertLogEntry(X509Certificate::OSCertHandle leaf,
// Extract the issuer's public key.
std::string issuer_der;
if (!X509Certificate::GetDEREncoded(issuer, &issuer_der))
return ScopedX509();
return false;
base::StringPiece issuer_key;
if (!asn1::ExtractSPKIFromDERCert(issuer_der, &issuer_key))
return false;
Expand Down
Loading

0 comments on commit 5d64b52

Please sign in to comment.