LibWeb: Prefix AK::Duration with AK Namespace

This commit is contained in:
Andrew Kaster 2024-07-16 23:45:44 -06:00 committed by Sam Atkins
commit b20a1d0fcd
Notes: sideshowbarker 2024-07-18 23:46:42 +09:00
16 changed files with 39 additions and 39 deletions

View file

@ -173,7 +173,7 @@ void on_max_age_attribute(ParsedCookie& parsed_cookie, StringView attribute_valu
parsed_cookie.expiry_time_from_max_age_attribute = UnixDateTime::earliest();
} else {
// Otherwise, let the expiry-time be the current date and time plus delta-seconds seconds.
parsed_cookie.expiry_time_from_max_age_attribute = UnixDateTime::now() + Duration::from_seconds(*delta_seconds);
parsed_cookie.expiry_time_from_max_age_attribute = UnixDateTime::now() + AK::Duration::from_seconds(*delta_seconds);
}
}
}

View file

@ -233,24 +233,24 @@ bool Response::is_stale() const
u64 Response::current_age() const
{
// The term "age_value" denotes the value of the Age header field (Section 5.1), in a form appropriate for arithmetic operation; or 0, if not available.
Optional<Duration> age;
Optional<AK::Duration> age;
if (auto const age_header = header_list()->get("Age"sv.bytes()); age_header.has_value()) {
if (auto converted_age = StringView { *age_header }.to_number<u64>(); converted_age.has_value())
age = Duration::from_seconds(converted_age.value());
age = AK::Duration::from_seconds(converted_age.value());
}
auto const age_value = age.value_or(Duration::from_seconds(0));
auto const age_value = age.value_or(AK::Duration::from_seconds(0));
// The term "date_value" denotes the value of the Date header field, in a form appropriate for arithmetic operations. See Section 6.6.1 of [HTTP] for the definition of the Date header field and for requirements regarding responses without it.
// FIXME: Do we have a parser for HTTP-date?
auto const date_value = UnixDateTime::now() - Duration::from_seconds(5);
auto const date_value = UnixDateTime::now() - AK::Duration::from_seconds(5);
// The term "now" means the current value of this implementation's clock (Section 5.6.7 of [HTTP]).
auto const now = UnixDateTime::now();
// The value of the clock at the time of the request that resulted in the stored response.
// FIXME: Let's get the correct time.
auto const request_time = UnixDateTime::now() - Duration::from_seconds(5);
auto const request_time = UnixDateTime::now() - AK::Duration::from_seconds(5);
// The value of the clock at the time the response was received.
auto const response_time = m_response_time;

View file

@ -70,7 +70,7 @@ void AudioTrack::pause(Badge<HTMLAudioElement>)
m_audio_plugin->pause_playback();
}
Duration AudioTrack::duration()
AK::Duration AudioTrack::duration()
{
return m_audio_plugin->duration();
}

View file

@ -25,7 +25,7 @@ public:
void play(Badge<HTMLAudioElement>);
void pause(Badge<HTMLAudioElement>);
Duration duration();
AK::Duration duration();
void seek(double, MediaSeekMode);
void update_volume();

View file

@ -399,7 +399,7 @@ void EventSource::process_field(StringView field, StringView value)
// If the field value consists of only ASCII digits, then interpret the field value as an integer in base ten,
// and set the event stream's reconnection time to that integer. Otherwise, ignore the field.
if (auto retry = value.to_number<i64>(); retry.has_value())
m_reconnection_time = Duration::from_seconds(*retry);
m_reconnection_time = AK::Duration::from_seconds(*retry);
}
// -> Otherwise
else {

View file

@ -82,7 +82,7 @@ private:
JS::GCPtr<Fetch::Infrastructure::Request> m_request;
// https://html.spec.whatwg.org/multipage/server-sent-events.html#concept-event-stream-reconnection-time
Duration m_reconnection_time { Duration::from_seconds(3) };
AK::Duration m_reconnection_time { AK::Duration::from_seconds(3) };
// https://html.spec.whatwg.org/multipage/server-sent-events.html#concept-event-stream-last-event-id
String m_last_event_id;

View file

@ -957,7 +957,7 @@ Vector<FlyString> HTMLFormElement::supported_property_names() const
Name,
Past,
} source;
Duration age;
AK::Duration age;
};
Vector<SourcedName> sourced_names;

