Commit 45f81df5 authored by Balazs Engedy's avatar Balazs Engedy Committed by Commit Bot

Revert "Read attachments from introduction"

This reverts commit 5528fce5.

Reason for revert: Compile failure on:

https://ci.chromium.org/p/chromium/builders/ci/win-archive-rel/16199?

Original change's description:
> Read attachments from introduction
> 
> Reads text and file attachments from introduction frame and appends
> them to the share target.
> 
> Bug: 1085068
> Change-Id: I0198a9edcfa5d8c7691514072c50577ff3d72428
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2320599
> Commit-Queue: Himanshu Jaju <himanshujaju@chromium.org>
> Reviewed-by: Alex Chau <alexchau@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#793136}

TBR=alexchau@chromium.org,himanshujaju@chromium.org

Change-Id: I4fbdac65b9e62653068572eaade6b920d949b9df
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1085068
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2329591Reviewed-by: default avatarBalazs Engedy <engedy@chromium.org>
Commit-Queue: Balazs Engedy <engedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#793139}
parent 52f240ea
...@@ -3357,8 +3357,6 @@ static_library("browser") { ...@@ -3357,8 +3357,6 @@ static_library("browser") {
"nearby_sharing/text_attachment.h", "nearby_sharing/text_attachment.h",
"nearby_sharing/transfer_metadata.cc", "nearby_sharing/transfer_metadata.cc",
"nearby_sharing/transfer_metadata.h", "nearby_sharing/transfer_metadata.h",
"nearby_sharing/transfer_metadata_builder.cc",
"nearby_sharing/transfer_metadata_builder.h",
"nearby_sharing/transfer_update_callback.h", "nearby_sharing/transfer_update_callback.h",
"nearby_sharing/webrtc_signaling_messenger.cc", "nearby_sharing/webrtc_signaling_messenger.cc",
"nearby_sharing/webrtc_signaling_messenger.h", "nearby_sharing/webrtc_signaling_messenger.h",
......
// Copyright 2020 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 "chrome/browser/nearby_sharing/fake_nearby_connection.h"
FakeNearbyConnection::FakeNearbyConnection() = default;
FakeNearbyConnection::~FakeNearbyConnection() = default;
void FakeNearbyConnection::Read(ReadCallback callback) {
callback_ = std::move(callback);
MaybeRunCallback();
}
void FakeNearbyConnection::Write(std::vector<uint8_t> bytes,
WriteCallback callback) {
NOTIMPLEMENTED();
}
void FakeNearbyConnection::Close() {
closed_ = true;
if (callback_)
std::move(callback_).Run(base::nullopt);
}
bool FakeNearbyConnection::IsClosed() const {
return closed_;
}
void FakeNearbyConnection::RegisterForDisconnection(
base::OnceClosure callback) {
NOTIMPLEMENTED();
}
void FakeNearbyConnection::AppendReadableData(std::vector<uint8_t> bytes) {
data_.push(std::move(bytes));
MaybeRunCallback();
}
void FakeNearbyConnection::MaybeRunCallback() {
if (!callback_ || data_.empty())
return;
auto item = std::move(data_.front());
data_.pop();
std::move(callback_).Run(std::move(item));
}
// Copyright 2020 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 CHROME_BROWSER_NEARBY_SHARING_FAKE_NEARBY_CONNECTION_H_
#define CHROME_BROWSER_NEARBY_SHARING_FAKE_NEARBY_CONNECTION_H_
#include <queue>
#include <vector>
#include "chrome/browser/nearby_sharing/nearby_connection.h"
class FakeNearbyConnection : public NearbyConnection {
public:
FakeNearbyConnection();
~FakeNearbyConnection() override;
void Read(ReadCallback callback) override;
void Write(std::vector<uint8_t> bytes, WriteCallback callback) override;
void Close() override;
bool IsClosed() const override;
void RegisterForDisconnection(base::OnceClosure callback) override;
void AppendReadableData(std::vector<uint8_t> bytes);
private:
void MaybeRunCallback();
bool closed_ = false;
ReadCallback callback_;
std::queue<std::vector<uint8_t>> data_;
};
#endif // CHROME_BROWSER_NEARBY_SHARING_FAKE_NEARBY_CONNECTION_H_
...@@ -10,13 +10,23 @@ ...@@ -10,13 +10,23 @@
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/optional.h" #include "base/optional.h"
#include "chrome/browser/nearby_sharing/attachment.h" #include "chrome/browser/nearby_sharing/attachment.h"
#include "chrome/services/sharing/public/mojom/nearby_decoder_types.mojom.h"
// A single attachment to be sent by / received from a |ShareTarget|, can be // A single attachment to be sent by / received from a |ShareTarget|, can be
// either a file or text. // either a file or text.
class FileAttachment : public Attachment { class FileAttachment : public Attachment {
public: public:
using Type = sharing::mojom::FileMetadata::Type; // Different types are used to offer richer experiences on Receiver side,
// mainly for: 1. displaying notification of attachment types, 2. opening
// different types with different apps. Remember to update Notifications,
// ShareTarget, etc once more types are introduced here.
enum class Type {
kUnknown,
kImage,
kVideo,
kApp,
kAudio,
kMaxValue = kAudio
};
FileAttachment(std::string file_name, FileAttachment(std::string file_name,
Type type, Type type,
......
...@@ -4,14 +4,15 @@ ...@@ -4,14 +4,15 @@
#include "chrome/browser/nearby_sharing/incoming_frames_reader.h" #include "chrome/browser/nearby_sharing/incoming_frames_reader.h"
#include <queue>
#include <vector> #include <vector>
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/test/bind_test_util.h" #include "base/test/bind_test_util.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chrome/browser/nearby_sharing/fake_nearby_connection.h"
#include "chrome/browser/nearby_sharing/mock_nearby_process_manager.h" #include "chrome/browser/nearby_sharing/mock_nearby_process_manager.h"
#include "chrome/browser/nearby_sharing/mock_nearby_sharing_decoder.h" #include "chrome/browser/nearby_sharing/mock_nearby_sharing_decoder.h"
#include "chrome/browser/nearby_sharing/nearby_connection.h"
#include "chrome/services/sharing/public/proto/wire_format.pb.h" #include "chrome/services/sharing/public/proto/wire_format.pb.h"
#include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile.h"
#include "content/public/test/browser_task_environment.h" #include "content/public/test/browser_task_environment.h"
...@@ -55,6 +56,51 @@ void ExpectIntroductionFrame( ...@@ -55,6 +56,51 @@ void ExpectIntroductionFrame(
} // namespace } // namespace
class FakeNearbyConnection : public NearbyConnection {
public:
FakeNearbyConnection() = default;
~FakeNearbyConnection() override = default;
void Read(ReadCallback callback) override {
callback_ = std::move(callback);
MaybeRunCallback();
}
void Write(std::vector<uint8_t> bytes, WriteCallback callback) override {
NOTIMPLEMENTED();
}
void Close() override {
closed_ = true;
if (callback_)
std::move(callback_).Run(base::nullopt);
}
bool IsClosed() const override { return closed_; }
void RegisterForDisconnection(base::OnceClosure callback) override {
NOTIMPLEMENTED();
}
void AppendReadableData(std::vector<uint8_t> bytes) {
data_.push(std::move(bytes));
MaybeRunCallback();
}
private:
void MaybeRunCallback() {
if (!callback_ || data_.empty())
return;
auto item = std::move(data_.front());
data_.pop();
std::move(callback_).Run(std::move(item));
}
bool closed_ = false;
ReadCallback callback_;
std::queue<std::vector<uint8_t>> data_;
};
class IncomingFramesReaderTest : public testing::Test { class IncomingFramesReaderTest : public testing::Test {
public: public:
IncomingFramesReaderTest() IncomingFramesReaderTest()
......
...@@ -59,16 +59,15 @@ KeyedService* NearbySharingServiceFactory::BuildServiceInstanceFor( ...@@ -59,16 +59,15 @@ KeyedService* NearbySharingServiceFactory::BuildServiceInstanceFor(
return nullptr; return nullptr;
} }
NearbyProcessManager& process_manager = NearbyProcessManager::GetInstance();
Profile* profile = Profile::FromBrowserContext(context); Profile* profile = Profile::FromBrowserContext(context);
PrefService* pref_service = profile->GetPrefs(); PrefService* pref_service = profile->GetPrefs();
auto nearby_connections_manager = auto nearby_connections_manager =
std::make_unique<NearbyConnectionsManagerImpl>(&process_manager, profile); std::make_unique<NearbyConnectionsManagerImpl>(
&NearbyProcessManager::GetInstance(), profile);
NS_LOG(VERBOSE) << __func__ << ": creating NearbySharingService."; NS_LOG(VERBOSE) << __func__ << ": creating NearbySharingService.";
return new NearbySharingServiceImpl(pref_service, profile, return new NearbySharingServiceImpl(pref_service, profile,
std::move(nearby_connections_manager), std::move(nearby_connections_manager));
&process_manager);
} }
content::BrowserContext* NearbySharingServiceFactory::GetBrowserContextToUse( content::BrowserContext* NearbySharingServiceFactory::GetBrowserContextToUse(
......
...@@ -27,10 +27,8 @@ ...@@ -27,10 +27,8 @@
#include "chrome/browser/nearby_sharing/nearby_sharing_service.h" #include "chrome/browser/nearby_sharing/nearby_sharing_service.h"
#include "chrome/browser/nearby_sharing/outgoing_share_target_info.h" #include "chrome/browser/nearby_sharing/outgoing_share_target_info.h"
#include "chrome/browser/nearby_sharing/share_target.h" #include "chrome/browser/nearby_sharing/share_target.h"
#include "chrome/browser/nearby_sharing/transfer_metadata.h"
#include "chrome/browser/ui/webui/nearby_share/public/mojom/nearby_share_settings.mojom.h" #include "chrome/browser/ui/webui/nearby_share/public/mojom/nearby_share_settings.mojom.h"
#include "chrome/services/sharing/public/mojom/nearby_decoder_types.mojom.h" #include "chrome/services/sharing/public/mojom/nearby_decoder_types.mojom.h"
#include "chrome/services/sharing/public/proto/wire_format.pb.h"
#include "components/keyed_service/core/keyed_service.h" #include "components/keyed_service/core/keyed_service.h"
#include "components/prefs/pref_change_registrar.h" #include "components/prefs/pref_change_registrar.h"
...@@ -55,8 +53,7 @@ class NearbySharingServiceImpl ...@@ -55,8 +53,7 @@ class NearbySharingServiceImpl
explicit NearbySharingServiceImpl( explicit NearbySharingServiceImpl(
PrefService* prefs, PrefService* prefs,
Profile* profile, Profile* profile,
std::unique_ptr<NearbyConnectionsManager> nearby_connections_manager, std::unique_ptr<NearbyConnectionsManager> nearby_connections_manager);
NearbyProcessManager* process_manager);
~NearbySharingServiceImpl() override; ~NearbySharingServiceImpl() override;
// NearbySharingService: // NearbySharingService:
...@@ -130,33 +127,25 @@ class NearbySharingServiceImpl ...@@ -130,33 +127,25 @@ class NearbySharingServiceImpl
void InvalidateReceiveSurfaceState(); void InvalidateReceiveSurfaceState();
void InvalidateAdvertisingState(); void InvalidateAdvertisingState();
void StopAdvertising(); void StopAdvertising();
void WriteResponse(
NearbyConnection& connection,
sharing::nearby::ConnectionResponseFrame::Status reponse_status);
void Fail(const ShareTarget& share_target, TransferMetadata::Status status);
void OnIncomingTransferUpdate(const ShareTarget& share_target, void OnIncomingTransferUpdate(const ShareTarget& share_target,
TransferMetadata metadata); TransferMetadata metadata);
void ReceiveIntroduction(ShareTarget share_target, void ReceiveIntroduction(const ShareTarget& share_target,
base::Optional<std::string> token); const std::string& token);
void OnReceivedIntroduction( void OnReceivedIntroduction(
ShareTarget share_target, NearbyConnection* connection,
base::Optional<std::string> token,
std::unique_ptr<IncomingFramesReader> frames_reader, std::unique_ptr<IncomingFramesReader> frames_reader,
base::Optional<sharing::mojom::V1FramePtr> frame); base::Optional<sharing::mojom::V1FramePtr> frame);
void UnregisterShareTarget(const ShareTarget& share_target);
IncomingShareTargetInfo& GetIncomingShareTargetInfo( IncomingShareTargetInfo& GetIncomingShareTargetInfo(
const ShareTarget& share_target); const ShareTarget& share_target);
NearbyConnection* GetIncomingConnection(const ShareTarget& share_target); NearbyConnection* GetIncomingConnection(const ShareTarget& share_target);
OutgoingShareTargetInfo& GetOutgoingShareTargetInfo( OutgoingShareTargetInfo& GetOutgoingShareTargetInfo(ShareTarget share_target);
const ShareTarget& share_target);
void ClearOutgoingShareTargetInfoMap(); void ClearOutgoingShareTargetInfoMap();
PrefService* prefs_; PrefService* prefs_;
Profile* profile_; Profile* profile_;
NearbyShareSettings settings_; NearbyShareSettings settings_;
std::unique_ptr<NearbyConnectionsManager> nearby_connections_manager_; std::unique_ptr<NearbyConnectionsManager> nearby_connections_manager_;
NearbyProcessManager* process_manager_;
ScopedObserver<NearbyProcessManager, NearbyProcessManager::Observer> ScopedObserver<NearbyProcessManager, NearbyProcessManager::Observer>
nearby_process_observer_{this}; nearby_process_observer_{this};
scoped_refptr<device::BluetoothAdapter> bluetooth_adapter_; scoped_refptr<device::BluetoothAdapter> bluetooth_adapter_;
......
...@@ -33,10 +33,6 @@ struct ShareTarget { ...@@ -33,10 +33,6 @@ struct ShareTarget {
ShareTarget& operator=(ShareTarget&&); ShareTarget& operator=(ShareTarget&&);
~ShareTarget(); ~ShareTarget();
bool has_attachments() const {
return !text_attachments.empty() || !file_attachments.empty();
}
base::UnguessableToken id = base::UnguessableToken::Create(); base::UnguessableToken id = base::UnguessableToken::Create();
std::string device_name; std::string device_name;
// Uri that points to an image of the ShareTarget, if one exists. // Uri that points to an image of the ShareTarget, if one exists.
......
...@@ -9,12 +9,21 @@ ...@@ -9,12 +9,21 @@
#include "base/optional.h" #include "base/optional.h"
#include "chrome/browser/nearby_sharing/attachment.h" #include "chrome/browser/nearby_sharing/attachment.h"
#include "chrome/services/sharing/public/mojom/nearby_decoder_types.mojom.h"
// Represents a text attachment. // Represents a text attachment.
class TextAttachment : public Attachment { class TextAttachment : public Attachment {
public: public:
using Type = sharing::mojom::TextMetadata::Type; // Different types are used to offer richer experiences on Receiver side,
// mainly for: 1. displaying notification of attachment types, 2. opening
// different types with different apps. Remember to update Notifications,
// ShareTarget, etc once more types are introduced here.
enum class Type {
kText,
kUrl,
kAddress,
kPhoneNumber,
kMaxValue = kPhoneNumber
};
TextAttachment(std::string text_body, Type type, int64_t size); TextAttachment(std::string text_body, Type type, int64_t size);
~TextAttachment() override; ~TextAttachment() override;
......
...@@ -3665,8 +3665,6 @@ test("unit_tests") { ...@@ -3665,8 +3665,6 @@ test("unit_tests") {
"../browser/media/feeds/media_feeds_fetcher_unittest.cc", "../browser/media/feeds/media_feeds_fetcher_unittest.cc",
"../browser/media/feeds/media_feeds_service_unittest.cc", "../browser/media/feeds/media_feeds_service_unittest.cc",
"../browser/media/kaleidoscope/kaleidoscope_switches_unittest.cc", "../browser/media/kaleidoscope/kaleidoscope_switches_unittest.cc",
"../browser/nearby_sharing/fake_nearby_connection.cc",
"../browser/nearby_sharing/fake_nearby_connection.h",
"../browser/nearby_sharing/fake_nearby_connections_manager.cc", "../browser/nearby_sharing/fake_nearby_connections_manager.cc",
"../browser/nearby_sharing/fake_nearby_connections_manager.h", "../browser/nearby_sharing/fake_nearby_connections_manager.h",
"../browser/nearby_sharing/fast_initiation_manager_unittest.cc", "../browser/nearby_sharing/fast_initiation_manager_unittest.cc",
...@@ -3691,6 +3689,8 @@ test("unit_tests") { ...@@ -3691,6 +3689,8 @@ test("unit_tests") {
"../browser/nearby_sharing/nearby_process_manager_unittest.cc", "../browser/nearby_sharing/nearby_process_manager_unittest.cc",
"../browser/nearby_sharing/nearby_share_settings_unittest.cc", "../browser/nearby_sharing/nearby_share_settings_unittest.cc",
"../browser/nearby_sharing/nearby_sharing_service_impl_unittest.cc", "../browser/nearby_sharing/nearby_sharing_service_impl_unittest.cc",
"../browser/nearby_sharing/transfer_metadata_builder.cc",
"../browser/nearby_sharing/transfer_metadata_builder.h",
"../browser/nearby_sharing/webrtc_signaling_messenger_unittest.cc", "../browser/nearby_sharing/webrtc_signaling_messenger_unittest.cc",
"../browser/password_manager/generated_password_leak_detection_pref_unittest.cc", "../browser/password_manager/generated_password_leak_detection_pref_unittest.cc",
"../browser/performance_manager/test_support/page_discarding_utils.cc", "../browser/performance_manager/test_support/page_discarding_utils.cc",
......
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