Upstream version 7.36.152.0 41/22941/1
authorEurogiciel-BOT <eurogiciel.tizen@gmail.com>
Fri, 13 Jun 2014 07:48:19 +0000 (07:48 +0000)
committerEurogiciel-BOT <eurogiciel.tizen@gmail.com>
Fri, 13 Jun 2014 07:48:19 +0000 (07:48 +0000)
Upstream commit-id 1f62333dcd3762aa808b231c3e528f4b68e7fed5

Change-Id: I4f5251f25c8955a594709a89c4244faea10d9022
Signed-off-by: Eurogiciel-BOT <eurogiciel.tizen@gmail.com>
37 files changed:
packaging/crosswalk.spec
src/content/browser/renderer_host/render_process_host_impl.cc
src/content/browser/renderer_host/render_process_host_impl.h
src/content/public/browser/render_process_host.h
src/content/public/test/mock_render_process_host.cc
src/content/public/test/mock_render_process_host.h
src/v8/include/v8-profiler.h
src/v8/src/api.cc
src/v8/src/cpu-profiler.cc
src/v8/src/full-codegen.cc
src/v8/src/log.h
src/v8/src/profile-generator-inl.h
src/v8/src/profile-generator.cc
src/v8/src/profile-generator.h
src/v8/test/cctest/test-cpu-profiler.cc
src/xwalk/DEPS.xwalk
src/xwalk/VERSION
src/xwalk/app/tools/android/app_info.py [new file with mode: 0644]
src/xwalk/app/tools/android/customize.py
src/xwalk/app/tools/android/make_apk.py
src/xwalk/app/tools/android/make_apk_test.py
src/xwalk/application/browser/application.h
src/xwalk/application/browser/application_storage_impl.cc
src/xwalk/application/browser/application_storage_impl.h
src/xwalk/application/browser/application_storage_impl_unittest.cc
src/xwalk/application/browser/application_tizen.cc
src/xwalk/application/browser/application_tizen.h
src/xwalk/application/common/application_data.cc
src/xwalk/application/common/application_data.h
src/xwalk/application/common/application_storage_constants.cc
src/xwalk/application/common/application_storage_constants.h
src/xwalk/application/tools/tizen/xwalk_package_helper.cc
src/xwalk/application/xwalk_application.gypi
src/xwalk/build/android/generate_app_packaging_tool.py
src/xwalk/packaging/crosswalk.spec
src/xwalk/runtime/browser/ui/native_app_window_tizen.cc
src/xwalk/runtime/browser/ui/native_app_window_tizen.h

index 4f8ec3c..be4777e 100644 (file)
@@ -12,7 +12,7 @@
 %endif
 
 Name:           crosswalk
-Version:        7.36.151.0
+Version:        7.36.152.0
 Release:        0
 Summary:        Crosswalk is an app runtime based on Chromium
 License:        (BSD-3-Clause and LGPL-2.1+)
index c01dc5c..777ffc1 100644 (file)
@@ -853,6 +853,11 @@ void RenderProcessHostImpl::NotifyTimezoneChange() {
   Send(new ViewMsg_TimezoneChange());
 }
 