View file

@ -132,7 +132,7 @@ void HTMLVideoElement::on_paused()
void HTMLVideoElement::on_seek(double position, MediaSeekMode seek_mode)
{
if (m_video_track)
m_video_track->seek(Duration::from_milliseconds(position * 1000.0), seek_mode);
m_video_track->seek(AK::Duration::from_milliseconds(position * 1000.0), seek_mode);
}
// https://html.spec.whatwg.org/multipage/media.html#attr-video-poster

View file

@ -103,17 +103,17 @@ void VideoTrack::stop_video(Badge<HTMLVideoElement>)
m_playback_manager->terminate_playback();
}
Duration VideoTrack::position() const
AK::Duration VideoTrack::position() const
{
return m_playback_manager->current_playback_time();
}
Duration VideoTrack::duration() const
AK::Duration VideoTrack::duration() const
{
return m_playback_manager->selected_video_track().video_data().duration;
}
void VideoTrack::seek(Duration position, MediaSeekMode seek_mode)
void VideoTrack::seek(AK::Duration position, MediaSeekMode seek_mode)
{
switch (seek_mode) {
case MediaSeekMode::Accurate:

View file

@ -27,9 +27,9 @@ public:
void pause_video(Badge<HTMLVideoElement>);
void stop_video(Badge<HTMLVideoElement>);
Duration position() const;
Duration duration() const;
void seek(Duration, MediaSeekMode);
AK::Duration position() const;
AK::Duration duration() const;
void seek(AK::Duration, MediaSeekMode);
u64 pixel_width() const;
u64 pixel_height() const;

View file

@ -41,7 +41,7 @@ public:
void set_body(ByteBuffer body) { m_body = move(body); }
void start_timer() { m_load_timer.start(); }
Duration load_time() const { return m_load_timer.elapsed_time(); }
AK::Duration load_time() const { return m_load_timer.elapsed_time(); }
JS::GCPtr<Page> page() const { return m_page.ptr(); }
void set_page(Page& page) { m_page = page; }

View file

@ -39,7 +39,7 @@ ErrorOr<FixedArray<Audio::Sample>> AudioCodecPlugin::read_samples_from_loader(Au
return buffer_or_error.release_value();
}
Duration AudioCodecPlugin::set_loader_position(Audio::Loader& loader, double position, Duration duration)
AK::Duration AudioCodecPlugin::set_loader_position(Audio::Loader& loader, double position, AK::Duration duration)
{
if (loader.total_samples() == 0)
return current_loader_position(loader);
@ -51,12 +51,12 @@ Duration AudioCodecPlugin::set_loader_position(Audio::Loader& loader, double pos
return current_loader_position(loader);
}
Duration AudioCodecPlugin::current_loader_position(Audio::Loader const& loader)
AK::Duration AudioCodecPlugin::current_loader_position(Audio::Loader const& loader)
{
auto samples_played = static_cast<double>(loader.loaded_samples());
auto sample_rate = static_cast<double>(loader.sample_rate());
return Duration::from_milliseconds(static_cast<i64>(samples_played / sample_rate * 1000.0));
return AK::Duration::from_milliseconds(static_cast<i64>(samples_played / sample_rate * 1000.0));
}
}

View file

@ -24,17 +24,17 @@ public:
virtual ~AudioCodecPlugin();
static ErrorOr<FixedArray<Audio::Sample>> read_samples_from_loader(Audio::Loader&, size_t samples_to_load);
static Duration set_loader_position(Audio::Loader&, double position, Duration duration);
static Duration current_loader_position(Audio::Loader const&);
static AK::Duration set_loader_position(Audio::Loader&, double position, AK::Duration duration);
static AK::Duration current_loader_position(Audio::Loader const&);
virtual void resume_playback() = 0;
virtual void pause_playback() = 0;
virtual void set_volume(double) = 0;
virtual void seek(double) = 0;
virtual Duration duration() = 0;
virtual AK::Duration duration() = 0;
Function<void(Duration)> on_playback_position_updated;
Function<void(AK::Duration)> on_playback_position_updated;
Function<void(String)> on_decoder_error;
protected:

View file

@ -17,12 +17,12 @@ namespace Web::Platform {
constexpr int update_interval = 50;
static Duration timestamp_from_samples(i64 samples, u32 sample_rate)
static AK::Duration timestamp_from_samples(i64 samples, u32 sample_rate)
{
return Duration::from_milliseconds(samples * 1000 / sample_rate);
return AK::Duration::from_milliseconds(samples * 1000 / sample_rate);
}
static Duration get_loader_timestamp(NonnullRefPtr<Audio::Loader> const& loader)
static AK::Duration get_loader_timestamp(NonnullRefPtr<Audio::Loader> const& loader)
{
return timestamp_from_samples(loader->loaded_samples(), loader->sample_rate());
}
@ -80,7 +80,7 @@ ErrorOr<NonnullOwnPtr<AudioCodecPluginAgnostic>> AudioCodecPluginAgnostic::creat
return plugin;
}
AudioCodecPluginAgnostic::AudioCodecPluginAgnostic(NonnullRefPtr<Audio::Loader> loader, Duration duration, NonnullRefPtr<Core::Timer> update_timer)
AudioCodecPluginAgnostic::AudioCodecPluginAgnostic(NonnullRefPtr<Audio::Loader> loader, AK::Duration duration, NonnullRefPtr<Core::Timer> update_timer)
: m_loader(move(loader))
, m_duration(duration)
, m_main_thread_event_loop(Core::EventLoop::current())
@ -95,7 +95,7 @@ void AudioCodecPluginAgnostic::resume_playback()
{
m_paused = false;
m_output->resume()
->when_resolved([this](Duration new_device_time) {
->when_resolved([this](AK::Duration new_device_time) {
m_main_thread_event_loop.deferred_invoke([this, new_device_time]() {
m_last_resume_in_device_time = new_device_time;
m_update_timer->start();
@ -164,7 +164,7 @@ void AudioCodecPluginAgnostic::seek(double position)
});
}
Duration AudioCodecPluginAgnostic::duration()
AK::Duration AudioCodecPluginAgnostic::duration()
{
return m_duration;
}

View file

@ -20,19 +20,19 @@ public:
virtual void set_volume(double) override;
virtual void seek(double) override;
virtual Duration duration() override;
virtual AK::Duration duration() override;
private:
explicit AudioCodecPluginAgnostic(NonnullRefPtr<Audio::Loader> loader, Duration, NonnullRefPtr<Core::Timer> update_timer);
explicit AudioCodecPluginAgnostic(NonnullRefPtr<Audio::Loader> loader, AK::Duration, NonnullRefPtr<Core::Timer> update_timer);
void update_timestamp();
NonnullRefPtr<Audio::Loader> m_loader;
RefPtr<Audio::PlaybackStream> m_output { nullptr };
Duration m_duration { Duration::zero() };
Duration m_last_resume_in_media_time { Duration::zero() };
Duration m_last_resume_in_device_time { Duration::zero() };
Duration m_last_good_device_time { Duration::zero() };
AK::Duration m_duration { AK::Duration::zero() };
AK::Duration m_last_resume_in_media_time { AK::Duration::zero() };
AK::Duration m_last_resume_in_device_time { AK::Duration::zero() };
AK::Duration m_last_good_device_time { AK::Duration::zero() };
Core::EventLoop& m_main_thread_event_loop;
NonnullRefPtr<Core::Timer> m_update_timer;
bool m_paused { true };

View file

@ -332,7 +332,7 @@ ExecuteScriptResultSerialized execute_async_script(Web::Page& page, ByteString c
auto start = MonotonicTime::now();
auto has_timed_out = [&] {
return timeout.has_value() && (MonotonicTime::now() - start) > Duration::from_seconds(static_cast<i64>(*timeout));
return timeout.has_value() && (MonotonicTime::now() - start) > AK::Duration::from_seconds(static_cast<i64>(*timeout));
};
// AD-HOC: An execution context is required for Promise creation hooks.