Commit 4da20a53 authored by Victor Costan's avatar Victor Costan Committed by Commit Bot

WebLocks: Minor improvements in browser-side implementation.

Change-Id: I366028613a73736af28799440cf87bfac5af3aae
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2093551
Commit-Queue: Joshua Bell <jsbell@chromium.org>
Reviewed-by: default avatarJoshua Bell <jsbell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748318}
parent 6bc859ad
...@@ -141,7 +141,7 @@ class LockManager::Lock { ...@@ -141,7 +141,7 @@ class LockManager::Lock {
mojo::SelfOwnedAssociatedReceiverRef<blink::mojom::LockHandle> handle_; mojo::SelfOwnedAssociatedReceiverRef<blink::mojom::LockHandle> handle_;
}; };
LockManager::LockManager() {} LockManager::LockManager() = default;
LockManager::~LockManager() = default; LockManager::~LockManager() = default;
...@@ -149,7 +149,8 @@ LockManager::~LockManager() = default; ...@@ -149,7 +149,8 @@ LockManager::~LockManager() = default;
// for a given origin. // for a given origin.
class LockManager::OriginState { class LockManager::OriginState {
public: public:
OriginState(LockManager* lock_manager) : lock_manager_(lock_manager) {} explicit OriginState(LockManager* lock_manager)
: lock_manager_(lock_manager) {}
~OriginState() = default; ~OriginState() = default;
// Helper function for breaking the lock at the front of a given request // Helper function for breaking the lock at the front of a given request
...@@ -263,7 +264,7 @@ class LockManager::OriginState { ...@@ -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::pair<std::vector<blink::mojom::LockInfoPtr>,
std::vector<blink::mojom::LockInfoPtr>> std::vector<blink::mojom::LockInfoPtr>>
...@@ -300,7 +301,7 @@ class LockManager::OriginState { ...@@ -300,7 +301,7 @@ class LockManager::OriginState {
// Any OriginState is owned by a LockManager so a raw pointer back to an // Any OriginState is owned by a LockManager so a raw pointer back to an
// OriginState's owning LockManager is safe. // OriginState's owning LockManager is safe.
LockManager* lock_manager_; LockManager* const lock_manager_;
}; };
void LockManager::BindReceiver( void LockManager::BindReceiver(
......
...@@ -2,13 +2,16 @@ ...@@ -2,13 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CONTENT_BROWSER_LOCKS_LOCK_CONTEXT_H_ #ifndef CONTENT_BROWSER_LOCKS_LOCK_MANAGER_H_
#define CONTENT_BROWSER_LOCKS_LOCK_CONTEXT_H_ #define CONTENT_BROWSER_LOCKS_LOCK_MANAGER_H_
#include <cstdint>
#include <map>
#include <memory> #include <memory>
#include <string> #include <string>
#include "base/callback.h" #include "base/callback.h"
#include "base/memory/weak_ptr.h"
#include "base/sequence_checker.h" #include "base/sequence_checker.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
#include "mojo/public/cpp/bindings/receiver_set.h" #include "mojo/public/cpp/bindings/receiver_set.h"
...@@ -25,6 +28,9 @@ class LockManager : public blink::mojom::LockManager { ...@@ -25,6 +28,9 @@ class LockManager : public blink::mojom::LockManager {
LockManager(); LockManager();
~LockManager() override; ~LockManager() override;
LockManager(const LockManager&) = delete;
LockManager& operator=(const LockManager&) = delete;
// Binds |receiver| to this LockManager. |receiver| belongs to a frame or // 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, // 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. // |render_frame_id| identifies it, otherwise it is MSG_ROUTING_NONE.
...@@ -73,10 +79,8 @@ class LockManager : public blink::mojom::LockManager { ...@@ -73,10 +79,8 @@ class LockManager : public blink::mojom::LockManager {
SEQUENCE_CHECKER(sequence_checker_); SEQUENCE_CHECKER(sequence_checker_);
base::WeakPtrFactory<LockManager> weak_ptr_factory_{this}; base::WeakPtrFactory<LockManager> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(LockManager);
}; };
} // namespace content } // namespace content
#endif // CONTENT_BROWSER_LOCKS_LOCK_CONTEXT_H #endif // CONTENT_BROWSER_LOCKS_LOCK_MANAGER_H
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment