Skip to content

Commit

Permalink
fix: modernize-use-nodiscard clang-tidy warnings (electron#44808)
Browse files Browse the repository at this point in the history
  • Loading branch information
ckerr authored Nov 25, 2024
1 parent 7e7010d commit 024fee4
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion shell/browser/electron_permission_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class ElectronPermissionManager::PendingRequest {
return content::RenderFrameHost::FromID(render_frame_host_id_);
}

bool IsComplete() const { return remaining_results_ == 0; }
[[nodiscard]] bool IsComplete() const { return remaining_results_ == 0; }

void RunCallback() {
if (!callback_.is_null()) {
Expand Down
8 changes: 4 additions & 4 deletions shell/browser/osr/osr_render_widget_host_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@ class ElectronDelegatedFrameHostClient
const ElectronDelegatedFrameHostClient&) = delete;

// content::DelegatedFrameHostClient
ui::Layer* DelegatedFrameHostGetLayer() const override {
[[nodiscard]] ui::Layer* DelegatedFrameHostGetLayer() const override {
return view_->root_layer();
}

bool DelegatedFrameHostIsVisible() const override {
[[nodiscard]] bool DelegatedFrameHostIsVisible() const override {
return view_->IsShowing();
}

SkColor DelegatedFrameHostGetGutterColor() const override {
[[nodiscard]] SkColor DelegatedFrameHostGetGutterColor() const override {
if (view_->render_widget_host()->delegate() &&
view_->render_widget_host()->delegate()->IsFullscreen()) {
return SK_ColorWHITE;
Expand All @@ -156,7 +156,7 @@ class ElectronDelegatedFrameHostClient
view_->render_widget_host()->DidProcessFrame(frame_token, activation_time);
}

float GetDeviceScaleFactor() const override {
[[nodiscard]] float GetDeviceScaleFactor() const override {
return view_->GetDeviceScaleFactor();
}

Expand Down
2 changes: 1 addition & 1 deletion shell/common/api/electron_api_url_loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class BufferDataSource : public mojo::DataPipeProducer::DataSource {

private:
// mojo::DataPipeProducer::DataSource:
uint64_t GetLength() const override { return buffer_.size(); }
[[nodiscard]] uint64_t GetLength() const override { return buffer_.size(); }
ReadResult Read(uint64_t offset, base::span<char> buffer) override {
ReadResult result;
if (offset <= buffer_.size()) {
Expand Down
6 changes: 3 additions & 3 deletions shell/common/extensions/electron_extensions_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ class ElectronPermissionMessageProvider
const ElectronPermissionMessageProvider&) = delete;

// PermissionMessageProvider implementation.
extensions::PermissionMessages GetPermissionMessages(
[[nodiscard]] extensions::PermissionMessages GetPermissionMessages(
const extensions::PermissionIDSet& permissions) const override {
return extensions::PermissionMessages();
}

bool IsPrivilegeIncrease(
[[nodiscard]] bool IsPrivilegeIncrease(
const extensions::PermissionSet& granted_permissions,
const extensions::PermissionSet& requested_permissions,
extensions::Manifest::Type extension_type) const override {
Expand All @@ -52,7 +52,7 @@ class ElectronPermissionMessageProvider
return false;
}

extensions::PermissionIDSet GetAllPermissionIDs(
[[nodiscard]] extensions::PermissionIDSet GetAllPermissionIDs(
const extensions::PermissionSet& permissions,
extensions::Manifest::Type extension_type) const override {
return extensions::PermissionIDSet();
Expand Down
2 changes: 1 addition & 1 deletion shell/common/gin_converters/osr_converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct OffscreenReleaseHolderMonitor {
holder_ = nullptr;
}

bool IsTextureReleased() const { return holder_ == nullptr; }
[[nodiscard]] bool IsTextureReleased() const { return holder_ == nullptr; }

v8::Persistent<v8::Value>* CreatePersistent(v8::Isolate* isolate,
v8::Local<v8::Value> value) {
Expand Down
2 changes: 1 addition & 1 deletion shell/common/gin_helper/callback.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class RefCountedGlobal
RefCountedGlobal(v8::Isolate* isolate, v8::Local<v8::Value> value)
: handle_(isolate, value.As<T>()) {}

bool IsAlive() const { return !handle_.IsEmpty(); }
[[nodiscard]] bool IsAlive() const { return !handle_.IsEmpty(); }

v8::Local<T> NewHandle(v8::Isolate* isolate) const {
return v8::Local<T>::New(isolate, handle_);
Expand Down
2 changes: 1 addition & 1 deletion shell/common/heap_snapshot.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class HeapSnapshotOutputStream : public v8::OutputStream {
DCHECK(file_);
}

bool IsComplete() const { return is_complete_; }
[[nodiscard]] bool IsComplete() const { return is_complete_; }

// v8::OutputStream
int GetChunkSize() override { return 65536; }
Expand Down
2 changes: 1 addition & 1 deletion shell/renderer/api/electron_api_spell_check_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class SpellCheckClient::SpellcheckRequest {
SpellcheckRequest& operator=(const SpellcheckRequest&) = delete;
~SpellcheckRequest() = default;

const std::u16string& text() const { return text_; }
[[nodiscard]] const std::u16string& text() const { return text_; }
blink::WebTextCheckingCompletion* completion() { return completion_.get(); }
std::vector<Word>& wordlist() { return word_list_; }

Expand Down
2 changes: 1 addition & 1 deletion shell/renderer/renderer_client_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class ChromePdfInternalPluginDelegate final
~ChromePdfInternalPluginDelegate() override = default;

// `pdf::PdfInternalPluginDelegate`:
bool IsAllowedOrigin(const url::Origin& origin) const override {
[[nodiscard]] bool IsAllowedOrigin(const url::Origin& origin) const override {
return origin.scheme() == extensions::kExtensionScheme &&
origin.host() == extension_misc::kPdfExtensionId;
}
Expand Down

0 comments on commit 024fee4

Please sign in to comment.