Skip to content

Commit

Permalink
WebLocks: Minor improvements in browser-side implementation.
Browse files Browse the repository at this point in the history
Change-Id: I366028613a73736af28799440cf87bfac5af3aae
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2093551
Commit-Queue: Joshua Bell <jsbell@chromium.org>
Reviewed-by: Joshua Bell <jsbell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748318}
  • Loading branch information
pwnall authored and Commit Bot committed Mar 9, 2020
1 parent 6bc859a commit 4da20a5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
9 changes: 5 additions & 4 deletions content/browser/locks/lock_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,16 @@ class LockManager::Lock {
mojo::SelfOwnedAssociatedReceiverRef<blink::mojom::LockHandle> handle_;
};

LockManager::LockManager() {}
LockManager::LockManager() = default;

LockManager::~LockManager() = default;

// The OriginState class manages and exposes the state of lock requests
// for a given origin.
class LockManager::OriginState {
public:
OriginState(LockManager* lock_manager) : lock_manager_(lock_manager) {}
explicit OriginState(LockManager* lock_manager)
: lock_manager_(lock_manager) {}
~OriginState() = default;

// Helper function for breaking the lock at the front of a given request
Expand Down Expand Up @@ -263,7 +264,7 @@ class LockManager::OriginState {
}
}

bool IsEmpty() { return lock_id_to_iterator_.empty(); }
bool IsEmpty() const { return lock_id_to_iterator_.empty(); }

std::pair<std::vector<blink::mojom::LockInfoPtr>,
std::vector<blink::mojom::LockInfoPtr>>
Expand Down Expand Up @@ -300,7 +301,7 @@ class LockManager::OriginState {

// Any OriginState is owned by a LockManager so a raw pointer back to an
// OriginState's owning LockManager is safe.
LockManager* lock_manager_;
LockManager* const lock_manager_;
};

void LockManager::BindReceiver(
Expand Down
14 changes: 9 additions & 5 deletions content/browser/locks/lock_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_BROWSER_LOCKS_LOCK_CONTEXT_H_
#define CONTENT_BROWSER_LOCKS_LOCK_CONTEXT_H_
#ifndef CONTENT_BROWSER_LOCKS_LOCK_MANAGER_H_
#define CONTENT_BROWSER_LOCKS_LOCK_MANAGER_H_

#include <cstdint>
#include <map>
#include <memory>
#include <string>

#include "base/callback.h"
#include "base/memory/weak_ptr.h"
#include "base/sequence_checker.h"
#include "content/public/browser/browser_context.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
Expand All @@ -25,6 +28,9 @@ class LockManager : public blink::mojom::LockManager {
LockManager();
~LockManager() override;

LockManager(const LockManager&) = delete;
LockManager& operator=(const LockManager&) = delete;

// Binds |receiver| to this LockManager. |receiver| belongs to a frame or
// worker at |origin| hosted by |render_process_id|. If it belongs to a frame,
// |render_frame_id| identifies it, otherwise it is MSG_ROUTING_NONE.
Expand Down Expand Up @@ -73,10 +79,8 @@ class LockManager : public blink::mojom::LockManager {

SEQUENCE_CHECKER(sequence_checker_);
base::WeakPtrFactory<LockManager> weak_ptr_factory_{this};

DISALLOW_COPY_AND_ASSIGN(LockManager);
};

} // namespace content

#endif // CONTENT_BROWSER_LOCKS_LOCK_CONTEXT_H
#endif // CONTENT_BROWSER_LOCKS_LOCK_MANAGER_H

0 comments on commit 4da20a5

Please sign in to comment.