+ScreenOrientationDispatcherHost* RenderProcessHostImpl
+    ::GetScreenOrientationDispatcherHost() {
+  return screen_orientation_dispatcher_host_;
+}
+
 void RenderProcessHostImpl::AddRoute(
     int32 routing_id,
     IPC::Listener* listener) {
index 358109f..2ec08ab 100644 (file)
@@ -133,6 +133,9 @@ class CONTENT_EXPORT RenderProcessHostImpl
       OVERRIDE;
   virtual void NotifyTimezoneChange() OVERRIDE;
 
+  virtual ScreenOrientationDispatcherHost* GetScreenOrientationDispatcherHost()
+      OVERRIDE;
+
   // IPC::Sender via RenderProcessHost.
   virtual bool Send(IPC::Message* msg) OVERRIDE;
 
index 66a96ec..f2cba79 100644 (file)
@@ -27,6 +27,7 @@ class BrowserContext;
 class BrowserMessageFilter;
 class RenderProcessHostObserver;
 class RenderWidgetHost;
+class ScreenOrientationDispatcherHost;
 class StoragePartition;
 struct GlobalRequestID;
 
@@ -215,6 +216,10 @@ class CONTENT_EXPORT RenderProcessHost : public IPC::Sender,
   // have changed.
   virtual void NotifyTimezoneChange() = 0;
 
+  // Returns message filter and dispatcher for screen orientation.
+  virtual ScreenOrientationDispatcherHost* GetScreenOrientationDispatcherHost()
+      = 0;
+
   // Static management functions -----------------------------------------------
 
   // Flag to run the renderer in process.  This is primarily
index 50c19ee..8793585 100644 (file)
@@ -227,6 +227,11 @@ void MockRenderProcessHost::FilterURL(bool empty_allowed, GURL* url) {
   RenderProcessHostImpl::FilterURL(this, empty_allowed, url);
 }
 
+ScreenOrientationDispatcherHost* MockRenderProcessHost
+    ::GetScreenOrientationDispatcherHost() {
+  return NULL;
+}
+
 #if defined(ENABLE_WEBRTC)
 void MockRenderProcessHost::EnableAecDump(const base::FilePath& file) {
 }
index 4b99782..b01dc4a 100644 (file)
@@ -82,6 +82,9 @@ class MockRenderProcessHost : public RenderProcessHost {
       OVERRIDE;
   virtual void NotifyTimezoneChange() OVERRIDE;
 
+  virtual ScreenOrientationDispatcherHost* GetScreenOrientationDispatcherHost()
+      OVERRIDE;
+
   // IPC::Sender via RenderProcessHost.
   virtual bool Send(IPC::Message* msg) OVERRIDE;
 
index 19d143e..5616044 100644 (file)
@@ -17,6 +17,14 @@ struct HeapStatsUpdate;
 
 typedef uint32_t SnapshotObjectId;
 
+typedef struct {
+  /** The 1-based number of the source line where the function originates. */
+  unsigned int line;
+
+  /** The count of samples associated with the source line. */
+  unsigned int ticks;
+} LineTick;
+
 /**
  * CpuProfileNode represents a node in a call graph.
  */
@@ -43,6 +51,17 @@ class V8_EXPORT CpuProfileNode {
    */
   int GetColumnNumber() const;
 
+  /**
+   * Returns the number of the function's source lines that collect the samples.
+   */
+  unsigned int GetHitLineCount() const;
+
+  /** Returns the set of source lines that collect the samples.
+   *  The caller allocates buffer and responsible for releasing it.
+   *  True if all available entries are copied, otherwise false.
+   */
+  bool GetLineTicks(LineTick* entries, unsigned int number) const;
+
   /** Returns bailout reason for the function
     * if the optimization was disabled for it.
     */
index 41b5a45..3c03b5b 100644 (file)
@@ -6996,6 +6996,19 @@ int CpuProfileNode::GetColumnNumber() const {
 }
 
 
+unsigned int CpuProfileNode::GetHitLineCount() const {
+  const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
+  return node->GetHitLineCount();
+}
+
+
+bool CpuProfileNode::GetLineTicks(LineTick* entries,
+                                  unsigned int number) const {
+  const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
+  return node->GetLineTicks(entries, number);
+}
+
+
 const char* CpuProfileNode::GetBailoutReason() const {
   const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
   return node->entry()->bailout_reason();
index eecf4dc..23abdcd 100644 (file)
@@ -257,17 +257,34 @@ void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
   CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
   CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
   rec->start = code->address();
+  // Get line info from the relocation information.
+  ASSERT(Script::cast(shared->script()));
+  JITLineInfoTable line_table;
+  if (line > 0) {
+    for (RelocIterator it(code); !it.done(); it.next()) {
+      RelocInfo::Mode mode = it.rinfo()->rmode();
+      if (RelocInfo::IsPosition(mode)) {
+        int pc_offset = static_cast<int>(it.rinfo()->pc() - code->address());
+        int position = static_cast<int>(it.rinfo()->data());
+        int lineno =
+          Script::cast(shared->script())->GetLineNumber(position) + 1;
+        if (position >= 0 && lineno > 0) {
+          line_table.SetPosition(pc_offset, lineno);
+        }
+      }
+    }
+  }
   rec->entry = profiles_->NewCodeEntry(
       tag,
       profiles_->GetFunctionName(shared->DebugName()),
       CodeEntry::kEmptyNamePrefix,
       profiles_->GetName(source),
       line,
-      column);
+      column,
+      line_table.entries()->length() ? &line_table : NULL);
   if (info) {
     rec->entry->set_no_frame_ranges(info->ReleaseNoFrameRanges());
   }
-  ASSERT(Script::cast(shared->script()));
   Script* script = Script::cast(shared->script());
   rec->entry->set_script_id(script->id()->value());
   rec->size = code->ExecutableSize();
index 2846d2b..429fc16 100644 (file)
@@ -860,6 +860,7 @@ void FullCodeGenerator::SetStatementPosition(int pos) {
 void FullCodeGenerator::SetSourcePosition(int pos) {
   if (pos != RelocInfo::kNoPosition) {
     masm_->positions_recorder()->RecordPosition(pos);
+    masm_->positions_recorder()->WriteRecordedPositions();
   }
 }
 
index cd0669f..7b2a8e0 100644 (file)
@@ -142,6 +142,76 @@ class LowLevelLogger;
 class PerfJitLogger;
 class Sampler;
 
+// Mapping from the offset within generated code to source line number.
+class JITLineInfoTable : public Malloced {
+ public:
+  JITLineInfoTable() : pc_offset_infos_(20) {}
+
+  void SetPosition(unsigned int pc_offset, unsigned int src_line) {
+    AddPcOffsetInfo(PcOffsetInfo(pc_offset, src_line));
+  }
+
+  int GetSourceLineNumber(unsigned int pc_offset) const {
+    int length = pc_offset_infos_.length();
+    if (0 == length) return 0;
+
+    int low = 0;
+    int high = length - 1;
+
+    if (pc_offset > pc_offset_infos_[high].pc_offset_) {
+      return 0;  // out of range
+    }
+
+    while (low < high) {
+      int mid = (low + high) / 2;
+      const JITLineInfoTable::PcOffsetInfo& elem = pc_offset_infos_[mid];
+      if (elem.pc_offset_ > pc_offset) {
+        high = mid;
+        continue;
+      }
+      if (elem.pc_offset_ < pc_offset) {
+        low = mid + 1;
+        continue;
+      }
+      return elem.line_;  // found the element
+    }
+
+    int line = pc_offset_infos_[high].line_;
+    return line;
+  }
+
+  struct PcOffsetInfo {
+    PcOffsetInfo(unsigned int pc_offset, unsigned int src_line)
+      : pc_offset_(pc_offset), line_(src_line) { }
+
+      unsigned int pc_offset_;
+      unsigned int line_;
+  };
+
+  List<PcOffsetInfo>* entries() { return &pc_offset_infos_; }
+  const List<PcOffsetInfo>* entries() const { return &pc_offset_infos_; }
+
+  JITLineInfoTable& operator=(const JITLineInfoTable& other) {
+    if (this != &other) {
+      const List<PcOffsetInfo>* entries = other.entries();
+      if (entries) {
+        pc_offset_infos_.Clear();
+        pc_offset_infos_.AddAll(*entries);
+      }
+    }
+    return *this;
+  }
+
+ private:
+  void AddPcOffsetInfo(const PcOffsetInfo& pc_offset_info) {
+    pc_offset_infos_.Add(pc_offset_info);
+  }
+
+  // The data reported by code generator.
+  List<PcOffsetInfo> pc_offset_infos_;
+};
+
+
 class Logger {
  public:
 #define DECLARE_ENUM(enum_item, ignore) enum_item,
index 9e8408d..e28aa2a 100644 (file)
@@ -15,7 +15,8 @@ CodeEntry::CodeEntry(Logger::LogEventsAndTags tag,
                      const char* name_prefix,
                      const char* resource_name,
                      int line_number,
-                     int column_number)
+                     int column_number,
+                     JITLineInfoTable* line_info)
     : tag_(tag),
       builtin_id_(Builtins::builtin_count),
       name_prefix_(name_prefix),
@@ -26,7 +27,11 @@ CodeEntry::CodeEntry(Logger::LogEventsAndTags tag,
       shared_id_(0),
       script_id_(v8::UnboundScript::kNoScriptId),
       no_frame_ranges_(NULL),
-      bailout_reason_(kEmptyBailoutReason) { }
+      bailout_reason_(kEmptyBailoutReason) {
+    if (NULL != line_info) {
+      line_info_ = *line_info;
+    }
+}
 
 
 bool CodeEntry::is_js_function_tag(Logger::LogEventsAndTags tag) {
@@ -39,12 +44,18 @@ bool CodeEntry::is_js_function_tag(Logger::LogEventsAndTags tag) {
 }
 
 
+static bool LineTickMatch(void* a, void* b) {
+    return a == b;
+}
+
+
 ProfileNode::ProfileNode(ProfileTree* tree, CodeEntry* entry)
     : tree_(tree),
       entry_(entry),
       self_ticks_(0),
       children_(CodeEntriesMatch),
-      id_(tree->next_node_id()) { }
+      id_(tree->next_node_id()),
+      line_ticks_(LineTickMatch) { }
 
 } }  // namespace v8::internal
 
index 957f5db..cad53cf 100644 (file)
@@ -207,6 +207,41 @@ ProfileNode* ProfileNode::FindOrAddChild(CodeEntry* entry) {
 }
 
 
+void ProfileNode::IncrementLineTicks(int src_line) {
+  if (src_line == v8::CpuProfileNode::kNoLineNumberInfo) return;
+  // Increment a hit counter of a certain source line.
+  // Add a new source line if not found.
+  HashMap::Entry* e =
+    line_ticks_.Lookup(reinterpret_cast<void*>(src_line), src_line, true);
+  if (NULL != e) {
+    e->value = static_cast<char*>(e->value) + 1;
+  }
+}
+
+
+bool ProfileNode::GetLineTicks(LineTick* entries,
+                               unsigned int number) const {
+  if (NULL == entries || number == 0) {
+    return false;
+  }
+
+  unsigned lineNumber = line_ticks_.occupancy();
+  if (lineNumber == 0) return false;
+  if (number < lineNumber) return false;
+
+  LineTick* entry = entries;
+
+  for (HashMap::Entry* p = line_ticks_.Start();
+       p != NULL;
+       p = line_ticks_.Next(p), entry++) {
+    entry->line = reinterpret_cast<intptr_t>(p->key);
+    entry->ticks = reinterpret_cast<intptr_t>(p->value);
+  }
+
+  return true;
+}
+
+
 void ProfileNode::Print(int indent) {
   OS::Print("%5u %*c %s%s %d #%d %s",
             self_ticks_,
@@ -252,7 +287,8 @@ ProfileTree::~ProfileTree() {
 }
 
 
-ProfileNode* ProfileTree::AddPathFromEnd(const Vector<CodeEntry*>& path) {
+ProfileNode* ProfileTree::AddPathFromEnd(const Vector<CodeEntry*>& path,
+                                         int src_line) {
   ProfileNode* node = root_;
   for (CodeEntry** entry = path.start() + path.length() - 1;
        entry != path.start() - 1;
@@ -262,11 +298,15 @@ ProfileNode* ProfileTree::AddPathFromEnd(const Vector<CodeEntry*>& path) {
     }
   }
   node->IncrementSelfTicks();
+  if (src_line != v8::CpuProfileNode::kNoLineNumberInfo) {
+    node->IncrementLineTicks(src_line);
+  }
   return node;
 }
 
 
-void ProfileTree::AddPathFromStart(const Vector<CodeEntry*>& path) {
+void ProfileTree::AddPathFromStart(const Vector<CodeEntry*>& path,
+                                   int src_line) {
   ProfileNode* node = root_;
   for (CodeEntry** entry = path.start();
        entry != path.start() + path.length();
@@ -276,6 +316,9 @@ void ProfileTree::AddPathFromStart(const Vector<CodeEntry*>& path) {
     }
   }
   node->IncrementSelfTicks();
+  if (src_line != v8::CpuProfileNode::kNoLineNumberInfo) {
+    node->IncrementLineTicks(src_line);
+  }
 }
 
 
@@ -336,8 +379,9 @@ CpuProfile::CpuProfile(const char* title, bool record_samples)
 }
 
 
-void CpuProfile::AddPath(TimeTicks timestamp, const Vector<CodeEntry*>& path) {
-  ProfileNode* top_frame_node = top_down_.AddPathFromEnd(path);
+void CpuProfile::AddPath(TimeTicks timestamp, const Vector<CodeEntry*>& path,
+                         int src_line) {
+  ProfileNode* top_frame_node = top_down_.AddPathFromEnd(path, src_line);
   if (record_samples_) {
     timestamps_.Add(timestamp);
     samples_.Add(top_frame_node);
@@ -525,13 +569,13 @@ void CpuProfilesCollection::RemoveProfile(CpuProfile* profile) {
 
 
 void CpuProfilesCollection::AddPathToCurrentProfiles(
-    TimeTicks timestamp, const Vector<CodeEntry*>& path) {
+    TimeTicks timestamp, const Vector<CodeEntry*>& path, int src_line) {
   // As starting / stopping profiles is rare relatively to this
   // method, we don't bother minimizing the duration of lock holding,
   // e.g. copying contents of the list to a local vector.
   current_profiles_semaphore_.Wait();
   for (int i = 0; i < current_profiles_.length(); ++i) {
-    current_profiles_[i]->AddPath(timestamp, path);
+    current_profiles_[i]->AddPath(timestamp, path, src_line);
   }
   current_profiles_semaphore_.Signal();
 }
@@ -543,13 +587,15 @@ CodeEntry* CpuProfilesCollection::NewCodeEntry(
       const char* name_prefix,
       const char* resource_name,
       int line_number,
-      int column_number) {
+      int column_number,
+      JITLineInfoTable* line_info) {
   CodeEntry* code_entry = new CodeEntry(tag,
                                         name,
                                         name_prefix,
                                         resource_name,
                                         line_number,
-                                        column_number);
+                                        column_number,
+                                        line_info);
   code_entries_.Add(code_entry);
   return code_entry;
 }
@@ -582,6 +628,15 @@ ProfileGenerator::ProfileGenerator(CpuProfilesCollection* profiles)
 }
 
 
+static int GetSourceLine(unsigned int pc_offset, CodeEntry* entry) {
+  int src_line = v8::CpuProfileNode::kNoLineNumberInfo;
+  const JITLineInfoTable& table = entry->line_info();
+  if (!table.entries()->length()) return src_line;
+  src_line = table.GetSourceLineNumber(pc_offset);
+  return src_line;
+}
+
+
 void ProfileGenerator::RecordTickSample(const TickSample& sample) {
   // Allocate space for stack frames + pc + function + vm-state.
   ScopedVector<CodeEntry*> entries(sample.frames_count + 3);
@@ -589,6 +644,7 @@ void ProfileGenerator::RecordTickSample(const TickSample& sample) {
   // entries vector with NULL values.
   CodeEntry** entry = entries.start();
   memset(entry, 0, entries.length() * sizeof(*entry));
+  int src_line = v8::CpuProfileNode::kNoLineNumberInfo;
   if (sample.pc != NULL) {
     if (sample.has_external_callback && sample.state == EXTERNAL &&
         sample.top_frame_type == StackFrame::EXIT) {
@@ -604,9 +660,11 @@ void ProfileGenerator::RecordTickSample(const TickSample& sample) {
       // ebp contains return address of the current function and skips caller's
       // frame. Check for this case and just skip such samples.
       if (pc_entry) {
+        Code* code = Code::cast(HeapObject::FromAddress(start));
         List<OffsetRange>* ranges = pc_entry->no_frame_ranges();
+        src_line = GetSourceLine(sample.pc - code->instruction_start(),
+                                 pc_entry);
         if (ranges) {
-          Code* code = Code::cast(HeapObject::FromAddress(start));
           int pc_offset = static_cast<int>(
               sample.pc - code->instruction_start());
           for (int i = 0; i < ranges->length(); i++) {
@@ -632,11 +690,25 @@ void ProfileGenerator::RecordTickSample(const TickSample& sample) {
       }
     }
 
+    bool unresolved_src = (src_line == v8::CpuProfileNode::kNoLineNumberInfo) ?
+                          true : false;
+
     for (const Address* stack_pos = sample.stack,
            *stack_end = stack_pos + sample.frames_count;
          stack_pos != stack_end;
          ++stack_pos) {
-      *entry++ = code_map_.FindEntry(*stack_pos);
+      Address start = NULL;
+      *entry = code_map_.FindEntry(*stack_pos, &start);
+      if (unresolved_src && NULL != *entry) {
+          Code* code = Code::cast(HeapObject::FromAddress(start));
+          src_line = GetSourceLine(*stack_pos - code->instruction_start(),
+                                   *entry);
+          if (src_line == v8::CpuProfileNode::kNoLineNumberInfo) {
+            src_line = (*entry)->line_number();
+          }
+          unresolved_src = false;
+      }
+      entry++;
     }
   }
 
@@ -654,7 +726,7 @@ void ProfileGenerator::RecordTickSample(const TickSample& sample) {
     }
   }
 
-  profiles_->AddPathToCurrentProfiles(sample.timestamp, entries);
+  profiles_->AddPathToCurrentProfiles(sample.timestamp, entries, src_line);
 }
 
 
index 1d8ad87..d95b7f8 100644 (file)
@@ -53,7 +53,8 @@ class CodeEntry {
                    const char* name_prefix = CodeEntry::kEmptyNamePrefix,
                    const char* resource_name = CodeEntry::kEmptyResourceName,
                    int line_number = v8::CpuProfileNode::kNoLineNumberInfo,
-                   int column_number = v8::CpuProfileNode::kNoColumnNumberInfo);
+                   int column_number = v8::CpuProfileNode::kNoColumnNumberInfo,
+                   JITLineInfoTable* line_info = NULL);
   ~CodeEntry();
 
   bool is_js_function() const { return is_js_function_tag(tag_); }
@@ -63,6 +64,7 @@ class CodeEntry {
   const char* resource_name() const { return resource_name_; }
   int line_number() const { return line_number_; }
   int column_number() const { return column_number_; }
+  const JITLineInfoTable& line_info() const { return line_info_; }
   void set_shared_id(int shared_id) { shared_id_ = shared_id; }
   int script_id() const { return script_id_; }
   void set_script_id(int script_id) { script_id_ = script_id; }
@@ -96,6 +98,7 @@ class CodeEntry {
   const char* resource_name_;
   int line_number_;
   int column_number_;
+  JITLineInfoTable line_info_;
   int shared_id_;
   int script_id_;
   List<OffsetRange>* no_frame_ranges_;
@@ -115,11 +118,14 @@ class ProfileNode {
   ProfileNode* FindOrAddChild(CodeEntry* entry);
   void IncrementSelfTicks() { ++self_ticks_; }
   void IncreaseSelfTicks(unsigned amount) { self_ticks_ += amount; }
+  void IncrementLineTicks(int src_line);
 
   CodeEntry* entry() const { return entry_; }
   unsigned self_ticks() const { return self_ticks_; }
   const List<ProfileNode*>* children() const { return &children_list_; }
   unsigned id() const { return id_; }
+  unsigned int GetHitLineCount() const { return line_ticks_.occupancy(); }
+  bool GetLineTicks(LineTick* entries, unsigned int number) const;
 
   void Print(int indent);
 
@@ -140,6 +146,7 @@ class ProfileNode {
   HashMap children_;
   List<ProfileNode*> children_list_;
   unsigned id_;
+  HashMap line_ticks_;
 
   DISALLOW_COPY_AND_ASSIGN(ProfileNode);
 };
@@ -150,8 +157,10 @@ class ProfileTree {
   ProfileTree();
   ~ProfileTree();
 
-  ProfileNode* AddPathFromEnd(const Vector<CodeEntry*>& path);
-  void AddPathFromStart(const Vector<CodeEntry*>& path);
+  ProfileNode* AddPathFromEnd(const Vector<CodeEntry*>& path,
+    int src_line = v8::CpuProfileNode::kNoLineNumberInfo);
+  void AddPathFromStart(const Vector<CodeEntry*>& path,
+    int src_line = v8::CpuProfileNode::kNoLineNumberInfo);
   ProfileNode* root() const { return root_; }
   unsigned next_node_id() { return next_node_id_++; }
 
@@ -176,7 +185,8 @@ class CpuProfile {
   CpuProfile(const char* title, bool record_samples);
 
   // Add pc -> ... -> main() call path to the profile.
-  void AddPath(TimeTicks timestamp, const Vector<CodeEntry*>& path);
+  void AddPath(TimeTicks timestamp, const Vector<CodeEntry*>& path,
+               int src_line);
   void CalculateTotalTicksAndSamplingRate();
 
   const char* title() const { return title_; }
@@ -281,11 +291,12 @@ class CpuProfilesCollection {
       const char* name_prefix = CodeEntry::kEmptyNamePrefix,
       const char* resource_name = CodeEntry::kEmptyResourceName,
       int line_number = v8::CpuProfileNode::kNoLineNumberInfo,
-      int column_number = v8::CpuProfileNode::kNoColumnNumberInfo);
+      int column_number = v8::CpuProfileNode::kNoColumnNumberInfo,
+      JITLineInfoTable* line_info = NULL);
 
   // Called from profile generator thread.
   void AddPathToCurrentProfiles(
-      TimeTicks timestamp, const Vector<CodeEntry*>& path);
+      TimeTicks timestamp, const Vector<CodeEntry*>& path, int src_line);
 
   // Limits the number of profiles that can be simultaneously collected.
   static const int kMaxSimultaneousProfiles = 100;
index 6cff742..e7e0872 100644 (file)
@@ -1006,6 +1006,157 @@ TEST(BoundFunctionCall) {
 }
 
 
+// Check that the profile tree for the script below will look like the
+// following:
+//
+// [Top down]:
+//  0  (root)0 #1
+//  15    start 20 #3 no reason
+//  3      foo 20 #4 TryCatchStatement
+//  121        bar 20 #5 TryCatchStatement
+//  223          loop 20 #6 no reason
+//
+// This tests checks distribution of the samples through the source lines.
+// The optimizing compiler is disabled for the hotest function to make
+// the test deterministic.
+
+static int GetHitLineSampleCount(const v8::CpuProfileNode* node) {
+  int sampleCount = 0;
+  unsigned int lineCount = node->GetHitLineCount();
+  if (lineCount) {
+    v8::LineTick* entries = new v8::LineTick[lineCount];
+    CHECK_EQ(true, node->GetLineTicks(entries, lineCount));
+    for (unsigned int i = 0; i < lineCount; i++) {
+      sampleCount += entries[i].ticks;
+    }
+    delete [] entries;
+  }
+  return sampleCount;
+}
+
+
+void CheckHitLine(unsigned int lineNo,
+                  const v8::CpuProfileNode* node,
+                  unsigned int sampleTotal,
+                  unsigned int threshold) {
+  bool found = false;
+
+  unsigned int lineCount = node->GetHitLineCount();
+  CHECK_GT(lineCount, 0);
+
+  v8::LineTick* entries = new v8::LineTick[lineCount];
+  CHECK_EQ(true, node->GetLineTicks(entries, lineCount));
+
+  unsigned int i = 0;
+  for (i = 0; i < lineCount; i++) {
+    if (entries[i].line == lineNo) {
+      found = true;
+      break;
+    }
+  }
+
+  CHECK_EQ(true, found);
+  CHECK_GT(entries[i].ticks * 100 / sampleTotal, threshold);
+
+  delete[] entries;
+}
+
+
+static void CheckBranchWithTickLines(v8::Isolate* isolate,
+                                     const v8::CpuProfile* profile) {
+  const v8::CpuProfileNode* root = profile->GetTopDownRoot();
+
+  const v8::CpuProfileNode* startNode =
+      GetChild(isolate, root, "start");
+  CHECK_EQ(1, startNode->GetChildrenCount());
+  CHECK_EQ(startNode->GetHitCount(), GetHitLineSampleCount(startNode));
+
+  const v8::CpuProfileNode* fooNode =
+      GetChild(isolate, startNode, "foo");
+  CHECK_EQ(1, fooNode->GetChildrenCount());
+  CHECK_EQ(fooNode->GetHitCount(), GetHitLineSampleCount(fooNode));
+
+  const v8::CpuProfileNode* barNode =
+      GetChild(isolate, fooNode, "bar");
+  CHECK_EQ(1, barNode->GetChildrenCount());
+  CHECK_EQ(barNode->GetHitCount(), GetHitLineSampleCount(barNode));
+  // Check that line #14 collects at least 90% of the samples.
+  CheckHitLine(14, barNode, barNode->GetHitCount(), 90);
+
+  const v8::CpuProfileNode* loopNode =
+     GetChild(isolate, barNode, "loop");
+  CHECK_EQ(0, loopNode->GetChildrenCount());
+  CHECK_EQ(loopNode->GetHitCount(), GetHitLineSampleCount(loopNode));
+
+  // Check that line #8 collects at least 70% of the samples
+  CheckHitLine(8, loopNode, loopNode->GetHitCount(), 70);
+}
+
+
+static const char* cpu_profiler_test_source3 = "function loop(timeout) {\n"
+"  with({}); // disable the optimizing compiler for this function"
+"  this.mmm = 0;\n"
+"  var start = Date.now();\n"
+"  while (Date.now() - start < timeout) {\n"
+"    var n = 100*1000;\n"
+"    while(n > 1) {\n"
+"      n--;\n"
+"      this.mmm += n * n * n;\n"
+"    }\n"
+"  }\n"
+"}\n"
+"function bar() {\n"
+"    try {\n"
+"       loop(10);\n"
+"    } catch(e) { }\n"
+"}\n"
+"function foo() {\n"
+"    try {\n"
+"       bar();\n"
+"    } catch (e) { }\n"
+"}\n"
+"function start(timeout) {\n"
+"  var start = Date.now();\n"
+"  do {\n"
+"    foo();\n"
+"    var duration = Date.now() - start;\n"
+"  } while (duration < timeout);\n"
+"  return duration;\n"
+"}\n";
+
+
+TEST(TickLines) {
+  LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
+  v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
+    cpu_profiler_test_source3))->Run();
+  v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
+    env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start")));
+
+  int32_t profiling_interval_ms = 200;
+  v8::Handle<v8::Value> args[] = {
+      v8::Integer::New(env->GetIsolate(), profiling_interval_ms)
+  };
+
+  // The first run tests distribution of the samples through the source
+  // line information taken from "relocation info" created during code
+  // generation.
+  v8::CpuProfile* profile =
+      RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 200);
+  function->Call(env->Global(), ARRAY_SIZE(args), args);
+  CheckBranchWithTickLines(env->GetIsolate(), profile);
+  profile->Delete();
+
+  // This is a case when the precompiled functions located on the heap
+  // are profiled. The second run tests that same source lines collect
+  // the expected number of samples.
+  profile = RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 200);
+  function->Call(env->Global(), ARRAY_SIZE(args), args);
+  CheckBranchWithTickLines(env->GetIsolate(), profile);
+  profile->Delete();
+}
+
+
 static const char* call_function_test_source = "function bar(iterations) {\n"
 "}\n"
 "function start(duration) {\n"
index 3ec6fde..3077e66 100644 (file)
@@ -7,9 +7,9 @@
 # Use 'Trunk' for trunk.
 # If using trunk, will use '.DEPS.git' for gclient.
 chromium_version = '36.0.1985.18'
-chromium_crosswalk_point = 'b2129f32fc231edc2eb401cf56a858dcb1477031'
+chromium_crosswalk_point = 'c282374abcd161a82bbcd5a51e02e33b1be0b1c4'
 blink_crosswalk_point = '7425f4985931cbd48e669c205a707cf1ff4ff6c6'
-v8_crosswalk_point = 'c4640c389b044e377d905579c6b01da3354d0f59'
+v8_crosswalk_point = '535cd006e5174ff00fd7b745a581980b1d371a9f'
 ozone_wayland_point = 'a5ca2e9203e6a0567751cc0400995982b703dde4'
 
 deps_xwalk = {
index 02a90a2..2b9d8c7 100644 (file)
@@ -1,4 +1,4 @@
 MAJOR=7
 MINOR=36
-BUILD=151
+BUILD=152
 PATCH=0
diff --git a/src/xwalk/app/tools/android/app_info.py b/src/xwalk/app/tools/android/app_info.py
new file mode 100644 (file)
index 0000000..1a5ac39
--- /dev/null
@@ -0,0 +1,18 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2014 Intel Corporation. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+class AppInfo:
+  def __init__(self):
+    self.app_root = ''
+    self.app_version = '1.0.0'
+    self.app_versionCode = ''
+    self.fullscreen_flag = ''
+    self.icon = ''
+    self.name = 'AppTemplate'
+    self.orientation = 'unspecified'
+    self.original_name = ''
+    self.package = 'org.xwalk.app.template'
+    self.remote_debugging = ''
index 40fb647..bb66a0b 100755 (executable)
@@ -14,6 +14,7 @@ import shutil
 import stat
 import sys
 
+from app_info import AppInfo
 from customize_launch_screen import CustomizeLaunchScreen
 from handle_xml import AddElementAttribute
 from handle_xml import AddElementAttributeAndText
@@ -108,7 +109,10 @@ def CompressSourceFiles(app_root, compressor):
     compress_js_and_css.CompressCss(css_list)
 
 
-def Prepare(name, package, app_root, compressor):
+def Prepare(app_info, compressor):
+  name = app_info.name
+  package = app_info.package
+  app_root = app_info.app_root
   if os.path.exists(name):
     shutil.rmtree(name)
   shutil.copytree('app_src', name)
@@ -170,9 +174,13 @@ def CustomizeThemeXML(name, fullscreen, app_manifest):
   theme_file.close()
 
 
-def CustomizeXML(package, app_versionCode, app_version, description, name,
-                 orientation, icon_dict, fullscreen, icon, app_manifest,
-                 permissions, app_root):
+def CustomizeXML(app_info, description, icon_dict, app_manifest, permissions):
+  app_version = app_info.app_version
+  app_versionCode = app_info.app_versionCode
+  name = app_info.name
+  orientation = app_info.orientation
+  package = app_info.package
+  original_name = app_info.original_name
   manifest_path = os.path.join(name, 'AndroidManifest.xml')
   if not os.path.isfile(manifest_path):
     print ('Please make sure AndroidManifest.xml'
@@ -180,7 +188,7 @@ def CustomizeXML(package, app_versionCode, app_version, description, name,
     sys.exit(6)
 
   CustomizeStringXML(name, description)
-  CustomizeThemeXML(name, fullscreen, app_manifest)
+  CustomizeThemeXML(name, app_info.fullscreen_flag, app_manifest)
   xmldoc = minidom.parse(manifest_path)
   EditElementAttribute(xmldoc, 'manifest', 'package', package)
   if app_versionCode:
@@ -193,14 +201,14 @@ def CustomizeXML(package, app_versionCode, app_version, description, name,
     EditElementAttribute(xmldoc, 'manifest', 'android:description',
                          "@string/description")
   HandlePermissions(permissions, xmldoc)
-  EditElementAttribute(xmldoc, 'application', 'android:label', name)
+  EditElementAttribute(xmldoc, 'application', 'android:label', original_name)
   activity_name = package + '.' + name + 'Activity'
   EditElementAttribute(xmldoc, 'activity', 'android:name', activity_name)
-  EditElementAttribute(xmldoc, 'activity', 'android:label', name)
+  EditElementAttribute(xmldoc, 'activity', 'android:label', original_name)
   if orientation:
     EditElementAttribute(xmldoc, 'activity', 'android:screenOrientation',
                          orientation)
-  icon_name = CustomizeIcon(name, app_root, icon, icon_dict)
+  icon_name = CustomizeIcon(name, app_info.app_root, app_info.icon, icon_dict)
   if icon_name:
     EditElementAttribute(xmldoc, 'application', 'android:icon',
                          '@drawable/%s' % icon_name)
@@ -233,9 +241,9 @@ def SetVariable(file_path, string_line, variable, value):
   shutil.move(temp_file_path, file_path)
 
 
-def CustomizeJava(name, package, app_url, app_local_path,
-                  enable_remote_debugging, display_as_fullscreen,
-                  keep_screen_on):
+def CustomizeJava(app_info, app_url, app_local_path, keep_screen_on):
+  name = app_info.name
+  package = app_info.package
   root_path = os.path.join(name, 'src', package.replace('.', os.path.sep))
   dest_activity = os.path.join(root_path, name + 'Activity.java')
   ReplaceString(dest_activity, 'org.xwalk.app.template', package)
@@ -260,11 +268,11 @@ def CustomizeJava(name, package, app_url, app_local_path,
                ' is correct.')
         sys.exit(8)
 
-  if enable_remote_debugging:
+  if app_info.remote_debugging:
     SetVariable(dest_activity,
                 'public void onCreate(Bundle savedInstanceState)',
                 'RemoteDebugging', 'true')
-  if display_as_fullscreen:
+  if app_info.fullscreen_flag:
     SetVariable(dest_activity,
                 'super.onCreate(savedInstanceState)',
                 'IsFullscreen', 'true')
@@ -297,7 +305,7 @@ def CopyExtensionFile(extension_name, suffix, src_path, dest_path):
     shutil.copyfile(src_file, dest_file)
 
 
-def CustomizeExtensions(name, extensions):
+def CustomizeExtensions(app_info, extensions):
   """Copy the files from external extensions and merge them into APK.
 
   The directory of one external extension should be like:
@@ -315,6 +323,7 @@ def CustomizeExtensions(name, extensions):
   """
   if not extensions:
     return
+  name = app_info.name
   apk_path = name
   apk_assets_path = os.path.join(apk_path, 'assets')
   extensions_string = 'xwalk-extensions'
@@ -397,10 +406,10 @@ def CustomizeExtensions(name, extensions):
     extension_json_file.close()
 
 
-def GenerateCommandLineFile(name, xwalk_command_line):
+def GenerateCommandLineFile(app_info, xwalk_command_line):
   if xwalk_command_line == '':
     return
-  assets_path = os.path.join(name, 'assets')
+  assets_path = os.path.join(app_info.name, 'assets')
   file_path = os.path.join(assets_path, 'xwalk-command-line')
   command_line_file = open(file_path, 'w')
   command_line_file.write('xwalk ' + xwalk_command_line)
@@ -465,23 +474,15 @@ def CustomizeIcon(name, app_root, icon, icon_dict):
   return icon_name
 
 
-def CustomizeAll(app_versionCode, description, icon_dict, permissions, app_url,
-                 app_root, app_local_path, enable_remote_debugging,
-                 display_as_fullscreen, keep_screen_on, extensions,
-                 app_manifest, icon, package='org.xwalk.app.template',
-                 name='AppTemplate', app_version='1.0.0',
-                 orientation='unspecified', xwalk_command_line='',
-                 compressor=None):
+def CustomizeAll(app_info, description, icon_dict, permissions, app_url,
+                 app_local_path, keep_screen_on, extensions, app_manifest,
+                 xwalk_command_line='', compressor=None):
   try:
-    Prepare(name, package, app_root, compressor)
-    CustomizeXML(package, app_versionCode, app_version, description, name,
-                 orientation, icon_dict, display_as_fullscreen, icon,
-                 app_manifest, permissions, app_root)
-    CustomizeJava(name, package, app_url, app_local_path,
-                  enable_remote_debugging, display_as_fullscreen,
-                  keep_screen_on)
-    CustomizeExtensions(name, extensions)
-    GenerateCommandLineFile(name, xwalk_command_line)
+    Prepare(app_info, compressor)
+    CustomizeXML(app_info, description, icon_dict, app_manifest, permissions)
+    CustomizeJava(app_info, app_url, app_local_path, keep_screen_on)
+    CustomizeExtensions(app_info, extensions)
+    GenerateCommandLineFile(app_info, xwalk_command_line)
   except SystemExit as ec:
     print('Exiting with error code: %d' % ec.code)
     sys.exit(ec.code)
@@ -554,24 +555,28 @@ def main():
                  72: 'icons/icon_72.png',
                  96: 'icons/icon_96.png',
                  48: 'icons/icon_48.png'}
-    if options.name is None:
-      options.name = 'Example'
+    app_info = AppInfo()
+    if options.name is not None:
+      app_info.name = options.name
     if options.app_root is None:
-      options.app_root = os.path.join('test_data', 'manifest')
-    if options.package is None:
-      options.package = 'org.xwalk.app.template'
-    if options.orientation is None:
-      options.orientation = 'unspecified'
-    if options.app_version is None:
-      options.app_version = '1.0.0'
-    icon = os.path.join('test_data', 'manifest', 'icons', 'icon_96.png')
-    CustomizeAll(options.app_versionCode, options.description, icon_dict,
-                 options.permissions, options.app_url, options.app_root,
-                 options.app_local_path, options.enable_remote_debugging,
-                 options.fullscreen, options.keep_screen_on,
-                 options.extensions, options.manifest,
-                 icon, options.package, options.name,
-                 options.app_version, options.orientation,
+      app_info.app_root = os.path.join('test_data', 'manifest')
+    else:
+      app_info.app_root = options.app_root
+    if options.package is not None:
+      app_info.package = options.package
+    if options.orientation is not None:
+      app_info.orientation = options.orientation
+    if options.app_version is not None:
+      app_info.app_version = options.app_version
+    if options.enable_remote_debugging is not None:
+      app_info.remote_debugging = options.enable_remote_debugging
+    if options.fullscreen is not None:
+      app_info.fullscreen_flag = options.fullscreen
+    app_info.icon = os.path.join('test_data', 'manifest', 'icons',
+                                 'icon_96.png')
+    CustomizeAll(app_info, options.description, icon_dict,
+                 options.permissions, options.app_url, options.app_local_path,
+                 options.keep_screen_on, options.extensions, options.manifest,
                  options.xwalk_command_line, options.compressor)
   except SystemExit as ec:
     print('Exiting with error code: %d' % ec.code)
index b58ed2a..375fdbf 100755 (executable)
@@ -15,6 +15,7 @@ import sys
 
 sys.path.append('scripts/gyp')
 
+from app_info import AppInfo
 from customize import VerifyAppName, CustomizeAll, \
                       ParseParameterForCompressor, ReplaceSpaceWithUnderscore
 from dex import AddExeExtensions
@@ -92,21 +93,23 @@ def GetVersion(path):
   return version_str
 
 
-def ParseManifest(options):
+def ParseManifest(options, app_info):
   parser = ManifestJsonParser(os.path.expanduser(options.manifest))
-  app_name = parser.GetAppName()
+  original_name = app_info.original_name = parser.GetAppName()
+  app_name = None
   if options.package:
     VerifyAppName(options.package, 'packagename')
   else:
-    VerifyAppName(app_name)
-    app_name = ReplaceSpaceWithUnderscore(app_name)
+    VerifyAppName(original_name)
+    app_name = ReplaceSpaceWithUnderscore(original_name)
     options.package = 'org.xwalk.' + app_name.lower()
   if options.name:
     VerifyAppName(options.name)
+    app_info.original_name = options.name
     options.name = ReplaceSpaceWithUnderscore(options.name)
   else:
-    VerifyAppName(app_name)
-    options.name = ReplaceSpaceWithUnderscore(app_name)
+    VerifyAppName(original_name)
+    options.name = ReplaceSpaceWithUnderscore(original_name)
   if not options.app_version:
     options.app_version = parser.GetVersion()
   if not options.app_versionCode and not options.app_versionCodeBase:
@@ -190,38 +193,28 @@ def MakeVersionCode(options):
   return '%s%s' % (abi, b.zfill(7))
 
 
-def Customize(options):
-  package = 'org.xwalk.app.template'
+def Customize(options, app_info):
   if options.package:
-    package = options.package
-  name = 'AppTemplate'
+    app_info.package = options.package
   if options.name:
-    name = options.name
-  app_version = ''
+    app_info.name = options.name
   if options.app_version:
-    app_version = options.app_version
-  app_versionCode = MakeVersionCode(options)
-  app_root = ''
+    app_info.app_version = options.app_version
+  app_info.app_versionCode = MakeVersionCode(options)
   if options.app_root:
-    app_root = os.path.expanduser(options.app_root)
-  remote_debugging = ''
+    app_info.app_root = os.path.expanduser(options.app_root)
   if options.enable_remote_debugging:
-    remote_debugging = '--enable-remote-debugging'
-  fullscreen_flag = ''
+    app_info.remote_debugging = '--enable-remote-debugging'
   if options.fullscreen:
-    fullscreen_flag = '-f'
-  orientation = 'unspecified'
+    app_info.fullscreen_flag = '-f'
   if options.orientation:
-    orientation = options.orientation
-  icon = ''
+    app_info.orientation = options.orientation
   if options.icon:
-    icon = '%s' % os.path.expanduser(options.icon)
-  CustomizeAll(app_versionCode, options.description, options.icon_dict,
-               options.permissions, options.app_url, app_root,
-               options.app_local_path, remote_debugging,
-               fullscreen_flag, options.keep_screen_on, options.extensions,
-               options.manifest, icon, package, name, app_version,
-               orientation, options.xwalk_command_line, options.compressor)
+    app_info.icon = '%s' % os.path.expanduser(options.icon)
+  CustomizeAll(app_info, options.description, options.icon_dict,
+               options.permissions, options.app_url, options.app_local_path,
+               options.keep_screen_on, options.extensions, options.manifest,
+               options.xwalk_command_line, options.compressor)
 
 
 def Execution(options, name):
@@ -529,8 +522,8 @@ def PrintPackageInfo(options, packaged_archs):
            'here:\nhttps://software.intel.com/en-us/html5/articles/submitting'
            '-multiple-crosswalk-apk-to-google-play-store')
 
-def MakeApk(options):
-  Customize(options)
+def MakeApk(options, app_info):
+  Customize(options, app_info)
   name = options.name
   packaged_archs = []
   if options.mode == 'shared':
@@ -709,6 +702,7 @@ def main(argv):
       print('Using manifest.json distributed with the application.')
       options.manifest = manifest_path
 
+  app_info = AppInfo()
   if not options.manifest:
     if options.package:
       VerifyAppName(options.package, 'packagename')
@@ -717,6 +711,7 @@ def main(argv):
                    'Please use "--package" option.')
     if options.name:
       VerifyAppName(options.name)
+      app_info.original_name = options.name
       options.name = ReplaceSpaceWithUnderscore(options.name)
     else:
       parser.error('The APK name is required! Please use "--name" option.')
@@ -741,7 +736,7 @@ def main(argv):
     options.icon_dict = {}
   else:
     try:
-      ParseManifest(options)
+      ParseManifest(options, app_info)
     except SystemExit as ec:
       return ec.code
 
@@ -759,7 +754,7 @@ def main(argv):
       os.makedirs(target_dir)
 
   try:
-    MakeApk(options)
+    MakeApk(options, app_info)
   except SystemExit as ec:
     CleanDir(options.name)
     CleanDir('out')
index df9659e..4c728ac 100755 (executable)
@@ -12,6 +12,8 @@ import sys
 import unittest
 import warnings
 
+from customize import ReplaceSpaceWithUnderscore
+
 
 def Clean(name, app_version):
   if os.path.exists(name):
@@ -59,7 +61,7 @@ def RunCommand(command):
   return proc.communicate()[0]
 
 
-def GetResultWithOption(mode, manifest=None, name=None, package=None):
+def GetResultWithOption(mode=None, manifest=None, name=None, package=None):
   app_url = None
   if manifest is not None:
     manifest = '--manifest=' + manifest
@@ -69,13 +71,14 @@ def GetResultWithOption(mode, manifest=None, name=None, package=None):
     name = '--name=' + name
   if package is not None:
     package = '--package=' + package
+
   cmd = ['python', 'make_apk.py',
          '--app-version=1.0.0',
          '%s' % manifest,
          '%s' % name,
          '%s' % package,
          '%s' % app_url,
-         mode]
+         '%s' % mode]
   return RunCommand(cmd)
 
 
@@ -986,6 +989,35 @@ class TestMakeApk(unittest.TestCase):
     Clean(name, version)
 
 
+  def VerifyResultForAppNameWithSpace(self, manifest=None, name=None,
+                                      package=None):
+    version = '1.0.0'
+    GetResultWithOption(manifest=manifest, name=name, package=package)
+    if name is None:
+      name = 'app name '
+    replaced_name = ReplaceSpaceWithUnderscore(name)
+    manifest = replaced_name + '/AndroidManifest.xml'
+    with open(manifest, 'r') as content_file:
+      content = content_file.read()
+    self.assertTrue(os.path.exists(manifest))
+    self.assertTrue(name in content)
+    Clean(replaced_name, version)
+
+
+  def testAppNameWithSpace(self):
+    name = 'app name'
+    package = 'org.xwalk.app_name'
+
+    self.VerifyResultForAppNameWithSpace(name=name, package=package)
+
+    name = 'app name '
+    self.VerifyResultForAppNameWithSpace(name=name, package=package)
+
+    directory = os.path.join('test_data', 'manifest', 'invalidchars')
+    manifest_path = os.path.join(directory, 'manifest_contain_space_name.json')
+    self.VerifyResultForAppNameWithSpace(manifest=manifest_path)
+
+
 def SuiteWithModeOption():
   # Gather all the tests for the specified mode option.
   test_suite = unittest.TestSuite()
@@ -1022,6 +1054,7 @@ def SuiteWithModeOption():
 def SuiteWithEmptyModeOption():
   # Gather all the tests for empty mode option.
   test_suite = unittest.TestSuite()
+  test_suite.addTest(TestMakeApk('testAppNameWithSpace'))
   test_suite.addTest(TestMakeApk('testCompressor'))
   test_suite.addTest(TestMakeApk('testCustomizeFile'))
   test_suite.addTest(TestMakeApk('testEmptyMode'))
index 8baa074..76a27e2 100644 (file)
@@ -127,7 +127,7 @@ class Application : public Runtime::Observer,
   Application(scoped_refptr<ApplicationData> data,
               RuntimeContext* context,
               Observer* observer);
-
+  virtual bool Launch(const LaunchParams& launch_params);
   virtual void InitSecurityPolicy();
   void AddSecurityPolicy(const GURL& url, bool subdomains);
 
@@ -150,9 +150,6 @@ class Application : public Runtime::Observer,
   virtual void RenderProcessHostDestroyed(
       content::RenderProcessHost* host) OVERRIDE;
 
-
-  bool Launch(const LaunchParams& launch_params);
-
   // Try to extract the URL from different possible keys for entry points in the
   // manifest, returns it and the entry point used.
   GURL GetStartURL(const LaunchParams& params, LaunchEntryPoint* used);
index 68c1748..ace39f7 100644 (file)
@@ -25,7 +25,6 @@ namespace application {
 const base::FilePath::CharType ApplicationStorageImpl::kDBFileName[] =
     FILE_PATH_LITERAL("applications.db");
 
-const char kEventSeparator = ';';
 const char kPermissionSeparator = '^';
 
 // Switching the JSON format DB(version 0) to SQLite backend version 1,
@@ -74,16 +73,6 @@ bool InitApplicationsTable(sql::Connection* db) {
   return transaction.Commit();
 }
 
-bool InitEventsTable(sql::Connection* db) {
-  sql::Transaction transaction(db);
-  transaction.Begin();
-  if (!db->DoesTableExist(db_fields::kEventTableName)) {
-    if (!db->Execute(db_fields::kCreateEventTableOp))
-     return false;
-  }
-  return transaction.Commit();
-}
-
 // Permissions are stored like "bluetooth^ALLOW;calendar^DENY;contacts^ALLOW"
 std::string ToString(StoredPermissionMap permissions) {
   std::string str;
@@ -229,11 +218,6 @@ bool ApplicationStorageImpl::Init(
     return false;
   }
 
-  if (!InitEventsTable(sqlite_db.get())) {
-    LOG(ERROR) << "Unable to open registered events table.";
-    return false;
-  }
-
   if (!InitPermissionsTable(sqlite_db.get())) {
     LOG(ERROR) << "Unable to open registered permissions table.";
     return false;
@@ -287,7 +271,7 @@ bool ApplicationStorageImpl::GetInstalledApplications(
   }
 
   sql::Statement smt(sqlite_db_->GetUniqueStatement(
-      db_fields::kGetAllRowsFromAppEventTableOp));
+      db_fields::kGetAllRowsFromAppTableOp));
   if (!smt.is_valid())
     return false;
 
@@ -310,8 +294,6 @@ bool ApplicationStorageImpl::GetInstalledApplications(
     }
     std::string path = smt.ColumnString(2);
     double install_time = smt.ColumnDouble(3);
-    std::vector<std::string> events;
-    base::SplitString(smt.ColumnString(4), kEventSeparator, &events);
 
     std::string error;
     scoped_refptr<ApplicationData> application =
@@ -328,11 +310,6 @@ bool ApplicationStorageImpl::GetInstalledApplications(
 
     application->install_time_ = base::Time::FromDoubleT(install_time);
 
-    if (!events.empty()) {
-      application->events_ =
-          std::set<std::string>(events.begin(), events.end());
-    }
-
     application->permission_map_ = ToPermissionMap(smt.ColumnString(5));
 
     if (!Insert(application, applications)) {
@@ -354,7 +331,6 @@ bool ApplicationStorageImpl::AddApplication(const ApplicationData* application,
 
   return (SetApplicationValue(
       application, install_time, db_fields::kSetApplicationWithBindOp) &&
-          SetEvents(application->ID(), application->GetEvents()) &&
           SetPermissions(application->ID(), application->permission_map_));
 }
 
@@ -367,7 +343,6 @@ bool ApplicationStorageImpl::UpdateApplication(
 
   if (SetApplicationValue(
           application, install_time, db_fields::kUpdateApplicationWithBindOp) &&
-      UpdateEvents(application->ID(), application->GetEvents()) &&
       UpdatePermissions(application->ID(), application->permission_map_)) {
     application->is_dirty_ = false;
     return true;
@@ -436,64 +411,6 @@ bool ApplicationStorageImpl::SetApplicationValue(
   return transaction.Commit();
 }
 
-bool ApplicationStorageImpl::SetEvents(const std::string& id,
-                                       const std::set<std::string>& events) {
-  if (!db_initialized_)
-    return false;
-  return SetEventsValue(id, events, db_fields::kInsertEventsWithBindOp);
-}
-
-bool ApplicationStorageImpl::UpdateEvents(
-    const std::string &id, const std::set<std::string>& events) {
-  if (!db_initialized_)
-    return false;
-
-  if (events.empty())
-    return DeleteEvents(id);
-
-  return SetEventsValue(id, events, db_fields::kUpdateEventsWithBindOp);
-}
-
-bool ApplicationStorageImpl::DeleteEvents(const std::string& id) {
-  sql::Transaction transaction(sqlite_db_.get());
-  if (!transaction.Begin())
-    return false;
-
-  sql::Statement smt(sqlite_db_->GetUniqueStatement(
-      db_fields::kDeleteEventsWithBindOp));
-  smt.BindString(0, id);
-
-  if (!smt.Run()) {
-    LOG(ERROR) << "An error occured when deleting event information from DB.";
-    return false;
-  }
-
-  return transaction.Commit();
-}
-
-bool ApplicationStorageImpl::SetEventsValue(
-    const std::string& id,
-    const std::set<std::string>& events,
-    const std::string& operation) {
-  sql::Transaction transaction(sqlite_db_.get());
-  std::string events_list(JoinString(
-      std::vector<std::string>(events.begin(), events.end()), kEventSeparator));
-
-  if (!transaction.Begin())
-    return false;
-
-  sql::Statement smt(sqlite_db_->GetUniqueStatement(
-      operation.c_str()));
-  smt.BindString(0, events_list);
-  smt.BindString(1, id);
-  if (!smt.Run()) {
-    LOG(ERROR) << "An error occured when inserting event information into DB.";
-    return false;
-  }
-
-  return transaction.Commit();
-}
-
 bool ApplicationStorageImpl::SetPermissions(const std::string& id,
     const StoredPermissionMap& permissions) {
   if (!db_initialized_) {
index 2afeeb1..df04c19 100644 (file)
@@ -40,15 +40,6 @@ class ApplicationStorageImpl {
   bool SetApplicationValue(const ApplicationData* application,
                            const base::Time& install_time,
                            const std::string& operation);
-  // Events helper functions
-  bool SetEventsValue(const std::string& id,
-                      const std::set<std::string>& events,
-                      const std::string& operation);
-  bool SetEvents(const std::string& id,
-                 const std::set<std::string>& events);
-  bool UpdateEvents(const std::string& id,
-                    const std::set<std::string>& events);
-  bool DeleteEvents(const std::string& id);
   // Permissions helper functions
   bool SetPermissionsValue(const std::string& id,
                            const StoredPermissionMap& permissions,
index 1567a5d..48c3ae0 100644 (file)
@@ -56,17 +56,12 @@ TEST_F(ApplicationStorageImplTest, DBInsert) {
       &error);
   ASSERT_TRUE(error.empty());
   ASSERT_TRUE(application);
-  std::set<std::string> events;
-  events.insert("test_events");
-  application->SetEvents(events);
   EXPECT_TRUE(app_storage_impl_->AddApplication(application.get(),
                                                 base::Time::FromDoubleT(0)));
   ApplicationData::ApplicationDataMap applications;
   ASSERT_TRUE(app_storage_impl_->GetInstalledApplications(applications));
   EXPECT_EQ(applications.size(), 1);
   EXPECT_TRUE(applications[application->ID()]);
-  EXPECT_EQ(applications[application->ID()]
-            ->GetEvents().count("test_events"), 1);
 }
 
 TEST_F(ApplicationStorageImplTest, DBDelete) {
index b62f94f..d599145 100644 (file)
@@ -10,8 +10,9 @@
 
 #include "content/public/browser/web_contents.h"
 #include "content/public/browser/render_process_host.h"
+#include "content/browser/screen_orientation/screen_orientation_dispatcher_host.h"
 
-#include "xwalk/runtime/browser/ui/native_app_window.h"
+#include "xwalk/runtime/browser/ui/native_app_window_tizen.h"
 #include "xwalk/runtime/common/xwalk_common_messages.h"
 
 #if defined(USE_OZONE)
@@ -83,7 +84,7 @@ ApplicationTizen::~ApplicationTizen() {
 }
 
 void ApplicationTizen::Hide() {
-  DCHECK(runtimes_.size());
+  DCHECK(!runtimes_.empty());
   std::set<Runtime*>::iterator it = runtimes_.begin();
   for (; it != runtimes_.end(); ++it) {
     if ((*it)->window())
@@ -91,6 +92,16 @@ void ApplicationTizen::Hide() {
   }
 }
 
+bool ApplicationTizen::Launch(const LaunchParams& launch_params) {
+  if (Application::Launch(launch_params)) {
+    DCHECK(render_process_host_);
+    render_process_host_->GetScreenOrientationDispatcherHost()->
+        SetProviderForTests(this);
+    return true;
+  }
+  return false;
+}
+
 void ApplicationTizen::InitSecurityPolicy() {
   // On Tizen, CSP mode has higher priority, and WARP will be disabled
   // if the application is under CSP mode.
@@ -172,5 +183,24 @@ void ApplicationTizen::DidProcessEvent(
 }
 #endif
 
+void ApplicationTizen::LockOrientation(
+      blink::WebScreenOrientationLockType lock) {
+  DCHECK(!runtimes_.empty());
+  // FIXME: Probably need better alignment with
+  // https://w3c.github.io/screen-orientation/#screen-orientation-lock-lifetime
+  std::set<Runtime*>::iterator it = runtimes_.begin();
+  for (; it != runtimes_.end(); ++it) {
+    NativeAppWindow* window = (*it)->window();
+    if (window && window->IsActive()) {
+      ToNativeAppWindowTizen(window)->LockOrientation(lock);
+      break;
+    }
+  }
+}
+
+void ApplicationTizen::UnlockOrientation() {
+  LockOrientation(blink::WebScreenOrientationLockDefault);
+}
+
 }  // namespace application
 }  // namespace xwalk
index ce8524e..aa5dec5 100644 (file)
@@ -5,6 +5,7 @@
 #define XWALK_APPLICATION_BROWSER_APPLICATION_TIZEN_H_
 
 #include "base/event_types.h"
+#include "content/browser/screen_orientation/screen_orientation_provider.h"
 #include "xwalk/application/browser/application.h"
 
 #if defined(USE_OZONE)
@@ -19,7 +20,7 @@ class ApplicationTizen :  // NOLINT
 #if defined(USE_OZONE)
   public ui::PlatformEventObserver,
 #endif
-  public Application {
+  public Application, public content::ScreenOrientationProvider {
  public:
   virtual ~ApplicationTizen();
   void Hide();
@@ -30,13 +31,18 @@ class ApplicationTizen :  // NOLINT
   ApplicationTizen(scoped_refptr<ApplicationData> data,
                    RuntimeContext* context,
                    Application::Observer* observer);
-
+  virtual bool Launch(const LaunchParams& launch_params) OVERRIDE;
   virtual void InitSecurityPolicy() OVERRIDE;
 
 #if defined(USE_OZONE)
   virtual void WillProcessEvent(const ui::PlatformEvent& event) OVERRIDE;
   virtual void DidProcessEvent(const ui::PlatformEvent& event) OVERRIDE;
 #endif
+
+  // content::ScreenOrientationProvider overrides:
+  virtual void LockOrientation(
+      blink::WebScreenOrientationLockType orientations) OVERRIDE;
+  virtual void UnlockOrientation() OVERRIDE;
 };
 
 inline ApplicationTizen* ToApplicationTizen(Application* app) {
index bf54bc1..d5f8b87 100644 (file)
@@ -314,15 +314,6 @@ bool ApplicationData::LoadManifestVersion(base::string16* error) {
   return true;
 }
 
-void ApplicationData::SetEvents(const std::set<std::string>& events) {
-  events_ = events;
-  is_dirty_ = true;
-}
-
-const std::set<std::string>& ApplicationData::GetEvents() const {
-  return events_;
-}
-
 StoredPermission ApplicationData::GetPermission(
     const std::string& permission_name) const {
   StoredPermissionMap::const_iterator iter =
index b9063f5..ed6fc62 100644 (file)
@@ -111,10 +111,6 @@ class ApplicationData : public base::RefCountedThreadSafe<ApplicationData> {
     return manifest_.get();
   }
 
-  // System events
-  void SetEvents(const std::set<std::string>& events);
-  const std::set<std::string>& GetEvents() const;
-
   bool IsDirty() const { return is_dirty_; }
 
   const base::Time& install_time() const { return install_time_; }
index 5087834..fbeab57 100644 (file)
@@ -9,7 +9,6 @@ namespace xwalk {
 namespace application_storage_constants {
 
 const char kAppTableName[] = "applications";
-const char kEventTableName[] = "registered_events";
 const char kPermissionTableName[] = "stored_permissions";
 const char kGarbageCollectionTableName[] = "garbage_collection";
 
@@ -20,14 +19,6 @@ const char kCreateAppTableOp[] =
     "path TEXT NOT NULL,"
     "install_time REAL)";
 
-const char kCreateEventTableOp[] =
-    "CREATE TABLE registered_events ("
-    "id TEXT NOT NULL,"
-    "event_names TEXT NOT NULL,"
-    "PRIMARY KEY (id),"
-    "FOREIGN KEY (id) REFERENCES applications(id)"
-    "ON DELETE CASCADE)";
-
 const char kCreatePermissionTableOp[] =
     "CREATE TABLE stored_permissions ("
     "id TEXT NOT NULL,"
@@ -46,12 +37,9 @@ const char kCreateGarbageCollectionTriggersOp[] =
     "CREATE TRIGGER IF NOT EXISTS del_garbage_app AFTER INSERT ON applications"
     " BEGIN DELETE FROM garbage_collection WHERE app_id = NEW.id; END";
 
-const char kGetAllRowsFromAppEventTableOp[] =
+const char kGetAllRowsFromAppTableOp[] =
     "SELECT A.id, A.manifest, A.path, A.install_time, "
-    "B.event_names, C.permission_names "
-    "FROM applications as A "
-    "LEFT JOIN registered_events as B "
-    "ON A.id = B.id "
+    "C.permission_names FROM applications as A "
     "LEFT JOIN stored_permissions as C "
     "ON A.id = C.id";
 
@@ -66,16 +54,6 @@ const char kUpdateApplicationWithBindOp[] =
 const char kDeleteApplicationWithBindOp[] =
     "DELETE FROM applications WHERE id = ?";
 
-const char kInsertEventsWithBindOp[] =
-    "INSERT INTO registered_events (event_names, id) "
-    "VALUES(?,?)";
-
-const char kUpdateEventsWithBindOp[] =
-    "UPDATE registered_events SET event_names = ? WHERE id = ?";
-
-const char kDeleteEventsWithBindOp[] =
-    "DELETE FROM registered_events WHERE id = ?";
-
 const char kInsertPermissionsWithBindOp[] =
     "INSERT INTO stored_permissions (permission_names, id) "
     "VALUES(?,?)";
index 1fbd0bb..054426e 100644 (file)
 namespace xwalk {
 namespace application_storage_constants {
   extern const char kAppTableName[];
-  extern const char kEventTableName[];
   extern const char kPermissionTableName[];
   extern const char kGarbageCollectionTableName[];
 
   extern const char kCreateAppTableOp[];
-  extern const char kCreateEventTableOp[];
   extern const char kCreatePermissionTableOp[];
   extern const char kCreateGarbageCollectionTableOp[];
   extern const char kCreateGarbageCollectionTriggersOp[];
-  extern const char kGetAllRowsFromAppEventTableOp[];
+  extern const char kGetAllRowsFromAppTableOp[];
   extern const char kSetApplicationWithBindOp[];
   extern const char kUpdateApplicationWithBindOp[];
   extern const char kDeleteApplicationWithBindOp[];
-  extern const char kInsertEventsWithBindOp[];
-  extern const char kUpdateEventsWithBindOp[];
-  extern const char kDeleteEventsWithBindOp[];
   extern const char kInsertPermissionsWithBindOp[];
   extern const char kUpdatePermissionsWithBindOp[];
   extern const char kDeletePermissionsWithBindOp[];
index 968b17f..b2037fc 100644 (file)
@@ -33,14 +33,6 @@ int main(int argc, char *argv[]) {
   if (argc <= 2)
     return usage(argv[0]);
 
-  // When installing an application on Tizen, the libraries used require
-  // some steps to be run as root (UID 0) and fail otherwise, so we force
-  // this tool to assume the root UID.
-  if (setuid(0)) {
-    fprintf(stderr, "Make sure '%s' is set-user-ID-root\n", argv[0]);
-    return 1;;
-  }
-
   PackageInstallerHelper helper(argv[2]);
   if (!strcmp(argv[1], "--install")) {
     if (argc != 5)
index 2525740..2cd2aaa 100644 (file)
@@ -5,6 +5,7 @@
       'type': 'static_library',
       'dependencies': [
         '../base/base.gyp:base',
+        '../content/content.gyp:content_browser',
         '../crypto/crypto.gyp:crypto',
         '../ipc/ipc.gyp:ipc',
         '../sql/sql.gyp:sql',
         }],
       ],
       'include_dirs': [
+        '..',
         '../..',
       ],
     },
index e501026..3addacd 100755 (executable)
@@ -124,6 +124,7 @@ def PrepareFromXwalk(src_dir, target_dir):
     # Build and python tools.
     (os.path.join(tools_src_dir, 'ant'),
      os.path.join(target_dir, 'scripts/ant')),
+    (os.path.join(tools_src_dir, 'app_info.py'), target_dir),
     (os.path.join(tools_src_dir, 'compress_js_and_css.py'), target_dir),
     (os.path.join(tools_src_dir, 'customize.py'), target_dir),
     (os.path.join(tools_src_dir, 'customize_launch_screen.py'), target_dir),
index 4f8ec3c..be4777e 100644 (file)
@@ -12,7 +12,7 @@
 %endif
 
 Name:           crosswalk
-Version:        7.36.151.0
+Version:        7.36.152.0
 Release:        0
 Summary:        Crosswalk is an app runtime based on Chromium
 License:        (BSD-3-Clause and LGPL-2.1+)
index 7ceee28..991faf3 100644 (file)
@@ -119,6 +119,13 @@ NativeAppWindowTizen::~NativeAppWindowTizen() {
     SensorProvider::GetInstance()->RemoveObserver(this);
 }
 
+void NativeAppWindowTizen::LockOrientation(
+      blink::WebScreenOrientationLockType lock) {
+  orientation_lock_ = lock;
+  if (SensorProvider* sensor = SensorProvider::GetInstance())
+    OnScreenOrientationChanged(sensor->GetScreenOrientation());
+}
+
 void NativeAppWindowTizen::ViewHierarchyChanged(
     const ViewHierarchyChangedDetails& details) {
   if (details.is_add && details.child == this) {
@@ -200,17 +207,6 @@ blink::WebScreenOrientationType
   return orientation;
 }
 
-void NativeAppWindowTizen::LockOrientation(
-      blink::WebScreenOrientationLockType lock) {
-  orientation_lock_ = lock;
-  if (SensorProvider* sensor = SensorProvider::GetInstance())
-    OnScreenOrientationChanged(sensor->GetScreenOrientation());
-}
-
-void NativeAppWindowTizen::UnlockOrientation() {
-  LockOrientation(blink::WebScreenOrientationLockDefault);
-}
-
 void NativeAppWindowTizen::OnScreenOrientationChanged(
     blink::WebScreenOrientationType orientation) {
 
index e671692..0e4c4d8 100644 (file)
@@ -5,13 +5,13 @@
 #ifndef XWALK_RUNTIME_BROWSER_UI_NATIVE_APP_WINDOW_TIZEN_H_
 #define XWALK_RUNTIME_BROWSER_UI_NATIVE_APP_WINDOW_TIZEN_H_
 
+#include "content/browser/screen_orientation/screen_orientation_provider.h"
 #include "xwalk/runtime/browser/ui/screen_orientation.h"
 #include "xwalk/runtime/browser/ui/native_app_window_views.h"
 #include "xwalk/tizen/mobile/sensor/sensor_provider.h"
 #include "xwalk/tizen/mobile/ui/tizen_system_indicator_widget.h"
 #include "xwalk/tizen/mobile/ui/widget_container_view.h"
 #include "ui/aura/window_observer.h"
-#include "content/browser/screen_orientation/screen_orientation_provider.h"
 
 namespace xwalk {
 
@@ -20,12 +20,14 @@ namespace xwalk {
 class NativeAppWindowTizen
     : public aura::WindowObserver,
       public NativeAppWindowViews,
-      public SensorProvider::Observer,
-      public content::ScreenOrientationProvider {
+      public SensorProvider::Observer {
  public:
   explicit NativeAppWindowTizen(const NativeAppWindow::CreateParams& params);
   virtual ~NativeAppWindowTizen();
 
+  void LockOrientation(
+      blink::WebScreenOrientationLockType orientations);
+
  private:
   blink::WebScreenOrientationType FindNearestAllowedOrientation(
       blink::WebScreenOrientationType orientation) const;
@@ -36,11 +38,6 @@ class NativeAppWindowTizen
   virtual void OnScreenOrientationChanged(
       blink::WebScreenOrientationType orientation) OVERRIDE;
 
-  // content::ScreenOrientationProvider overrides:
-  virtual void LockOrientation(
-      blink::WebScreenOrientationLockType orientations) OVERRIDE;
-  virtual void UnlockOrientation() OVERRIDE;
-
   // NativeAppWindowViews overrides:
   virtual void Initialize() OVERRIDE;
 
@@ -74,6 +71,10 @@ class NativeAppWindowTizen
   DISALLOW_COPY_AND_ASSIGN(NativeAppWindowTizen);
 };
 
+inline NativeAppWindowTizen* ToNativeAppWindowTizen(NativeAppWindow* window) {
+  return static_cast<NativeAppWindowTizen*>(window);
+}
+
 }  // namespace xwalk
 
 #endif  // XWALK_RUNTIME_BROWSER_UI_NATIVE_APP_WINDOW_TIZEN_H_