<commit_before>// Copyright (c) 2013 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/service/cloud_print/printer_job_queue_handler.h"

#include <math.h>

#include <algorithm>

#include "base/values.h"

namespace cloud_print {

class TimeProviderImpl : public PrinterJobQueueHandler::TimeProvider {
 public:
    virtual base::Time GetNow() OVERRIDE;
};

base::Time TimeProviderImpl::GetNow() {
  return base::Time::Now();
}

JobDetails::JobDetails() {}

JobDetails::~JobDetails() {}

void JobDetails::Clear() {
  job_id_.clear();
  job_title_.clear();
  print_ticket_.clear();
  print_data_mime_type_.clear();
  print_data_file_path_ = base::FilePath();
  print_data_url_.clear();
  print_ticket_url_.clear();
  tags_.clear();
  time_remaining_ = base::TimeDelta();
}

// static
bool JobDetails::ordering(const JobDetails& first, const JobDetails& second) {
  return first.time_remaining_ <= second.time_remaining_;
}

PrinterJobQueueHandler::PrinterJobQueueHandler(TimeProvider* time_provider)
    : time_provider_(time_provider) {}

PrinterJobQueueHandler::PrinterJobQueueHandler()
    : time_provider_(new TimeProviderImpl()) {}

PrinterJobQueueHandler::~PrinterJobQueueHandler() {}

void PrinterJobQueueHandler::ConstructJobDetailsFromJson(
    const DictionaryValue* job_data,
    JobDetails* job_details) {
  job_details->Clear();

  job_data->GetString(kIdValue, &job_details->job_id_);
  job_data->GetString(kTitleValue, &job_details->job_title_);

  job_data->GetString(kTicketUrlValue, &job_details->print_ticket_url_);
  job_data->GetString(kFileUrlValue, &job_details->print_data_url_);

  // Get tags for print job.
  const ListValue* tags = NULL;
  if (job_data->GetList(kTagsValue, &tags)) {
    for (size_t i = 0; i < tags->GetSize(); i++) {
      std::string value;
      if (tags->GetString(i, &value))
        job_details->tags_.push_back(value);
    }
  }<commit_msg>std::sort requires strict comparison function.<commit_after>// Copyright (c) 2013 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/service/cloud_print/printer_job_queue_handler.h"

#include <math.h>

#include <algorithm>

#include "base/values.h"

namespace cloud_print {

class TimeProviderImpl : public PrinterJobQueueHandler::TimeProvider {
 public:
    virtual base::Time GetNow() OVERRIDE;
};

base::Time TimeProviderImpl::GetNow() {
  return base::Time::Now();
}

JobDetails::JobDetails() {}

JobDetails::~JobDetails() {}

void JobDetails::Clear() {
  job_id_.clear();
  job_title_.clear();
  print_ticket_.clear();
  print_data_mime_type_.clear();
  print_data_file_path_ = base::FilePath();
  print_data_url_.clear();
  print_ticket_url_.clear();
  tags_.clear();
  time_remaining_ = base::TimeDelta();
}

// static
bool JobDetails::ordering(const JobDetails& first, const JobDetails& second) {
  return first.time_remaining_ < second.time_remaining_;
}

PrinterJobQueueHandler::PrinterJobQueueHandler(TimeProvider* time_provider)
    : time_provider_(time_provider) {}

PrinterJobQueueHandler::PrinterJobQueueHandler()
    : time_provider_(new TimeProviderImpl()) {}

PrinterJobQueueHandler::~PrinterJobQueueHandler() {}

void PrinterJobQueueHandler::ConstructJobDetailsFromJson(
    const DictionaryValue* job_data,
    JobDetails* job_details) {
  job_details->Clear();

  job_data->GetString(kIdValue, &job_details->job_id_);
  job_data->GetString(kTitleValue, &job_details->job_title_);

  job_data->GetString(kTicketUrlValue, &job_details->print_ticket_url_);
  job_data->GetString(kFileUrlValue, &job_details->print_data_url_);

  // Get tags for print job.
  const ListValue* tags = NULL;
  if (job_data->GetList(kTagsValue, &tags)) {
    for (size_t i = 0; i < tags->GetSize(); i++) {
      std::string value;
      if (tags->GetString(i, &value))
        job_details->tags_.push_back(value);
    }
  }
{'fraction_non_alphanumeric': 0.12976721149083706, 'fraction_numerical': 0.0024764735017335313, 'mean_word_length': 5.472756410256411, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5827632', 'n_tokens_mistral': 1311, 'n_tokens_neox': 1293, 'n_words': 256}